Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (40 sloc) 1.23 KB
import urllib2 as url
import urllib
import httplib as http
import cleverbot
myses = cleverbot.Session()
def fmtId( string ):
return string[1:len( string ) - 1]
def talk(id,req,messagestr):
#typing = url.urlopen('http://omegle.com/typing', '&id='+id)
#typing.close()
msg = myses.Ask(messagestr)
print msg
msgReq = url.urlopen('http://omegle.com/send', '&msg='+msg+'&id='+id)
msgReq.close()
def listenserv(id,req):
while True:
site = url.urlopen(req)
rec = site.read()
if 'waiting' in rec:
print 'waiting'
elif 'connected' in rec:
print 'Got one!'
messagestr = 'Hello'
talk(id,req,messagestr)
elif ' strangerDisconeccted' in rec:
print 'He left, What a cunt.'
connect()
elif 'typing' in rec:
print 'he is typing..'
elif 'gotMessage' in rec:
messagestr = rec[16:len( rec ) - 2]
print(messagestr)
talk(id,req,messagestr)
def connect():
site = url.urlopen('http://omegle.com/start','')
id = fmtId( site.read() )
print(id)
req = url.Request('http://omegle.com/events', urllib.urlencode( {'id':id}))
listenserv(id,req)
connect()
Jump to Line
Something went wrong with that request. Please try again.