diff options
author | yvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd> | 2009-06-11 17:47:05 +0000 |
---|---|---|
committer | yvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd> | 2009-06-11 17:47:05 +0000 |
commit | 508dce1a34e85702e25e2628f6a90718b6f1a13d (patch) | |
tree | da2f75bc7d40a0cbfdb11db7444ada8f3d96d3c6 | |
parent | 6124c3ead6a45ae852ec2b671436a9de0566002a (diff) | |
download | omegle-508dce1a34e85702e25e2628f6a90718b6f1a13d.tar.gz omegle-508dce1a34e85702e25e2628f6a90718b6f1a13d.zip |
dbchange
git-svn-id: http://xapek.org/svn/common/omegle@1116 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
-rw-r--r-- | db_proxy.py | 7 | ||||
-rw-r--r-- | megahal_bot.py | 68 | ||||
-rw-r--r-- | megahal_local.py | 4 | ||||
-rw-r--r-- | proxy.py | 5 |
4 files changed, 35 insertions, 49 deletions
diff --git a/db_proxy.py b/db_proxy.py index 9e5273e..8cb3e55 100644 --- a/db_proxy.py +++ b/db_proxy.py @@ -12,10 +12,9 @@ __all__ = [] class DBThread(Thread): - def __init__(self,conn_str): + def __init__(self,**kwargs): Thread.__init__(self) -# dbconn = ...("dbname='yvesf' user='dbuser' host='localhost' password='dbpass'") - self.conn = pyPgSQL.PgSQL.connect(conn_str, client_encoding="utf-8", unicode_results=1) + self.conn = pyPgSQL.PgSQL.connect(client_encoding="utf-8", unicode_results=1,**kwargs) self.queue = Queue.Queue() self.running = True def run(self): @@ -61,7 +60,7 @@ if __name__ == "__main__": logging.basicConfig(level=logging.DEBUG) print "press ctrl-c to abort" - db=DBThread("") + db=DBThread(database="omegle") db.start() try: db.create_table() diff --git a/megahal_bot.py b/megahal_bot.py index 0db602a..adc6429 100644 --- a/megahal_bot.py +++ b/megahal_bot.py @@ -44,7 +44,7 @@ class MegahalBot(OmegleChat): self.disconnect() else: self.logger.info("Idle count %s/8" % self.idlecount) - self.respond("are you there?") #restart the conv. + self.respond("hey?") #restart the conv. def on_message(self,message): print self.c("%s%s [MSG] %s: %s" %( @@ -57,7 +57,10 @@ class MegahalBot(OmegleChat): try: self.typing() except Exception,e: - print e + try: + self.disconnect() + except: + self.disconnect_event.set() return time.sleep(random.randint(1,3)) self.respond(message,prepend="\033[1A\033[2K\033[%sD"%(len(typestr))) #move up 1; delete line; move left %s @@ -75,53 +78,34 @@ class MegahalBot(OmegleChat): if __name__ == "__main__": mh_python.initbrain() - conn = pyPgSQL.PgSQL.connect("") + conn = pyPgSQL.PgSQL.connect(database="omegle") cur = conn.cursor() + #normal # sql = """SELECT message FROM omegle_messages -#WHERE LENGTH(message) < 15 -# OR CAST(RANDOM()*10 AS integer) < 6;""" #reduziert kurze sachen -# sql = """SELECT message FROM omegle_messages""" + # WHERE LENGTH(message) < 35 + # AND NOT ( message ILIKE '%www.%' + # OR message ILIKE '%http%' + # OR message ILIKE '%@%.%') + # ; +# """ - #hmm + #Offensive sql = """SELECT message FROM omegle_messages - WHERE LENGTH(message) < 35 - AND NOT ( message ILIKE '%www.%' - OR message ILIKE '%http%' - OR message ILIKE '%@%.%') + WHERE ( message ILIKE '%sex%' + OR message ILIKE '%boob%' + OR message ILIKE '%horny %' + OR message ILIKE '%pussy %' + OR message ILIKE '%ass %' + OR message ILIKE '%naked%' + OR message ILIKE '%fuck%' + OR LENGTH(message) < 7 AND CAST(RANDOM()*10 as integer)=1) + AND LENGTH(message) < 35 + AND NOT ( message ILIKE '%www.%' + OR message ILIKE '%http%' + OR message ILIKE '%@%.%') ; """ -# #Offensive -# sql = """SELECT message FROM omegle_messages -# WHERE ( message ILIKE '%sex%' -# OR message ILIKE '%boob%' -# OR message ILIKE '%horny %' -# OR message ILIKE '%pussy %' -# OR message ILIKE '%ass %' -# OR message ILIKE '%naked%' -# OR message ILIKE '%fuck%' -# OR LENGTH(message) < 7 AND CAST(RANDOM()*10 as integer)=1) -# AND LENGTH(message) < 35 -# AND NOT ( message ILIKE '%www.%' -# OR message ILIKE '%http%' -# OR message ILIKE '%@%.%') -# ; -# """ - -# sql = """ -#SELECT message -# FROM omegle_messages -# WHERE from_ident IN ( -# SELECT from_ident -# FROM omegle_messages -# WHERE ( message ILIKE '%sex%' -# OR message ILIKE '%cam%' -# OR message ILIKE '%boobs%' -# OR message ILIKE '%horny%' -# OR message ILIKE '%pussy%' -# OR message ILIKE '%ass%') -# AND NOT ( message ILIKE '%www%' -# OR message ILIKE '%http%'));""" cur.execute(sql) messages = cur.fetchall() c=0 diff --git a/megahal_local.py b/megahal_local.py index b17316f..024d053 100644 --- a/megahal_local.py +++ b/megahal_local.py @@ -4,7 +4,7 @@ import pyPgSQL.PgSQL mh_python.initbrain() -conn = pyPgSQL.PgSQL.connect("") +conn = pyPgSQL.PgSQL.connect(database="omegle") cur = conn.cursor() cur.execute(""" @@ -24,7 +24,7 @@ while True: print "%s%s" % ("\033[2K\033[E",c), mh_python.learn("%s"%message[0]) -print "" +print "all learned" cur.close() conn.close() import sys @@ -31,7 +31,10 @@ class OmegleProxyChat(OmegleChat): self.idlecount += 1 if self.idlecount > 8: self.logger.info("Idle > 8. disconnect()") - self.disconnect() + try: + self.disconnect() + except: + self.disconnect_event.set() else: self.logger.info("Idle count %s/8" % self.idlecount) |