#!/usr/bin/python # -*- vim: encoding: utf-8 -*- # Yves Fischer, xapek.org 2009 import sys import random from twisted.words.protocols import oscar from twisted.internet import reactor from twisted.python import log from omegle import OmegleChat from icq import ExtendedBOSConnection, ReconnectOscarFactory ICQ_UIN = '446323989' ICQ_PASSWORD = 'gagaga' def random_greetings(): gr = ( "Sup dawg, we heard u need some stranger in ur chatroom, so we put a Stranger in ur chatroom so u can chat with him while u chat with others (until you type %disconnect% anywhere)", "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.", ) return "==== %s" % gr[random.randint(0,len(gr)-1)] class OmegleICQChat(OmegleChat): def __init__(self,icqconn,user): self.user = user self.icqconn = icqconn OmegleChat.__init__(self,name="omegle") def on_message(self,message): self.send_icqconn( message ) def send_icqconn(self,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") #von omegle kommt immer unicode, icq sendet latin1/iso-8859-1 message = unicode(message) 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): """ 0x02 begin 0x01 idle 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 "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 "Omegle->%s: (connected)" % self.user self.send_icqconn( random_greetings() ) def on_disconnect(self): print "Omegle->%s: (disconnected)" % self.user self.send_icqconn( "==Stranger Disconnected ==" ) class ICQBuddy( ExtendedBOSConnection ): def initDone( self ): ExtendedBOSConnection.initDone( self ) self.omegleConns = {} def shutdown( self ): for conn in self.omegleConns: if conn.is_connected: conn.disconnect() def receiveTyping(self, user, state): try: if state == "finish": self.omegleConns[user].stopped_typing() elif state == "idle": pass elif state == "begin": self.omegleConns[user].typing() except: pass def receiveCleanMessage( self, user, message, flags ): print "receiveCleanMessage" if not self.omegleConns.has_key(user.name): self.omegleConns[user.name] = OmegleICQChat(self,user.name) if not self.omegleConns[user.name].is_connected: if u"%connect%" in message: 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: print "Not connected" # self.sendMessage(user.name, "Not connected, type >connect<") elif self.omegleConns[user.name].is_connected and u"%disconnect%" in message: try: self.omegleConns[user.name].disconnect() except Exception,e: self.sendMessage(user.name, str(e)) self.sendMessage(user.name, "Disconnecting") 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: try: 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) if __name__ == '__main__': import logging logging.basicConfig(level=logging.INFO) log.startLogging(sys.stdout) factory = ReconnectOscarFactory(ICQBuddy, ICQ_UIN,ICQ_PASSWORD,icq=1) reactor.run()