summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--megahal_bot.py49
-rw-r--r--megahal_local.py34
2 files changed, 30 insertions, 53 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()
diff --git a/megahal_local.py b/megahal_local.py
deleted file mode 100644
index 024d053..0000000
--- a/megahal_local.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import mh_python
-import pyPgSQL.PgSQL
-
-mh_python.initbrain()
-
-
-conn = pyPgSQL.PgSQL.connect(database="omegle")
-
-cur = conn.cursor()
-cur.execute("""
-SELECT message FROM omegle_messages
-WHERE NOT ( message ILIKE '%www.%'
- OR message ILIKE '%http:%'
- OR message ILIKE '%@%.%');
-""")
-c=0
-while True:
- messages = cur.fetchmany(1000)
- if len(messages)==0:
- break
- for message in messages:
- c+=1
- if c%50==0:
- print "%s%s" % ("\033[2K\033[E",c),
- mh_python.learn("%s"%message[0])
-
-print "all learned"
-cur.close()
-conn.close()
-import sys
-while True:
- print ">>> ",
- x=sys.stdin.readline().strip()
- print "<<< %s " % mh_python.doreply(x)