-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestBot.py
48 lines (39 loc) · 1.19 KB
/
testBot.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
import re
import random
from eliza_chatdata import ElizaChatData
psychobabble = []
def genericResponse():
global psychobabble
for pattern, responses in psychobabble:
#try:
print(pattern)
match = re.match(pattern, "what really happened to you.")
if match:
response = random.choice(responses)
try:
return response.format(" That")
except:
pass
#except:
# return "Random2 "
return ("Exited")
def addChatData(chatdata):
global psychobabble
if psychobabble == []:
psychobabble = chatdata
else:
for pattern, responses in chatdata:
isFound = False
for patt, resp in psychobabble:
if pattern == patt:
isFound = True
for reply in responses:
if reply not in resp:
resp.append(reply)
if isFound == False:
data =[]
data.append(pattern)
data.append(responses)
psychobabble.append(data)
addChatData(ElizaChatData().psychobabble)
print(genericResponse())