summaryrefslogtreecommitdiff
path: root/megahal_bot.py
diff options
context:
space:
mode:
authoryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-06-11 20:52:42 +0000
committeryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-06-11 20:52:42 +0000
commit4a71dd2884f207cfbecc94f6d3b256380e658d38 (patch)
tree81fed63dc0887a14cf52cd4cd13a7f7fd2a1220c /megahal_bot.py
parente3a9529caa55dc537a5912928b518eadf9d7bc67 (diff)
downloadomegle-4a71dd2884f207cfbecc94f6d3b256380e658d38.tar.gz
omegle-4a71dd2884f207cfbecc94f6d3b256380e658d38.zip
hal
git-svn-id: http://xapek.org/svn/common/omegle@1120 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
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()