Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib2 as url
- import urllib
- import thread as thr
- idList = list()
- def disconnect( id ):
- url.urlopen( 'http://omegle.com/disconnect', urllib.urlencode( {'id':id} ) )
- #for posting things
- def sendOmegle( msg, sendId = None, recId = None ):
- '''if id is None, send to all'''
- if recId != None:
- if sendId != None:
- print '*** Not supported yet.'
- else:
- #send msg from bot to one person
- url.urlopen( 'http://omegle.com/send', urllib.urlencode( {'id':recId, 'msg':msg} ) )
- print msg
- else:
- if sendId != None:
- #send msg from one person to all
- sentMsg = sendId + ': ' + msg
- for id in idList:
- if id != sendId:
- url.urlopen( 'http://omegle.com/send', urllib.urlencode( {'id':id, 'msg':sentMsg} ) )
- try:
- print sendId + ': ' + msg.decode( 'utf-8' )
- except:
- print '*** OH GOD AN EXCEPTION'
- print sentMsg
- else:
- #send msg from bot to all
- for id in idList:
- url.urlopen( 'http://omegle.com/send', urllib.urlencode( {'id':id, 'msg':msg} ) )
- print msg
- def fmtId( string ):
- return string[1:len( string ) - 1]
- def connect():
- #start omegle
- site = url.urlopen( 'http://omegle.com/start', '' )
- #get id
- id = fmtId( site.read() )
- idList.append( id )
- #connect
- req = url.Request( 'http://omegle.com/events', urllib.urlencode( {'id':id} ) )
- print '*** Getting a stranger...'
- while True:
- site = url.urlopen( req )
- rec = site.read()
- if 'connected' in rec:
- print '*** You have connected!'
- break
- def runAll():
- for id in idList:
- thr.start_new_thread( runOne, ( id, ) )
- while len( idList ) != 0:
- pass
- print '*** Everyone left.'
- def runOne( id ):
- global idList
- while len( idList ) != 0:
- isDisconnected = False
- site = url.urlopen( 'http://omegle.com/events', urllib.urlencode( {'id':id} ) )
- rec = site.read()
- if rec != 'null':
- inputs = eval( rec )
- for inp in inputs:
- if inp[0] == "strangerDisconnected":
- idList.remove( id )
- if len( idList ) > 1:
- sendOmegle( id + ' disconnected, ' + str( len( idList ) - 1 ) + ' other(s) left.' )
- else:
- sendOmegle( 'Everyone but you disconnected, so I\'m out. Have a nice day!' )
- disconnect( idList[0] )
- idList = list()
- isDisconnected = True
- elif inp[0] == "gotMessage":
- if inp[1] == 'list':
- print '***', id, 'has requested a list of IDs.'
- sendOmegle( 'List of all IDs:', None, id )
- for dispId in idList:
- sendOmegle( dispId, None, id )
- elif inp[1] == 'info':
- print '***', id, 'has requested info about the bot.'
- sendOmegle( 'This bot is not affiliated in any way with Omegle. It was just made by a nerd with no life. It\'s in Python!', None, id )
- else:
- sendOmegle( inp[1].decode( 'raw_unicode_escape' ).encode( 'utf-8' ), id, None )
- if isDisconnected:
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement