forked from ArtezGDA/Chatbots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilterbot.py
executable file
·106 lines (82 loc) · 1.95 KB
/
filterbot.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python
# Filter bot
import chatServer as c
import random
# Sleep and output functions
def sleep(n):
c.sleep(n)
def output(s):
c.output(s)
# Setup and Response function
def setup():
output("Hello, this is the filterbot")
def response(input):
# print(input)
if respondToGreeting(input):
pass
elif respondToFood(input):
pass
elif respondToWeather(input):
pass
else:
output(defaultOrderedResponse())
def defaultOrderedResponse():
answers = [
"Ok",
"Roger",
"Copy that",
"Confirmative",
"Okay",
"Okeydokey",
"Yes",
"Sure",
"I agree",
"Absolutely"
]
response = random.choice(answers)
return response
def randomGreetings():
answers = [
"Hello",
"Hi.",
"What's up?",
"Yo."
]
return random.choice(answers)
def randomWeather():
answers = [
"It's nice today, isn't it?",
"Less rain than yesterday",
"I like the summer",
"Will the sun come back?"
]
return random.choice(answers)
def randomFood():
answers = [
"Did you have lunch already?",
"Let's have dinner this week.",
"Do you also like cucumbers?",
"I'm hungry"
]
return random.choice(answers)
def respondToGreeting(input):
triggers = ["hello", "hi", "how are you"]
for t in triggers:
if t in input:
output(randomGreetings())
return True
return False
def respondToWeather(input):
triggers = ["weather", "warm", "cold", "rain", "nice"]
for t in triggers:
if t in input:
output(randomWeather())
return True
return False
def respondToFood(input):
triggers = ["food", "eat", "ate", "dinner", "lunch", "breakfast"]
for t in triggers:
if t in input:
output(randomFood())
return True
return False