summaryrefslogtreecommitdiff
path: root/pyaiml_test.py
diff options
context:
space:
mode:
authoryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-12-07 07:40:04 +0000
committeryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-12-07 07:40:04 +0000
commit92626714d8aa68ef70aff0fb998d7870a5d48aa8 (patch)
treef7f604db6fc5d8925b6bd4ce1e38c18210d2d478 /pyaiml_test.py
parent1836f91a4e4048fab9d7af99ec4c015d6fa764c8 (diff)
downloadomegle-92626714d8aa68ef70aff0fb998d7870a5d48aa8.tar.gz
omegle-92626714d8aa68ef70aff0fb998d7870a5d48aa8.zip
bla
git-svn-id: http://xapek.org/svn/common/omegle@1475 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
Diffstat (limited to 'pyaiml_test.py')
-rw-r--r--pyaiml_test.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/pyaiml_test.py b/pyaiml_test.py
new file mode 100644
index 0000000..3b23cd5
--- /dev/null
+++ b/pyaiml_test.py
@@ -0,0 +1,37 @@
+import aiml
+
+k=aiml.Kernel()
+k.bootstrap(learnFiles="std-startup.xml", commands="load aiml b")
+while True: print k.respond(raw_input("> "))
+
+"""
+from twisted.python import log
+from kippo.core import honeypot
+
+learnFiles="std-startup.xml"
+
+
+class HalCommand(honeypot.HoneyPotCommand):
+ k = None
+ @staticmethod
+ def init():
+ HalCommand.k = aiml.Kernel()
+ HalCommand.k.bootstrap(learnFiles=learnFiles, commands="load aiml b")
+
+ def start(self):
+ from random import randint
+ token = "token_%s" % (0,10000)
+ self.write("HAL: Am I playing a man or a machine?... This is a character that thinks rather than acts\n")
+ self.write("You: ")
+ self.callbacks = [ lambda line: self.respond(line, token) ]
+
+ def respond(self,line,token)
+ resp = "HAL: %s" % HalCommand.k.respond(line, sessionID=token)
+ self.write(resp)
+ self.callbacks.append(lambda line: self.respond(line, token))
+
+ def lineReceived(self,line):
+ self.callbacks.pop(0)(line)
+
+HalCommand.init()
+"""