From bcbd91805a9a2ea27772e404d421234e59841e19 Mon Sep 17 00:00:00 2001 From: yvesf Date: Thu, 11 Jun 2009 20:58:29 +0000 Subject: blah git-svn-id: http://xapek.org/svn/common/omegle@1121 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd --- megahal_bot.py | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) (limited to 'megahal_bot.py') diff --git a/megahal_bot.py b/megahal_bot.py index 49a4c37..20fe7aa 100644 --- a/megahal_bot.py +++ b/megahal_bot.py @@ -83,20 +83,23 @@ if __name__ == "__main__": Argumente: -h, --help Diese Hilfe --host=HOST (Standard: HOST=omegle.com) - -d DBNAME or + -d DBNAME or --dbname=DBNAME Database (Standard: DBNAME=omegle) + -l or + --local Do local testing --profile=NAME Database select profile (Standard: NAME=standard) see sourcecode""" % (sys.argv[0]) #parse args try: - opts, args = getopt.getopt(sys.argv[1:], "hd:", ["help", "host=", "profile=","dbname="]) + opts, args = getopt.getopt(sys.argv[1:], "hd:l", ["help", "host=", "profile=","dbname=","local"]) except getopt.GetoptError,err: print str(err) usage() sys.exit(2) #defaults + local = False host = "omegle.com" sql = {"standard": """SELECT message FROM omegle_messages @@ -124,11 +127,13 @@ Argumente: dbname = "omegle" for o, a in opts: - if o in ('h', '--help'): + if o in ('-h', '--help'): usage() sys.exit(0) - elif o in ('d', '--dbname'): + elif o in ('-d', '--dbname'): dbname = a + elif o in ('-l', '--local'): + local = True elif o == "--host": host = a elif o == "--profile": @@ -156,20 +161,26 @@ Argumente: del messages logging.basicConfig(level=logging.DEBUG) - print "press ctrl-c to abort" - event = Event() - bot=MegahalBot(event,"A",host=host,color=31) + if local: + print ">>>", + while True: + x=sys.stdin.readline().strip() + print "<<< %s\n>>>" % mh_python.doreply(x), + else: + print "press ctrl-c to abort" + event = Event() + bot=MegahalBot(event,"A",host=host,color=31) + + bot.start() - bot.start() - - try: - while True: - event.wait(0.5) - if event.isSet(): - print "partner" - break - except KeyboardInterrupt: - print "CTRL-C pressed, exiting" - - if bot.is_connected: bot.disconnect() + try: + while True: + event.wait(0.5) + if event.isSet(): + print "partner" + break + except KeyboardInterrupt: + print "CTRL-C pressed, exiting" + + if bot.is_connected: bot.disconnect() -- cgit v1.2.1