diff options
-rw-r--r-- | omegle/__init__.py | 5 | ||||
-rw-r--r-- | omegle/__init__.pyc | bin | 0 -> 10666 bytes | |||
-rw-r--r-- | omegle/icq.py | 9 | ||||
-rw-r--r-- | omegle/icq.pyc | bin | 0 -> 6514 bytes | |||
-rw-r--r-- | omegle/icqBuddy.py | 15 | ||||
-rw-r--r-- | omegle/icqChatroomBuddy.py | 16 | ||||
-rw-r--r-- | omegle/icqRoombot.py | 120 |
7 files changed, 137 insertions, 28 deletions
diff --git a/omegle/__init__.py b/omegle/__init__.py index 528b629..5291b55 100644 --- a/omegle/__init__.py +++ b/omegle/__init__.py @@ -1,8 +1,9 @@ +#!/usr/bin/python +# -*- vim: encoding: utf-8 -*- +# Yves Fischer, xapek.org 2009 import sys import httplib -import socket import urllib -import time import json import logging from threading import Thread, Lock, Event diff --git a/omegle/__init__.pyc b/omegle/__init__.pyc Binary files differnew file mode 100644 index 0000000..7cf18a2 --- /dev/null +++ b/omegle/__init__.pyc diff --git a/omegle/icq.py b/omegle/icq.py index e8ed739..aa271cc 100644 --- a/omegle/icq.py +++ b/omegle/icq.py @@ -112,21 +112,22 @@ class ExtendedBOSConnection( oscar.BOSConnection ): oscar.BOSConnection.connectionLost(self,*args,**kwargs) class Authenticator( oscar.OscarAuthenticator ): - BOSClass = ExtendedBOSConnection +# BOSClass = ExtendedBOSConnection def connectionLost(self,reason): oscar.OscarAuthenticator.connectionLost(self,reason) self.factory.connectionLost(reason) class ReconnectOscarFactory(ClientFactory): - OAClass=Authenticator - def __init__(self, uid, password,icq=1): + def __init__(self, BOSClass, uid, password,icq=1): + self.BOSClass = BOSClass self.uid = uid self.password = password self.icq = icq def buildProtocol(self, addr): - p = self.__class__.OAClass(self.uid, self.password,icq=self.icq) + p = Authenticator(self.uid, self.password,icq=self.icq) p.factory = self + p.BOSClass = self.BOSClass return p def startedConnecting(self, connector): diff --git a/omegle/icq.pyc b/omegle/icq.pyc Binary files differnew file mode 100644 index 0000000..9377150 --- /dev/null +++ b/omegle/icq.pyc diff --git a/omegle/icqBuddy.py b/omegle/icqBuddy.py index 554a434..cd34cd4 100644 --- a/omegle/icqBuddy.py +++ b/omegle/icqBuddy.py @@ -8,7 +8,7 @@ from twisted.internet import reactor from twisted.python import log from omegle import OmegleChat -from icq import ExtendedBOSConnection, ReconnectOscarFactory, Authenticator +from icq import ExtendedBOSConnection, ReconnectOscarFactory ICQ_UIN = '446323989' ICQ_PASSWORD = 'gagaga' @@ -101,20 +101,11 @@ class ICQBuddy( ExtendedBOSConnection ): except Exception,e: print "icq(%s): Error %s" % (user.name,e) -class MyAuthenticator( Authenticator ): - BOSClass = ICQBuddy - -class Factory( ReconnectOscarFactory ): - OAClass = MyAuthenticator - if __name__ == '__main__': import logging logging.basicConfig(level=logging.INFO) - log.startLogging(sys.stdout) - print Factory.OAClass - print MyAuthenticator.BOSClass - reactor.connectTCP('login.icq.com', 5238, - Factory(ICQ_UIN,ICQ_PASSWORD,icq=1)) + + factory = ReconnectOscarFactory(ICQBuddy, ICQ_UIN,ICQ_PASSWORD,icq=1) reactor.run() diff --git a/omegle/icqChatroomBuddy.py b/omegle/icqChatroomBuddy.py index d4c2edc..63689f1 100644 --- a/omegle/icqChatroomBuddy.py +++ b/omegle/icqChatroomBuddy.py @@ -1,12 +1,14 @@ #!/usr/bin/python # -*- vim: encoding: utf-8 -*- +# Yves Fischer, xapek.org 2009 import sys from twisted.words.protocols import oscar from twisted.internet import reactor, protocol from twisted.python import log -from omegle.icqBuddy import OmegleICQ, OscarFactory +from omegle.icqBuddy import OmegleICQ +from icq import ReconnectOscarFactory ICQ_UIN = '446323989' ICQ_PASSWORD = 'gagaga' @@ -20,18 +22,12 @@ class OmegleICQChatroomBuddy( OmegleICQ ): self.sendMessage(ICQ_CHATROOM_UID, "/leave") OmegleICQ.shutdown(self) -class Authenticator( oscar.OscarAuthenticator ): - BOSClass = OmegleICQChatroomBuddy - -class MyOscarFactory(OscarFactory): - BOSClass = Authenticator - if __name__ == '__main__': import logging logging.basicConfig(level=logging.INFO) - log.startLogging(sys.stdout) - reactor.connectTCP('login.icq.com', 5238, - MyOscarFactory(ICQ_UIN,ICQ_PASSWORD,icq=1)) + + factory = ReconnectOscarFactory(OmegleICQChatroomBuddy, ICQ_UIN,ICQ_PASSWORD,icq=1) + reactor.connectTCP('login.icq.com', 5238, factory) reactor.run() diff --git a/omegle/icqRoombot.py b/omegle/icqRoombot.py new file mode 100644 index 0000000..2ded976 --- /dev/null +++ b/omegle/icqRoombot.py @@ -0,0 +1,120 @@ +#!/usr/bin/python +# Yves Fischer, xapek.org 2009 + +import sys +from icq import ExtendedBOSConnection, ReconnectOscarFactory, Authenticator +from random import randint +from twisted.python import log +from twisted.internet import reactor + +class Member(object): + def __init__(self,id,name): + self.id = id + self.name = name + +class Room(object): + def __init__(self): + self.members = [] + self.msg_cbs = [] + + def addMessageCallback(self,cb): + self.msg_cbs.append(cb) + + def removeMessageCallback(self,cb): + self.msg_cbs.remove(cb) + + def join(self,member): + self.members.append(member) + + def leave(self,member): + self.members.remove(member) + + def getMemberById(self,id): + l=filter(lambda member: member.id == id, self.members) + if len(l) > 0: + return l[0] + else: + return None + + instance = None + @classmethod + def getInstance(klass): + if klass.instance == None: + klass.instance = Room() + return klass.instance + +CAP_TYPING = '\x56\x3f\xc8\x09\x0b\x6f\x41\xbd\x9f\x79\x42\x26\x09\xdf\xa2\xf3' +class ICQRoombot( ExtendedBOSConnection ): + + def initDone( self ): + ExtendedBOSConnection.initDone(self) + self.room = Room.getInstance() + self.members = dict() + + def receiveCleanMessage( self, user, message, flags ): + print "receiveCleanMessage" + try: + if self.room.getMemberById(user.name) != None: + member = self.room.getMemberById(user.name) + + if message.strip() == "/leave": + self.room.leave(member) + self.sendMessage(user.name, 'You left') + for otherMember in self.room.members: + self.sendMessage(otherMember.id, "===== %s/%s left"%(member.name,member.id) ) + elif message.strip().startswith("/invite"): + otherUin = message.strip().split("/invite")[1].strip() + self.sendMessage(otherUin, "Youre invited by %s to join this room!, Type \" /join nickname\""%(user.name)) + self.sendMessage(member.id, "Invitation sent to %s"%otherUin) + elif message.strip().startswith("/nick"): + newNick = message.strip().split("/nick")[1] + for otherMember in self.room.members: + self.sendMessage(otherMember.id, "===== %s now known as %s" % (member.name,newNick)) + member.name = newNick + elif message.strip().startswith("/msg"): + otherNick = message.strip().split("/msg")[1].strip().split(" ")[0] + otherMember = filter(lambda m: m.name == otherNick, self.room.members) + if len(otherMember) == 0: + self.sendMessage(member.id, "===== Nick %s gibts nicht!" % otherNick) + else: + self.sendMessage(otherMember[0].id, "=== Privat von %s/%s: %s" % (member.name,member.id,message)) + elif message.strip() == "/list": + self.sendMessage(member.id, "===== List: %s"%", ".join(map(lambda m: "%s/%s"%(m.id,m.name),self.room.members)) ) + elif message.strip().startswith("/"): + self.sendMessage(member.id, "===== kennich nicht") + else: + i=0 + for otherMember in self.room.members: + i += 1 + if otherMember.id == user.name: + continue + reactor.callLater(i, self.sendMessage, otherMember.id, "%s: %s" %(member.name, message.strip())) + else: + if message.strip().startswith("/join"): + nick = message.strip().split("/join")[1].strip() + member = Member(user.name, nick) + self.room.join(member) + i=0 + for otherMember in self.room.members: + i += 1 + reactor.callLater(i, self.sendMessage, otherMember.id, "===== %s/%s joined" % (member.name,member.id)) + else: + if randint(0,5) == 3: + self.sendMessage(user.name, "Use '/join Nickname' or ' /join Nickname'") + + self.sendAuthorizationResponse(user.name, True, '') + except Exception,e: + print "error: %s %s\n%s" % (user,multiparts,e) + +if __name__ == '__main__': + uin = '370496181' + password = 'megahal123' + host, port = ('login.oscar.aol.com', 5190) + + import logging + logging.basicConfig(level=logging.INFO) + log.startLogging(sys.stdout) + + fac = ReconnectOscarFactory(ICQRoombot, uin, password, icq=1) + reactor.connectTCP(host, port, fac) + reactor.run() |