diff options
Diffstat (limited to 'megahal_bot.py')
-rw-r--r-- | megahal_bot.py | 49 |
1 files changed, 30 insertions, 19 deletions
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() |