summaryrefslogtreecommitdiff
path: root/omegle
diff options
context:
space:
mode:
authoryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2010-01-14 23:03:06 +0000
committeryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2010-01-14 23:03:06 +0000
commit9fc737865ab67fa1302cc1f49f3f563ef057782b (patch)
tree2581ca1d49b21a07e7a6af0b971d44bb27859e46 /omegle
parente76492815e75ead949a424c3fec73ac19c739f0a (diff)
downloadomegle-master.tar.gz
omegle-master.zip
git-svn-id: http://xapek.org/svn/common/omegle@1538 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
Diffstat (limited to 'omegle')
-rw-r--r--omegle/icq.py146
-rw-r--r--omegle/icqBuddy.py14
-rw-r--r--omegle/icqChatroomBuddy.py5
-rw-r--r--omegle/icqRoombot.py4
4 files changed, 87 insertions, 82 deletions
diff --git a/omegle/icq.py b/omegle/icq.py
index 3cb5c7f..b134dd6 100644
--- a/omegle/icq.py
+++ b/omegle/icq.py
@@ -3,36 +3,38 @@
# Yves Fischer, xapek.org 2009
import struct
-from twisted.words.protocols import oscar
-from twisted.internet import reactor, protocol
+#from twisted.words.protocols import oscar
+from tlib import oscar
+from twisted.internet import reactor, protocol, defer
from twisted.internet.protocol import ClientFactory
-CAP_TYPING = '\x56\x3f\xc8\x09\x0b\x6f\x41\xbd\x9f\x79\x42\x26\x09\xdf\xa2\xf3'
+__all__ = ['ReconnectingOSCARLoginFactory', 'ExtendedBOSConnection']
+CAP_TYPING = '\x56\x3f\xc8\x09\x0b\x6f\x41\xbd\x9f\x79\x42\x26\x09\xdf\xa2\xf3'
class ExtendedBOSConnection( oscar.BOSConnection ):
- capabilities = [oscar.CAP_CHAT,CAP_TYPING]
+ capabilities = [oscar.CAP_CHAT, CAP_TYPING]
- def __init__(self,s,p,**kwargs):
- oscar.BOSConnection.__init__(self, s, p,**kwargs)
+ def __init__(self,username, cookie, authenticator = None):
+ oscar.BOSConnection.__init__(self, username, cookie)
+ self.authenticator = authenticator
+ print self.authenticator
- """
- handles typing SNAC
- """
+ """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"):
+ if len(data) == len('\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\t222840035\x00\x02'):
user = data[11:20]
state = data[20:22]
- if state == "\x00\x00": #finish
- self.receiveTyping(user, "finish")
- elif state == "\x00\x01": #idle
- self.receiveTyping(user, "idle")
- elif state == "\x00\x02": #begin
- self.receiveTyping(user, "begin")
+ if state == '\x00\x00': #finish
+ self.receiveTyping(user, 'finish')
+ elif state == '\x00\x01': #idle
+ self.receiveTyping(user, 'idle')
+ elif state == '\x00\x02': #begin
+ self.receiveTyping(user, 'begin')
else:
- print "Unknown state in typing snac\nuser %s\ndata %s\nsnac %s\nstate %X%X" % (user,data,snac,state[0],sate[1])
+ print 'Unknown state in typing snac\nuser %s\ndata %s\nsnac %s\nstate %X%X' % (user,data,snac,state[0],sate[1])
else:
- print "komisches tpying snac"
+ print 'komisches tpying snac'
def receiveTyping(self, user, state):
pass
@@ -45,25 +47,25 @@ class ExtendedBOSConnection( oscar.BOSConnection ):
pass
def updateBuddy(self, user):
- print "updateBuddy %s" % user
+ print 'updateBuddy %s' % user
def gotBuddyList( self, buddylist ):
self.activateSSI()
- self.setProfile("Forget ICQ, MSN, Yahoo and the other shitty protocols! Use XMPP/Jabber!")
+ self.setProfile('Forget ICQ, MSN, Yahoo and the other shitty protocols! Use XMPP/Jabber!')
self.setIdleTime( 0 )
self.clientReady()
for user in buddylist[0][0].users:
- print "icq: Authorize %s" % user.name
+ print 'icq: Authorize %s' % user.name
self.sendAuthorizationResponse(user.name, True, '')
- """message - utf8 """
+ """message - utf8"""
def receiveCleanMessage( self, user, message, flags ):
raise NotImplementedError('receiveCleanMessage( self, user, message, flags )')
def _getMessage(self,multiparts):
message = None
if len(multiparts[0]) == 2:
- if multiparts[0][1] == "unicode":
+ if multiparts[0][1] == 'unicode':
message = unicode(multiparts[0][0])
else:
message = multiparts[0][0].decode(multiparts[0][1],'latin1')
@@ -73,80 +75,80 @@ class ExtendedBOSConnection( oscar.BOSConnection ):
def receiveMessage( self, user, multiparts, flags ):
- print "icq: receiveMessage(%s,%s,%s)" % (user,multiparts,flags)
- if flags != None and "auto" in flags:
- print "'auto' message, abort"
- return
+ print 'icq: receiveMessage(%s,%s,%s)' % (user,multiparts,flags)
+ if flags != None and 'auto' in flags:
+ return #skip 'auto' messages
- # because i cant receive the "budded added signal" i auth on every message
+ # because i cant receive the 'buddy added signal' i auth on every message
self.sendAuthorizationResponse(user.name, True, '')
#cleanup message
try:
message = self._getMessage( multiparts )
#filter qip \x00CHAR\x00CHAR - qip sucks at unicode?
- message = filter(lambda x: x!=u"\x00", message)
+ message = filter(lambda x: x!=u'\x00', message)
self.receiveCleanMessage( user, message, flags )
except Exception,e:
- print "Exception: %s" % e
-
- def chatReceiveMessage( self, chat, user, message ):
- self.receiveMessage( self, user, message, [] )
+ print 'Exception: %s' % e
def sendAuthorizationResponse(self, uin, success, responsString):
- packet = struct.pack("b", len(uin)) + uin
+ packet = struct.pack('b', len(uin)) + uin
if success:
- packet += struct.pack("b", 1)
+ packet += struct.pack('b', 1)
else:
- packet += struct.pack("b", 0)
- packet += struct.pack(">H", len(responsString)) + responsString
+ packet += struct.pack('b', 0)
+ packet += struct.pack('>H', len(responsString)) + responsString
self.sendSNACnr(0x13, 0x1a, packet)
def sendMessage(self, user, messageUtf8):
message = messageUtf8.encode('latin1','replace')
oscar.BOSConnection.sendMessage(self,user,message)
- def connectionLost(self,reason):
- print "Connection lost"
- oscar.BOSConnection.connectionLost(self,reason)
- self.shutdown()
- self.transport.loseConnection()
- self.authenticator.connectionLost(reason)
-
-class Authenticator( oscar.OscarAuthenticator ):
- def connectionLost(self,reason):
- oscar.OscarAuthenticator.connectionLost(self,reason)
- self.factory.connectionLost(reason)
-
- def connectToBOS(self, server, port):
- c = protocol.ClientCreator(reactor, self.BOSClass,
- self.username, self.cookie)
- c.authenticator = self
- return c.connectTCP(server, port)
-
+ def connectionLost(self, reason):
+ self.factory.clientConnectionLost(self, reason)
+ oscar.BOSConnection.connectionLost(self,reason)
-class ReconnectOscarFactory(ClientFactory):
- def __init__(self, BOSClass, uid, password,icq=1):
- self.BOSClass = BOSClass
+class ReconnectingOSCARFactory(protocol.ClientFactory):
+ delay = 10.0
+ BOSClass = oscar.BOSConnection
+ def __init__(self, uid, cookie, password, host, port):
self.uid = uid
+ self.cookie = cookie
self.password = password
- self.icq = icq
-
+ self.host = host
+ self.port = port
def buildProtocol(self, addr):
- p = Authenticator(self.uid, self.password,icq=self.icq)
+ p = self.BOSClass(self.uid, self.cookie)
p.factory = self
+ return p
+ def clientConnectionLost(self, connector, reason):
+ reactor.callLater(self.delay, self._reconnect)
+ def _reconnect(self):
+ print "_reconnect"
+ f = ReconnectingOSCARLoginFactory(self.uid, self.password)
+ f.BOSClass = self.BOSClass
+ return reactor.connectTCP(self.host, self.port, f)
+
+class Authenticator(oscar.OscarAuthenticator):
+ BOSClass = oscar.BOSConnection
+ def connectToBOS(self, host, port):
+ f = ReconnectingOSCARFactory(self.username, self.cookie, self.password, host, port)
+ f.BOSClass = self.BOSClass
+ reactor.connectTCP(host, port, f)
+ return defer.Deferred() #dummy
+
+class ReconnectingOSCARLoginFactory(protocol.ReconnectingClientFactory):
+ BOSClass = oscar.BOSConnection
+ def __init__(self, uid, password):
+ self.uid = uid
+ self.password = password
+ def buildProtocol(self, addr):
+ p = Authenticator(self.uid, self.password)
p.BOSClass = self.BOSClass
+ p.factory = self
return p
-
- def startedConnecting(self, connector):
- print 'Started to connect to oscar'
-
- def connectionLost(self,reason):
- print "CONECTION LOST - start njew factory"
- reactor.callLater(4.0, reactor.connectTCP,
- 'login.icq.com', 5238, self)
-# reactor.connectTCP('login.icq.com', 5238, OscarFactory(self.uin, self.password,icq=1))
-
-
+ ## only reconnect on *failures*
+ def clientConnectionLost(self, con, reason):
+ pass
diff --git a/omegle/icqBuddy.py b/omegle/icqBuddy.py
index c51419f..1a9d609 100644
--- a/omegle/icqBuddy.py
+++ b/omegle/icqBuddy.py
@@ -9,10 +9,9 @@ from twisted.internet import reactor
from twisted.python import log
from omegle import OmegleChat
-from icq import ExtendedBOSConnection, ReconnectOscarFactory
+from icq import ExtendedBOSConnection, ReconnectingOSCARLoginFactory
-ICQ_UIN = '446323989'
-ICQ_PASSWORD = 'gagaga'
+ICQ_UIN, ICQ_PASSWORD = ('446323989', 'gagaga')
def random_greetings():
gr = (
@@ -20,7 +19,9 @@ def random_greetings():
"Connected with Omegle, be retarted with strangers!",
"Omegle ... its like pedo-roulette",
"Under law 153:276:935 section 864, Omegle is required to inform you that the person you are currently chatting with owns the IP address of a registered sex offender. Please be careful when chatting with this person, and remember never to give out your personal information. The person you are chatting with cannot see this message.",
+ "You're Now On Omegle, Note: In China Too Young Is Just a Name",
)
+
return "==== %s" % gr[random.randint(0,len(gr)-1)]
class OmegleICQChat(OmegleChat):
@@ -67,7 +68,8 @@ class ICQBuddy( ExtendedBOSConnection ):
self.omegleConns = {}
def shutdown( self ):
- for conn in self.omegleConns:
+ for k in self.omegleConns.keys():
+ conn = self.omegleConns[k]
if conn.is_connected:
conn.disconnect()
@@ -116,6 +118,8 @@ if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
log.startLogging(sys.stdout)
- factory = ReconnectOscarFactory(ICQBuddy, ICQ_UIN,ICQ_PASSWORD,icq=1)
+ f = ReconnectingOSCARLoginFactory(ICQ_UIN, ICQ_PASSWORD)
+ f.BOSClass = ICQBuddy
+ reactor.connectTCP('login.icq.com', 5238, f)
reactor.run()
diff --git a/omegle/icqChatroomBuddy.py b/omegle/icqChatroomBuddy.py
index a235334..be92c58 100644
--- a/omegle/icqChatroomBuddy.py
+++ b/omegle/icqChatroomBuddy.py
@@ -8,7 +8,7 @@ from twisted.internet import reactor, protocol
from twisted.python import log
from omegle.icqBuddy import ICQBuddy
-from icq import ReconnectOscarFactory
+from icq import ReconnectingOSCARLoginFactory
ICQ_UIN = '446323989'
ICQ_PASSWORD = 'gagaga'
@@ -29,6 +29,7 @@ if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
log.startLogging(sys.stdout)
- factory = ReconnectOscarFactory(OmegleICQChatroomBuddy, ICQ_UIN,ICQ_PASSWORD,icq=1)
+ factory = ReconnectingOSCARLoginFactory(ICQ_UIN,ICQ_PASSWORD)
+ factory.BOSClass = OmegleICQChatroomBuddy
reactor.connectTCP('login.icq.com', 5238, factory)
reactor.run()
diff --git a/omegle/icqRoombot.py b/omegle/icqRoombot.py
index 3f463a5..17a0a3d 100644
--- a/omegle/icqRoombot.py
+++ b/omegle/icqRoombot.py
@@ -1,8 +1,6 @@
#!/usr/bin/python
# Yves Fischer, xapek.org 2009
-
-import sys
-from icq import ExtendedBOSConnection, ReconnectOscarFactory
+from icq import ExtendedBOSConnection
from random import randint
from twisted.internet import reactor