-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatter.py
40 lines (29 loc) · 818 Bytes
/
chatter.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
import aiml
class Chatter:
botList = [
"alice"]
k = None
def __init__(self):
self.k = aiml.Kernel()
pass
def load_bot(self, bot):
list_of_files = open("./" + bot + "/files")
line = list_of_files.readline()
files = line.split(" ")
for i in files:
i = "./" + bot + "/" + i
print("loading: " + i)
self.k.learn(i)
i = list_of_files.readline()
def start_bot_loop(self):
self.k.respond("load aiml b")
while True:
print(self.k.respond(raw_input("> ")))
def get_reply(self, msg):
return self.k.respond(msg)
def main():
chat = Chatter()
chat.load_bot("alice")
chat.start_bot_loop()
if __name__ == "__main__":
main()