summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--megahal_bot.py49
-rw-r--r--omegle.py10
-rw-r--r--proxy.py4
3 files changed, 57 insertions, 6 deletions
diff --git a/megahal_bot.py b/megahal_bot.py
index 9865df7..5055e45 100644
--- a/megahal_bot.py
+++ b/megahal_bot.py
@@ -30,7 +30,7 @@ class MegahalBot(OmegleChat):
def respond(self,message):
r=mh_python.doreply(message.encode("utf-8"))
print self.c("%s [MSG] %s: %s" %(time.strftime("%H:%M:%S"), self.name, r),bold=True)
- self.send(r.decode("utf-8"))
+ self.send(r) #.decode("utf-8"))
def on_idle(self):
self.idlecount += 1
@@ -40,9 +40,13 @@ class MegahalBot(OmegleChat):
else:
self.logger.info("Idle count %s/8" % self.idlecount)
def on_message(self,message):
- self.idlecount = 0
print self.c("%s [MSG] %s: %s" %(time.strftime("%H:%M:%S"), "Stranger", message),bold=True,color=32)
- time.sleep(1)
+ self.idlecount = 0
+ time.sleep(0.05)
+ print self.c("%s [EVT] %s: typing" %(time.strftime("%H:%M:%S"), self.name),bold=True,color=32),
+ self.typing()
+ time.sleep(1.5)
+ print "\033[E\033[2K",
self.respond(message)
def on_connect(self):
@@ -60,7 +64,44 @@ if __name__ == "__main__":
conn = pyPgSQL.PgSQL.connect("")
cur = conn.cursor()
- cur.execute("SELECT message FROM omegle_messages")
+# 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"""
+
+
+ #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
for message in messages:
diff --git a/omegle.py b/omegle.py
index 2713636..8aac69e 100644
--- a/omegle.py
+++ b/omegle.py
@@ -125,9 +125,15 @@ class OmegleChat(RESTClient):
"""
#if a raw string given, assume its utf8
if msg.__class__ == str:
- msg = msg.decode("utf8")
+ try:
+ msg = msg.decode("utf8")
+ except UnicodeDecodeError:
+ pass
#convert utf8 to RAW-utf8
- msg = msg.encode("utf8")
+ try:
+ msg = msg.encode("utf8")
+ except UnicodeEncodeError,e:
+ self.logger.critical(e)
if not self.is_confirmed:
self.logger.error("Cant send message if not is_confirmed")
diff --git a/proxy.py b/proxy.py
index 07a83d7..39c72a4 100644
--- a/proxy.py
+++ b/proxy.py
@@ -16,6 +16,7 @@ class OmegleProxyChat(OmegleChat):
self.name = name
self.color = color
self.idlecount = 0
+ self.partner = None
def c(self,str,bold=False):
if bold:
@@ -36,6 +37,7 @@ class OmegleProxyChat(OmegleChat):
def on_message(self,message):
self.idlecount = 0
+ self.partner.idlecount = 0
print self.c("%s [MSG] %s: %s" %(time.strftime("%H:%M:%S"), self.name, message.encode("utf-8")),bold=True)
if self.partner.is_connected:
self.partner.send(message)
@@ -44,6 +46,8 @@ class OmegleProxyChat(OmegleChat):
print self.c("%s [EVT] %s Connection confirmed" % (time.strftime("%H:%M:%S"), self.name))
def on_typing(self):
+ self.idlecount = 0
+ self.partner.idlecount = 0
print self.c("%s [EVT] %s is typing" % (time.strftime("%H:%M:%S"), self.name))
if self.partner.is_connected:
self.partner.typing()