-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatbot.py
67 lines (45 loc) · 1.99 KB
/
chatbot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from tkinter import *
# GUI
root = Tk()
root.title("Chatbot")
BG_GRAY = "#ABB2B9"
BG_COLOR = "#17202A"
TEXT_COLOR = "#EAECEE"
FONT = "Helvetica 14"
FONT_BOLD = "Helvetica 13 bold"
# Send function
def send():
send = "You -> " + e.get()
txt.insert(END, "\n" + send)
user = e.get().lower()
if (user == "hello"):
txt.insert(END, "\n" + "Bot -> Hi there, how can I help?")
elif (user == "hi" or user == "hii" or user == "hiiii"):
txt.insert(END, "\n" + "Bot -> Hi there, what can I do for you?")
elif (user == "how are you"):
txt.insert(END, "\n" + "Bot -> fine! and you")
elif (user == "fine" or user == "i am good" or user == "i am doing good"):
txt.insert(END, "\n" + "Bot -> Great! how can I help you.")
elif (user == "thanks" or user == "thank you" or user == "now its my time"):
txt.insert(END, "\n" + "Bot -> My pleasure !")
elif (user == "what do you sell" or user == "what kinds of items are there" or user == "have you something"):
txt.insert(END, "\n" + "Bot -> We have coffee and tea")
elif (user == "tell me a joke" or user == "tell me something funny" or user == "crack a funny line"):
txt.insert(
END, "\n" + "Bot -> What did the buffalo say when his son left for college? Bison.! ")
elif (user == "goodbye" or user == "see you later" or user == "see yaa"):
txt.insert(END, "\n" + "Bot -> Have a nice day!")
else:
txt.insert(END, "\n" + "Bot -> Sorry! I didn't understand that")
e.delete(0, END)
lable1 = Label(root, bg=BG_COLOR, fg=TEXT_COLOR, text="Welcome", font=FONT_BOLD, pady=10, width=20, height=1).grid(
row=0)
txt = Text(root, bg=BG_COLOR, fg=TEXT_COLOR, font=FONT, width=60)
txt.grid(row=1, column=0, columnspan=2)
scrollbar = Scrollbar(txt)
scrollbar.place(relheight=1, relx=0.974)
e = Entry(root, bg="#2C3E50", fg=TEXT_COLOR, font=FONT, width=55)
e.grid(row=2, column=0)
send = Button(root, text="Send", font=FONT_BOLD, bg=BG_GRAY,
command=send).grid(row=2, column=1)
root.mainloop()