diff options
-rw-r--r-- | megahal_bot.py | 4 | ||||
-rw-r--r-- | pyaiml_bot.py | 13 | ||||
-rw-r--r-- | pyaiml_test.py | 37 |
3 files changed, 46 insertions, 8 deletions
diff --git a/megahal_bot.py b/megahal_bot.py index 8f92961..9008db8 100644 --- a/megahal_bot.py +++ b/megahal_bot.py @@ -183,7 +183,7 @@ Argumente: mh_python.initbrain() - conn = pyPgSQL.PgSQL.connect(database=dbname) + conn = pyPgSQL.PgSQL.connect(database=dbname,user="yvesf",password="iii",host="10.2.2.13") cur = conn.cursor() print sql[sqlKey] @@ -203,7 +203,7 @@ Argumente: conn.close() del messages - logging.basicConfig(level=logging.DEBUG) + logging.basicConfig(level=logging.ERROR) if local: print "CTRL-C\n>>> ", while True: diff --git a/pyaiml_bot.py b/pyaiml_bot.py index 2a41848..587d01b 100644 --- a/pyaiml_bot.py +++ b/pyaiml_bot.py @@ -7,14 +7,15 @@ from omegle import OmegleChat import aiml k=aiml.Kernel() -k.bootstrap(learnFiles="aiml_files/std-startup.xml", commands="load aiml b") +#k.bootstrap(learnFiles="aiml_files/std-startup.xml", commands="load aiml b") +k.bootstrap(learnFiles="aiml_files/German-standalone.aiml") -class MegahalBot(OmegleChat): +class PyAIMLBot(OmegleChat): def __init__(self,disconnect_event,name,host="omegle.com",color=0): self.disconnect_event = disconnect_event self.name=name self.color = color - OmegleChat.__init__(self,name=" Megahal",host=host) + OmegleChat.__init__(self,name=" PyAIML",host=host) self.idlecount = 0 @@ -53,7 +54,7 @@ class MegahalBot(OmegleChat): time.strftime("%H:%M:%S"), "Stranger", message),bold=True,color=32) self.idlecount = 0 time.sleep(0.05) - self.logger.info("Megahal simulate typing") + self.logger.info("Bot simulate typing") # typestr = "%s [EVT] %s: typing" %(time.strftime("%H:%M:%S"),self.name) #print self.c(typestr,bold=True,color=32) try: @@ -83,7 +84,7 @@ if __name__ == "__main__": host = "omegle.com" local=False - logging.basicConfig(level=logging.ERROR) + logging.basicConfig(level=logging.DEBUG) if local: print "CTRL-C\n>>> ", while True: @@ -92,7 +93,7 @@ if __name__ == "__main__": else: print "press ctrl-c to abort" event = Event() - bot=MegahalBot(event,"A",host=host,color=31) + bot=PyAIMLBot(event,"A",host=host,color=31) bot.start() 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() +""" |