summaryrefslogtreecommitdiff
path: root/megahal_bot.py
diff options
context:
space:
mode:
Diffstat (limited to 'megahal_bot.py')
-rw-r--r--megahal_bot.py79
1 files changed, 54 insertions, 25 deletions
diff --git a/megahal_bot.py b/megahal_bot.py
index adc6429..49a4c37 100644
--- a/megahal_bot.py
+++ b/megahal_bot.py
@@ -1,5 +1,4 @@
import logging
-import sys
from threading import Event
import random
@@ -76,21 +75,38 @@ class MegahalBot(OmegleChat):
if __name__ == "__main__":
- mh_python.initbrain()
-
- conn = pyPgSQL.PgSQL.connect(database="omegle")
- cur = conn.cursor()
- #normal
-# sql = """SELECT message FROM omegle_messages
- # WHERE LENGTH(message) < 35
- # AND NOT ( message ILIKE '%www.%'
- # OR message ILIKE '%http%'
- # OR message ILIKE '%@%.%')
- # ;
-# """
-
- #Offensive
- sql = """SELECT message FROM omegle_messages
+ import getopt
+ import sys
+
+ def usage():
+ print """%s - megahal ding
+Argumente:
+ -h, --help Diese Hilfe
+ --host=HOST (Standard: HOST=omegle.com)
+ -d DBNAME or
+ --dbname=DBNAME Database (Standard: DBNAME=omegle)
+ --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="])
+ except getopt.GetoptError,err:
+ print str(err)
+ usage()
+ sys.exit(2)
+
+ #defaults
+ host = "omegle.com"
+ sql = {"standard":
+ """SELECT message FROM omegle_messages
+ WHERE LENGTH(message) < 35
+ AND NOT ( message ILIKE '%www.%'
+ OR message ILIKE '%http%'
+ OR message ILIKE '%@%.%')
+ ;""",
+ "offensive":
+ """SELECT message FROM omegle_messages
WHERE ( message ILIKE '%sex%'
OR message ILIKE '%boob%'
OR message ILIKE '%horny %'
@@ -102,11 +118,28 @@ if __name__ == "__main__":
AND LENGTH(message) < 35
AND NOT ( message ILIKE '%www.%'
OR message ILIKE '%http%'
- OR message ILIKE '%@%.%')
- ;
- """
+ OR message ILIKE '%@%.%');""",
+ }
+ sqlKey = "standard"
+ dbname = "omegle"
+
+ for o, a in opts:
+ if o in ('h', '--help'):
+ usage()
+ sys.exit(0)
+ elif o in ('d', '--dbname'):
+ dbname = a
+ elif o == "--host":
+ host = a
+ elif o == "--profile":
+ sqlKey = a
- cur.execute(sql)
+ mh_python.initbrain()
+
+ conn = pyPgSQL.PgSQL.connect(database=dbname)
+ cur = conn.cursor()
+
+ cur.execute(sql[sqlKey])
messages = cur.fetchall()
c=0
for message in messages:
@@ -124,12 +157,8 @@ if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
print "press ctrl-c to abort"
-
event = Event()
- if len(sys.argv) == 2:
- bot=MegahalBot(event,"A",host=sys.argv[1],color=31)
- else:
- bot=MegahalBot(event,"A",host="omegle.com",color=31)#red
+ bot=MegahalBot(event,"A",host=host,color=31)
bot.start()