summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-07-01 21:25:37 +0000
committeryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-07-01 21:25:37 +0000
commit082ff2e370ad174c326e0d8417d5dc4928b206ab (patch)
treed00eeae47e485af5b66e8715288cf05cd13b416b
parent0460320393b10033df2badb98daefe0335232876 (diff)
downloadomegle-082ff2e370ad174c326e0d8417d5dc4928b206ab.tar.gz
omegle-082ff2e370ad174c326e0d8417d5dc4928b206ab.zip
icq bot an dranom upda
git-svn-id: http://xapek.org/svn/common/omegle@1173 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
-rw-r--r--Documentation.txt2
-rw-r--r--abfragen.sql74
-rw-r--r--megahal_bot.py26
-rw-r--r--megahal_icq.py95
-rw-r--r--omegle.py11
-rw-r--r--proxy.py5
6 files changed, 193 insertions, 20 deletions
diff --git a/Documentation.txt b/Documentation.txt
index ee0176f..1e4b928 100644
--- a/Documentation.txt
+++ b/Documentation.txt
@@ -1,3 +1,5 @@
+http://github.com/suttree/grokitbot/blob/8bbd8c40a4cc0e8761053412efa4511403971d7d/AIMLBayes.py
+
__ __
/\ \__/\ \
_____ __ __\ \ ,_\ \ \___ ___ ___
diff --git a/abfragen.sql b/abfragen.sql
index 53ba62d..557bcb0 100644
--- a/abfragen.sql
+++ b/abfragen.sql
@@ -1,5 +1,4 @@
-
--- Ausdauernde
+-- Dauer der längsten Gespräche
SELECT a.send_time - b.send_time AS "Dauer", date_trunc('day',a.send_time)
FROM ( SELECT MAX(send_time) AS send_time, from_ident
FROM omegle_messages
@@ -9,12 +8,77 @@
GROUP BY from_ident ) b
ON a.from_ident = b.from_ident
WHERE a.send_time - b.send_time > interval '1 hour'
-ORDER BY 1 DESC;
+ORDER BY 1 DESC
+LIMIT 10;
--- Fleissigste
+-- Poster mit den meisten abgesendeten Nachrichten
SELECT COUNT(*), from_ident, date_trunc('hour',MIN(send_time))
FROM omegle_messages
GROUP BY from_ident
- HAVING COUNT(*) > 10
+ HAVING COUNT(*) > 200
ORDER BY 1 DESC;
+
+-- Anteil von GEsprächen in denen ein Begriff vorkommt
+SELECT to_char(a.tag,'DD.MM FMDay'), (b.count/CAST(a.count as real))*100 AS Anteil
+FROM (
+SELECT date_trunc('day', om1.send_time) AS Tag, COUNT(*)
+FROM omegle_messages om1
+GROUP BY date_trunc('day', om1.send_time)
+) a JOIN (
+SELECT date_trunc('day', om1.send_time) AS Tag, COUNT(*)
+FROM omegle_messages om1
+WHERE from_ident IN ( SELECT DISTINCT from_ident
+ FROM omegle_messages
+ WHERE message ILIKE '%hell%')
+GROUP BY date_trunc('day', om1.send_time)
+) b ON a.Tag = b.Tag;
+
+
+
+-- Gesprächsfetzen - DEFEKT
+SELECT om1.message AS msgA,
+ om2.message AS msgB
+ FROM omegle_messages om1,
+ omegle_messages om2
+ WHERE om1.from_ident = om2.to_ident
+ AND om2.send_time > om1.send_time
+ AND om2.send_time = ( SELECT MAX(send_time) from omegle_messages om3 WHERE om3.send_time > om1.send_time AND om1.from_ident = om3.to_ident );
+ AND LENGTH(om1.message) < 100 AND LENGTH(om2.message) < 100;
+ LIMIT 10
+;
+
+
+
+-- ALle möglichen Partner
+
+
+SELECT to_char(MIN(om1.send_time),'DD') || '_' || om1.from_ident
+FROM omegle_messages om1
+GROUP BY om1.from_ident
+LIMIT 4
+;
+
+SELECT DISTINCT om1.to_ident, om2.from_ident
+FROM omegle_messages om1 JOIN (
+ SELECT DISTINCT from_ident
+ FROM omegle_messages
+) om2 ON om1.from_ident = om2.from_ident
+LIMIT 10;
+
+
+
+SELECT initiator,MAX(send_time)
+FROM (
+ SELECT SUBSTR(from_ident||to_ident,0,7) AS "initiator", MAX(send_time) AS "send_time"
+ FROM omegle_messages om1
+ WHERE from_ident IS NOT NULL and to_ident IS NOT NULL
+ GROUP BY from_ident || to_ident
+ UNION
+ SELECT SUBSTR(to_ident||from_ident,7,12) AS "initiator", MAX(send_time) AS "send_time"
+ FROM omegle_messages om1
+ WHERE from_ident IS NOT NULL and to_ident IS NOT NULL
+ GROUP BY to_ident||from_ident ) o1
+GROUP BY "initiator"
+ORDER BY 2
+LIMIT 10; \ No newline at end of file
diff --git a/megahal_bot.py b/megahal_bot.py
index f1f3864..8f92961 100644
--- a/megahal_bot.py
+++ b/megahal_bot.py
@@ -29,7 +29,7 @@ class MegahalBot(OmegleChat):
def respond(self,message,prepend=""):
r=mh_python.doreply(message.encode("utf-8"))
- print self.c("%s%s [MSG] %s: %s" %(prepend,time.strftime("%H:%M:%S"), self.name, r),bold=True)
+ print self.c("%s [MSG] %s: %s" %(time.strftime("%H:%M:%S"), self.name, r),bold=True)
try:
self.send(r) #.decode("utf-8"))
except Exception,e:
@@ -44,16 +44,18 @@ class MegahalBot(OmegleChat):
self.disconnect_event.set()
else:
self.logger.info("Idle count %s/8" % self.idlecount)
- self.respond("hey?") #restart the conv.
+ if self.is_confirmed:
+ self.respond("hey?") #restart the conv.
def on_message(self,message):
- print self.c("%s%s [MSG] %s: %s" %(
- "\033[1A\033[2K\033[30D",
+ self.logger.info("Stranger: %s" % message)
+ print self.c("%s [MSG] %s: %s" %(
time.strftime("%H:%M:%S"), "Stranger", message),bold=True,color=32)
self.idlecount = 0
time.sleep(0.05)
- typestr = "%s [EVT] %s: typing" %(time.strftime("%H:%M:%S"),self.name)
- print self.c(typestr,bold=True,color=32)
+ self.logger.info("Megahal simulate typing")
+# typestr = "%s [EVT] %s: typing" %(time.strftime("%H:%M:%S"),self.name)
+ #print self.c(typestr,bold=True,color=32)
try:
self.typing()
except Exception,e:
@@ -63,7 +65,7 @@ class MegahalBot(OmegleChat):
self.disconnect_event.set()
return
time.sleep(random.randint(2,5))
- self.respond(message,prepend="\033[1A\033[2K\033[%sD"%(len(typestr))) #move up 1; delete line; move left %s
+ self.respond(message) #prepend="\033[1A\033[2K\033[%sD"%(len(typestr))) #move up 1; delete line; move left %s
def on_connect(self):
print self.c("%s [EVT] %s Connection confirmed" % (time.strftime("%H:%M:%S"), self.name))
@@ -105,11 +107,12 @@ Argumente:
host = "omegle.com"
sql = {"standard":
"""SELECT message FROM omegle_messages
- WHERE LENGTH(message) < 35
+ WHERE LENGTH(message) < 50
AND NOT ( message ILIKE '%www.%'
OR message ILIKE '%http%'
OR message ILIKE '%@%.%')
;""",
+ "all":"""SELECT message FROM omegle_messages""",
"offensive":
"""SELECT message FROM omegle_messages
WHERE ( message ILIKE '%sex%'
@@ -127,8 +130,9 @@ Argumente:
OR message ILIKE '%http%'
OR message ILIKE '%@%.%');""",
"offensive-large":
- """SELECT message FROM omegle_messages WHERE from_ident in (
- SELECT from_ident FROM omegle_messages
+ """
+ SELECT message FROM omegle_messages WHERE from_ident in (
+ SELECT DISTINCT from_ident FROM omegle_messages
WHERE ( message ILIKE '%sex%'
OR message ILIKE '%boob%'
OR message ILIKE '%horny %'
@@ -173,7 +177,6 @@ Argumente:
elif o in ("-p", "--profile"):
if sql.has_key(a):
sqlKey = a
- print sql[a]
else:
print "Profile %s does not exist, create it!" % a
sys.exit(0)
@@ -183,6 +186,7 @@ Argumente:
conn = pyPgSQL.PgSQL.connect(database=dbname)
cur = conn.cursor()
+ print sql[sqlKey]
cur.execute(sql[sqlKey])
messages = cur.fetchall()
c=0
diff --git a/megahal_icq.py b/megahal_icq.py
new file mode 100644
index 0000000..f9afeaa
--- /dev/null
+++ b/megahal_icq.py
@@ -0,0 +1,95 @@
+#!/usr/bin/python
+import struct
+import sys
+
+from twisted.words.protocols import oscar
+from twisted.internet import reactor, protocol
+import mh_python
+import pyPgSQL.PgSQL
+
+uin = '370496181'
+print "Enter icq password(megahal...): ",
+password = sys.stdin.readline().strip()
+
+mh_python.initbrain()
+
+conn = pyPgSQL.PgSQL.connect(database="omegle")
+cur = conn.cursor()
+
+cur.execute("""
+SELECT message from omegle_messages WHERE LENGTH(message) BETWEEN 3 AND 30
+AND NOT ( message ILIKE '%www.%'
+ OR message ILIKE '%http%'
+ OR message ILIKE '%@%.%')
+""")
+messages = cur.fetchall()
+c=0
+for message in messages:
+ c+=1
+ if c%500==0:
+ print "%s%s/%s" % ("\033[2K\033[E",c,len(messages)),
+ #XXX pass massage[0] to mh and end with a fucked up python
+ mh_python.learn("%s " % (message[0]))
+
+print "%s%s/%s" % ("\033[2K\033[E",len(messages),len(messages))
+cur.close()
+conn.close()
+del messages
+
+
+
+
+
+class icqBot( oscar.BOSConnection ):
+ capabilities = [oscar.CAP_CHAT]
+# oscar.CAP_SEND_FILE,oscar.CAP_GET_FILE]
+
+ def initDone( self ):
+ self.requestSelfInfo()
+ self.requestSSI().addCallback(self.gotBuddyList)
+
+ def updateBuddy(self, user):
+ print "Update buddy %s" % user
+
+ def gotBuddyList( self, buddylist ):
+ self.activateSSI()
+ self.setProfile("Forget ICQ, MSN, Yahoo and the other shitty protocols! Use Jabber!")
+ self.setIdleTime( 0 )
+ self.clientReady()
+
+ print buddylist
+ print 'ICQ-Autoresponder-Bot aktiviert ;-)'
+
+ def receiveMessage( self, user, multiparts, flags ):
+ try:
+ sss = str(multiparts[0][0])
+ reply = mh_python.doreply(sss)
+ self.sendMessage(user.name, reply )
+ print "from: " + user.name+':', multiparts[0][0]
+ print " to: " + user.name+':',reply
+ self.sendAuthorizationResponse(user.name, True, '')
+ except Exception,e:
+ print "error: %s %s\n%s" % (user,multiparts,e)
+
+ def chatReceiveMessage( self, chat, user, message ):
+ self.receiveMessage( self, user, message, 0 )
+ def receiveSendFileRequest(self, *args):
+# def receiveSendFileRequest(self, user, file, description, cookie):
+ print args
+
+ def sendAuthorizationResponse(self, uin, success, responsString):
+ packet = struct.pack("b", len(uin)) + uin
+ if success:
+ packet += struct.pack("b", 1)
+ else:
+ packet += struct.pack("b", 0)
+ packet += struct.pack(">H", len(responsString)) + responsString
+ self.sendSNACnr(0x13, 0x1a, packet)
+
+
+class OscarCrap( oscar.OscarAuthenticator ):
+ BOSClass = icqBot
+
+protocol.ClientCreator( reactor, OscarCrap, uin, password, icq=1 ).connectTCP( 'login.icq.com', 5238 )
+reactor.run()
+
diff --git a/omegle.py b/omegle.py
index 395bf4b..62a3892 100644
--- a/omegle.py
+++ b/omegle.py
@@ -54,6 +54,7 @@ class RESTClient(object):
try:
headers = RESTClient.headers.copy()
headers['Host'] = self.host
+ headers['Content-Length'] = str(len(params))
self.conn.request(method,path,params,headers)
resp = self.conn.getresponse()
finally:
@@ -94,14 +95,14 @@ class OmegleChat(RESTClient):
def disconnect(self):
"""Close a chat session."""
self.logger.debug("disconnect()")
- self.is_connected = False
+ self.is_confirmed = False
self.timer.stop()
if self.is_confirmed:
r = RESTClient.request(self,"POST", "/disconnect", urllib.urlencode({'id': self.id}))
body = r.read()
self.logger.debug("/disconnect sent. Read: %s" % body)
if body == "win":
- self.is_confirmed = False
+ self.is_connected = False
self.id = None
self.conn.close()
else:
@@ -110,9 +111,13 @@ class OmegleChat(RESTClient):
def _events(self):
"""does use its own "HTTPConnection" because its called async from a thread"""
conn = httplib.HTTPConnection(self.host)
+ params = urllib.urlencode({'id' : self.id})
+ headers = OmegleChat.headers.copy()
+ headers['Host'] = "omegle.com"
+ headers['Content-Length'] = str(len(params))
conn.request("POST",
"/events",
- urllib.urlencode({'id' : self.id}),
+ params,
OmegleChat.headers)
r=conn.getresponse()
body=r.read()
diff --git a/proxy.py b/proxy.py
index 43e5a24..93e9911 100644
--- a/proxy.py
+++ b/proxy.py
@@ -73,7 +73,10 @@ class OmegleProxyChat(OmegleChat):
def on_disconnect(self):
print self.c("%s [EVT] %s disconnect" % (time.strftime("%H:%M:%S"), self.name))
if self.partner.is_confirmed:
- self.partner.disconnect()
+ try:
+ self.partner.disconnect()
+ except:
+ pass
self.disconnect_event.set()