summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--icq_roombot.py6
-rw-r--r--megahal_bot.py17
-rw-r--r--megahal_icq.py6
-rw-r--r--omegle_icq.py88
-rw-r--r--omegle_jabber.py42
-rw-r--r--pyaiml_bot.py4
-rw-r--r--pyaiml_test.py3
-rw-r--r--unfoggedbot.py12
8 files changed, 123 insertions, 55 deletions
diff --git a/icq_roombot.py b/icq_roombot.py
index 7dc3da9..835d639 100644
--- a/icq_roombot.py
+++ b/icq_roombot.py
@@ -186,15 +186,20 @@ class ReconnectingOSCARFactory(protocol.ClientFactory):
return p
def clientConnectionLost(self, connector, reason):
+ print "reconnect in %s" % self.delay
reactor.callLater(self.delay, self._reconnect)
def _reconnect(self):
+ print "reconnect"
f = ReconnectingOSCARLoginFactory(uin, password)
return reactor.connectTCP(host, port, f)
class OscarCrap( oscar.OscarAuthenticator ):
BOSClass = icqBot
connectfactory = ReconnectingOSCARFactory
+ def connectToBOS(self, server, port):
+ f = self.connectfactory(self.username, self.cookie)
+ return reactor.connectTCP(server, int(port), f)
class ReconnectingOSCARLoginFactory(protocol.ReconnectingClientFactory):
protocol = OscarCrap
@@ -214,4 +219,3 @@ if __name__ == '__main__':
f = ReconnectingOSCARLoginFactory(uin, password)
reactor.connectTCP(host, port, f)
reactor.run()
-
diff --git a/megahal_bot.py b/megahal_bot.py
index 9008db8..428ca6c 100644
--- a/megahal_bot.py
+++ b/megahal_bot.py
@@ -88,6 +88,8 @@ Argumente:
--host=HOST (Standard: HOST=omegle.com)
-d DBNAME or
--dbname=DBNAME Database (Standard: DBNAME=omegle)
+ --user=USER
+ --password=PASSWORD
-l or
--local Do local testing
-p NAME or
@@ -96,7 +98,7 @@ Argumente:
#parse args
try:
- opts, args = getopt.getopt(sys.argv[1:], "hp:d:l", ["help", "host=", "profile=","dbname=","local"])
+ opts, args = getopt.getopt(sys.argv[1:], "hp:d:l", ["help", "host=", "profile=","dbname=","local","user=","password="])
except getopt.GetoptError,err:
print str(err)
usage()
@@ -112,7 +114,7 @@ Argumente:
OR message ILIKE '%http%'
OR message ILIKE '%@%.%')
;""",
- "all":"""SELECT message FROM omegle_messages""",
+ "all":"""SELECT message FROM omegle_messages WHERE LENGTH(message) > 2 AND LENGTH(message) < 35""",
"offensive":
"""SELECT message FROM omegle_messages
WHERE ( message ILIKE '%sex%'
@@ -163,13 +165,18 @@ Argumente:
}
sqlKey = "standard"
dbname = "omegle"
-
+ user = "omegle"
+ password = "omegle"
for o, a in opts:
if o in ('-h', '--help'):
usage()
sys.exit(0)
elif o in ('-d', '--dbname'):
dbname = a
+ elif o in ('--user'):
+ user = a
+ elif o in ('--password'):
+ password = a
elif o in ('-l', '--local'):
local = True
elif o == "--host":
@@ -183,7 +190,7 @@ Argumente:
mh_python.initbrain()
- conn = pyPgSQL.PgSQL.connect(database=dbname,user="yvesf",password="iii",host="10.2.2.13")
+ conn = pyPgSQL.PgSQL.connect(database=dbname,user=user,password=password,host="10.2.2.13")
cur = conn.cursor()
print sql[sqlKey]
@@ -203,7 +210,7 @@ Argumente:
conn.close()
del messages
- logging.basicConfig(level=logging.ERROR)
+ logging.basicConfig(level=logging.DEBUG)
if local:
print "CTRL-C\n>>> ",
while True:
diff --git a/megahal_icq.py b/megahal_icq.py
index 8ae3dd6..0f46c00 100644
--- a/megahal_icq.py
+++ b/megahal_icq.py
@@ -9,8 +9,7 @@ import mh_python
import pyPgSQL.PgSQL
uin = '370496181'
-print "Enter icq password(megahal...): ",
-password = sys.stdin.readline().strip()
+password = raw_input( "Enter icq password(megahal...): " )
def fill_hal():
mh_python.initbrain()
@@ -22,8 +21,7 @@ def fill_hal():
SELECT message from omegle_messages WHERE LENGTH(message) BETWEEN 3 AND 30
AND NOT ( message ILIKE '%www.%'
OR message ILIKE '%http%'
- OR message ILIKE '%@%.%')
- """)
+ OR message ILIKE '%@%.%')""")
messages = cur.fetchall()
c=0
for message in messages:
diff --git a/omegle_icq.py b/omegle_icq.py
index 6100e7b..67861fe 100644
--- a/omegle_icq.py
+++ b/omegle_icq.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+# -*- vim: encoding: utf-8 -*-
import struct
import sys
import thread
@@ -19,17 +20,17 @@ class OmegleICQChat(OmegleChat):
def __init__(self,icqconn,user):
self.user = user
self.icqconn = icqconn
- OmegleChat.__init__(self,name="("+user+")")
+ OmegleChat.__init__(self,name="omegle")
def on_message(self,message):
- print "%s: omegle got message %s" % (self.user,message)
self.send_icqconn( message )
def send_icqconn(self,message):
- print "%s: send to icq %s" % (self.user,message)
#send stopped typing snac
reactor.callFromThread(self.icqconn.sendSNAC, 0x04, 0x14, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'+chr(len(self.user))+self.user+"\x00\x00")
- message = message.decode("utf-8")
- message = message.encode("iso-8859-1")
+ #von omegle kommt immer unicode
+ message = unicode(message) #message.decode("utf-8")
+ message = message.encode("iso-8859-1","replace")
+ print "Omegle->%s: %s" % (self.user,message.__repr__())
reactor.callFromThread(self.icqconn.sendMessage, self.user, message )
def on_typing(self):
@@ -39,16 +40,17 @@ class OmegleICQChat(OmegleChat):
0x00 finish
"""
reactor.callFromThread(self.icqconn.sendSNAC, 0x04, 0x14, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'+chr(len(self.user))+self.user+"\x00\x02")
- print "begin typing"
+ print "Omegle->%s: (begin typing)" % self.user
def on_stopped_typing(self):
reactor.callFromThread(self.icqconn.sendSNAC, 0x04, 0x14, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'+chr(len(self.user))+self.user+"\x00\x01")
def on_connect(self):
- print "%s: omegle connected" % self.user
+ print "Omegle->%s: (connected)" % self.user
self.send_icqconn( "== Sup dawg, we heard u like to meet strangers so we put a Stranger in ur chat so u can chat while u chat (until you type \"disconnect\" without quotes) ==" )
+
def on_disconnect(self):
- print "%s: omegle disconnecteed" % self.user
+ print "Omegle->%s: (disconnected)" % self.user
self.send_icqconn( "==Stranger Disconnected ==" )
CAP_TYPING = '\x56\x3f\xc8\x09\x0b\x6f\x41\xbd\x9f\x79\x42\x26\x09\xdf\xa2\xf3'
@@ -61,6 +63,9 @@ class icqBot( oscar.BOSConnection ):
self.factory = factory
oscar.BOSConnection.__init__(self, s, p,**kwargs)
+ """
+ handles typing SNAC
+ """
def oscar_04_14(self,snac):
data = snac[3]
if len(data) == len("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\t222840035\x00\x02"):
@@ -98,7 +103,7 @@ class icqBot( oscar.BOSConnection ):
conn.disconnect()
def updateBuddy(self, user):
- print "Update buddy %s" % user
+ print "icq: Update buddy %s" % user
def gotBuddyList( self, buddylist ):
self.activateSSI()
@@ -106,28 +111,49 @@ class icqBot( oscar.BOSConnection ):
self.setIdleTime( 0 )
self.clientReady()
for user in buddylist[0][0].users:
- print "Authorize %s" % user.name
+ print "icq: Authorize %s" % user.name
self.sendAuthorizationResponse(user.name, True, '')
- print 'ICQ-Autoresponder-Bot aktiviert ;-)'
-
def receiveMessage( self, user, multiparts, flags ):
- print "receiveMessage(%s,%s,%s)" % (user,multiparts,flags)
+ print "icq: receiveMessage(%s,%s,%s)" % (user,multiparts,flags)
if "auto" in flags:
print "'auto' message, abort"
return
+ # because i cant receive the "budded added signal" i auth on every message
self.sendAuthorizationResponse(user.name, True, '')
if not self.omegleConns.has_key(user.name):
self.omegleConns[user.name] = OmegleICQChat(self,user.name)
try:
- message = str(multiparts[0][0])
+ message = None
+ if len(multiparts[0]) == 2:
+ if multiparts[0][1] == "unicode":
+ message = unicode(multiparts[0][0])
+ else:
+ try:
+ message = multiparts[0][0].decode(multiparts[0][1])
+ except Exception,e:
+ self.sendMessage(user.name,str(e))
+ else:
+ try:
+ message = str(multiparts[0][0])
+ except Exception,e:
+ self.sendMessage(user.name,str(e))
+
+ #filter qip \x00CHAR\x00CHAR - qip sucks at unicode?
+ message_neu = filter(lambda x: x!=u"\x00", message)
+ if len(message_neu) != len(message):
+ client_sucks = True
+ message = message_neu
+
if not self.omegleConns[user.name].is_connected:
- if message == "connect":
+ if message == u"connect":
self.omegleConns[user.name].start()
self.sendMessage(user.name, "Please stand by.....")
+ if client_sucks:
+ self.sendMessage(user.name, "Hey, dein ICQ-Client sendet scheiss")
else:
self.sendMessage(user.name, "Not connected, type >connect<")
elif self.omegleConns[user.name].is_connected and message == "disconnect":
@@ -139,12 +165,21 @@ class icqBot( oscar.BOSConnection ):
elif self.omegleConns[user.name].is_connected and not self.omegleConns[user.name].is_confirmed:
self.sendMessage(user.name, "Wait for connection confirm from omegle")
else:
- if len(multiparts[0]) == 2:
- print "send to omegle: %s" % message.decode(multiparts[0][1])
- self.omegleConns[user.name].send(message.decode(multiparts[0][1]))
- else:
- print "send to omegle: %s" % message
- self.omegleConns[user.name].send(message)
+# if len(multiparts[0]) == 2:
+# print "send to omegle: %s" % message.decode(multiparts[0][1])
+# if multiparts[0][1] == "unicode":
+# self.omegleConns[user.name].send(unicode(message))
+# else:
+ try:
+# self.omegleConns[user.name].send(message.decode(multiparts[0][1]))
+ print "%s->Omegle: %s" % (user.name, message.__repr__())
+ self.omegleConns[user.name].send(message)
+ except Exception,e:
+ print "icq(%s): Error %s" % (user.name,e)
+ self.sendMessage(user.name,str(e))
+# else:
+# print "send to omegle: %s" % message
+# self.omegleConns[user.name].send(message)
except Exception,e:
print "error: %s %s -> %s" % (user,multiparts,e)
@@ -160,7 +195,10 @@ class icqBot( oscar.BOSConnection ):
packet += struct.pack(">H", len(responsString)) + responsString
self.sendSNACnr(0x13, 0x1a, packet)
def connectionLost(self,reason):
- print reason
+ print "connnection los called: %s " % reason
+ print dir(self)
+ self.factory.connectionLost(reason)
+ #self.shutdown()
@@ -194,7 +232,8 @@ class OscarFactory(ClientFactory):
print 'Started to connect to oscar'
def connectionLost(self,reason):
- print "CONECTION LOST"
+ print "CONECTION LOST - start njew factory"
+ reactor.connectTCP('login.icq.com', 5238, OscarFactory(uin,password,icq=1))
class OscarClientFactory(ReconnectingClientFactory):
def startedConnecting(self, connector):
@@ -220,7 +259,8 @@ class OscarClientFactory(ReconnectingClientFactory):
# reason)
-
+import logging
+logging.basicConfig(level=logging.INFO)
log.startLogging(sys.stdout)
#protocol.ClientCreator( reactor, OscarCrap, uin, password, icq=1 ).connectTCP( 'login.icq.com', 5238 )
diff --git a/omegle_jabber.py b/omegle_jabber.py
index 9103e2d..51d7ba3 100644
--- a/omegle_jabber.py
+++ b/omegle_jabber.py
@@ -1,9 +1,11 @@
import xmpp
from omegle import OmegleChat
+import Queue
def reply(message,text):
msg = xmpp.Message(to=message.getFrom(),body=text)
- msg.setThread( message.getThread() )
+ if message.getThread():
+ msg.setThread( message.getThread() )
msg.setType( message.getType() )
return msg
@@ -17,31 +19,33 @@ class OmegleXMPP(OmegleChat):
print "%s: omegle got message %s" % (self.last_message.getFrom(),message)
msg = reply(self.last_message, message)
msg.addChild(name="active",namespace="http://jabber.org/protocol/chatstates")
- self.xmpp.send(msg)
+ self.xmpp._myqueue.put_nowait(msg)
def on_typing(self):
msg = xmpp.Message(to=self.last_message.getFrom(),typ=self.last_message.getType())
- msg.setThread(self.last_message.getThread())
+ if self.last_message.getThread():
+ msg.setThread(self.last_message.getThread())
msg.addChild(name="composing",namespace="http://jabber.org/protocol/chatstates")
- self.xmpp.send(msg)
+ self.xmpp._myqueue.put_nowait(msg)
print "begin typing"
def on_stopped_typing(self):
msg = xmpp.Message(to=self.last_message.getFrom(),typ=self.last_message.getType())
- msg.setThread(self.last_message.getThread())
+ if self.last_message.getThread():
+ msg.setThread(self.last_message.getThread())
msg.addChild(name="paused",namespace="http://jabber.org/protocol/chatstates")
- self.xmpp.send(msg)
+ self.xmpp._myqueue.put_nowait(msg)
print "stopped typing"
def on_connect(self):
print "%s: omegle connected" % self.last_message.getFrom()
- self.xmpp.send( reply(self.last_message, "Sup dawg, we heard u like to meet strangers so we put a Stranger in ur chat so u can chat while u chat (until you type \"disconnect\" without quotes) ==") )
+ self.xmpp._myqueue.put_nowait( reply(self.last_message, "Sup dawg, we put a Stranger in ur chat so u can chat while u chat (until you type \"disconnect\" without quotes) ==") )
def on_disconnect(self):
print "%s: omegle disconnecteed" % self.last_message.getFrom()
- self.xmpp.send( reply(self.last_message, "== Stranger disconnected ==") )
+ self.xmpp._myqueue.put_nowait( reply(self.last_message, "== Stranger disconnected ==") )
def on_message_xmpp(self,message):
self.last_message = message
@@ -58,6 +62,7 @@ class XMPPClient(object):
self.omegle_connections = dict()
self.jid = xmpp.JID(jid)
self.client = xmpp.Client(self.jid.getDomain()) #,debug=[])
+ self.client._myqueue = Queue.Queue()
self.client.connect()
self.client.auth(self.jid.getNode(),password)
@@ -66,9 +71,22 @@ class XMPPClient(object):
self.client.RegisterHandler("message", self.messageHandler)
self.client.RegisterHandler("presence", self.presence)
- while self.client.Process(1): pass
+ while self.client.Process(1):
+ try:
+ self.client.send( self.client._myqueue.get(True,1) )
+ except Exception,e:
+ pass #print e
def messageHandler(self,dispatcher,message):
+ if message.getFrom() == "yvesf@xapek.org/mcabber" and message.getBody() \
+ and message.getBody().__len__() > 1 and message.getBody()[0] == "#":
+ try:
+ ret=eval(message.getBody()[1:])
+ except Exception,e:
+ ret = str(e)
+ self.client.send( reply(message, str(ret)))
+ return
+
if not self.omegle_connections.has_key(message.getFrom()):
self.omegle_connections[message.getFrom()] = OmegleXMPP(self.client, message)
@@ -94,11 +112,13 @@ class XMPPClient(object):
print e
def presence(self,dispatcher,presence):
+ print presence.__str__().encode("utf-8")
if presence.getType() == "subscribe":
self.client.Roster.Authorize(presence.getFrom())
- self.client.Roster.Subscribe(presence.getFrom())
+# self.client.Roster.Subscribe(presence.getFrom())
-cl=XMPPClient('omegle@jabber.org','omegle')
+#cl=XMPPClient('omegle@jabber.org','omegle')
+cl=XMPPClient('hpxp@xapek.org','iii')
diff --git a/pyaiml_bot.py b/pyaiml_bot.py
index 587d01b..e916484 100644
--- a/pyaiml_bot.py
+++ b/pyaiml_bot.py
@@ -7,8 +7,8 @@ from omegle import OmegleChat
import aiml
k=aiml.Kernel()
-#k.bootstrap(learnFiles="aiml_files/std-startup.xml", commands="load aiml b")
-k.bootstrap(learnFiles="aiml_files/German-standalone.aiml")
+k.bootstrap(learnFiles="aiml_files/std-startup.xml", commands="load aiml b")
+#k.bootstrap(learnFiles="aiml_files/German-standalone.aiml")
class PyAIMLBot(OmegleChat):
def __init__(self,disconnect_event,name,host="omegle.com",color=0):
diff --git a/pyaiml_test.py b/pyaiml_test.py
index 3b23cd5..01ea63d 100644
--- a/pyaiml_test.py
+++ b/pyaiml_test.py
@@ -1,7 +1,8 @@
import aiml
k=aiml.Kernel()
-k.bootstrap(learnFiles="std-startup.xml", commands="load aiml b")
+k.bootstrap(learnFiles="aiml_files/std-startup.xml", commands="load aiml b")
+#k.bootstrap(learnFiles="aiml_files/German-standalone.aiml")
while True: print k.respond(raw_input("> "))
"""
diff --git a/unfoggedbot.py b/unfoggedbot.py
index 4c943ba..19362da 100644
--- a/unfoggedbot.py
+++ b/unfoggedbot.py
@@ -1,12 +1,12 @@
#! /usr/bin/python
-#from twisted.words.protocols import oscar
-import oscar
+from twisted.words.protocols import oscar
+#import oscar
## local copy taken from the py-aimt project.
## some API differences, but it automagically does rate-limiting stuff.
from twisted.internet import protocol, reactor
from twisted.enterprise.adbapi import ConnectionPool
from twisted.python import log
-import re, feedparser, socket, sets, os
+import re, socket, sets, os
#socket.setdefaulttimeout(60)
@@ -21,7 +21,7 @@ GETSUBSCRIBERS = "SELECT screen_name FROM subscriptions WHERE thread_url = ?"
INSERTCOMMENTS = "INSERT OR IGNORE INTO rss_items (link, processed, thread_url, author, content, title) VALUES (?, ?, ?, ?, ?, ?)"
INSERTPOSTS = "INSERT OR IGNORE INTO posts (post_url, title, processed) VALUES (?, ?, ?)"
-db = ConnectionPool("pysqlite2.dbapi2", DB)
+db = None
permalink = re.compile("http://(www\.)?unfogged\.com/archives/week_...._.._..\.html#(\d+)")
commentlink = re.compile("http://(www\.)?unfogged\.com/archives/comments_(\d+).html")
@@ -208,8 +208,6 @@ class ReconnectingOSCARLoginFactory(protocol.ReconnectingClientFactory):
def getrss():
##on the assumption that this can be done w/o using too much time,
##I have taken this out of a separate thread.
- comments = feedparser.parse("/home/unfogged/unfogged/html/bridgeplate.rdf")
- posts = feedparser.parse("/home/unfogged/unfogged/html/index.xml")
updaterss(comments, posts)
reactor.callLater(15, getrss)
@@ -230,7 +228,7 @@ def updaterss(comments, posts):
if __name__ == '__main__':
- execfile(RC) # values of "sn" and "pass_"
+ sn,pass_="aa","bb"
import sys
sys.stderr = sys.stdout = open("ubot.log", "a+")
log.startLogging(sys.stdout)