summaryrefslogtreecommitdiff
path: root/megahal_bot.py
diff options
context:
space:
mode:
authoryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-06-11 20:58:29 +0000
committeryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-06-11 20:58:29 +0000
commitbcbd91805a9a2ea27772e404d421234e59841e19 (patch)
treef93153c4aa617f9790492d5e8920c8ae09178a4f /megahal_bot.py
parent4a71dd2884f207cfbecc94f6d3b256380e658d38 (diff)
downloadomegle-bcbd91805a9a2ea27772e404d421234e59841e19.tar.gz
omegle-bcbd91805a9a2ea27772e404d421234e59841e19.zip
blah
git-svn-id: http://xapek.org/svn/common/omegle@1121 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
Diffstat (limited to 'megahal_bot.py')
-rw-r--r--megahal_bot.py49
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()