def __init__(self,u,p,pid): self.username=u self.password=p self.user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' self.values = {'username' : self.username,'password':self.password} self.base64string = base64.encodestring('%s:%s' % (self.username, self.password)).replace('\n', '') self.headers = { 'User-Agent' : self.user_agent ,"Authorization": "Basic %s" % self.base64string} self.dd = urllib.urlencode(self.values) self.pid = pid self.frontpage = self.login() self.cbot = cbot_Session()
def __init__(self, u, p, pid): self.username = u self.password = p self.user_agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)" self.values = {"username": self.username, "password": self.password} self.base64string = base64.encodestring("%s:%s" % (self.username, self.password)).replace("\n", "") self.headers = {"User-Agent": self.user_agent, "Authorization": "Basic %s" % self.base64string} self.dd = urllib.urlencode(self.values) self.pid = pid self.frontpage = self.login() self.cbot = cbot_Session()
def __init__(self, u, p, pid): self.username = u self.password = p self.user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' self.values = {'username': self.username, 'password': self.password} self.base64string = base64.encodestring( '%s:%s' % (self.username, self.password)).replace('\n', '') self.headers = { 'User-Agent': self.user_agent, "Authorization": "Basic %s" % self.base64string } self.dd = urllib.urlencode(self.values) self.pid = pid self.frontpage = self.login() self.cbot = cbot_Session()
def listenServer( id, req , log): s = cleverbot.cbot_Session() t=time.time() status = 0 pstring = str(datetime.datetime.now()).split('.')[0] +' [Stranger disconnected, finding new session]' print pstring log.clear_rt() log.write(pstring) closelist = ["bitly", "tyoyu"] while True: if not status and time.time() - t > 10: break site = url.urlopen(req) #We read the HTTP output to get what's going on rec = site.read() if 'waiting' in rec: t = time.time() status = 0 #print("Waiting...") elif 'connected' in rec: print status = 0 t = time.time() #Since this isn't threaded yet, it executes the talk function (yeah, turn by turn) talk(id,req,"hi") pstring = str(datetime.datetime.now()).split('.')[0] +" Cleverbot : " + "hi" #print pstring #log.write(pstring) elif 'strangerDisconnected' in rec: #pstring = str(datetime.datetime.now()).split('.')[0] +' [Stranger disconnected]' print "disconnect..." #log.write(pstring) #We start the whole process again #omegleConnect() break elif 'typing' in rec: status = 1 print "[ Stranger is typing ]" ''' print "[ Stranger is typing ]" log.write("[ Stranger is typing ]") ''' #When we receive a message, print it and execute the talk function elif 'gotMessage' in rec: status = 1 resp = rec[17:len( rec ) - 3] br = 0 for phrase in closelist: if phrase in resp: br = 1 if br: break pstring = str(datetime.datetime.now()).split('.')[0] + " Stranger : "+ resp print pstring log.write(pstring) try: msg = s.Ask(resp) msg.replace(' m ', ' f ') msg.replace('/m/','/f/') except: pass pstring = str(datetime.datetime.now()).split('.')[0] +" Cleverbot : " + msg print pstring log.write(pstring) talk(id,req, msg) status = 0 t = time.time()+10
def listenServer(id, req, log): s = cleverbot.cbot_Session() t = time.time() status = 0 pstring = str(datetime.datetime.now()).split( '.')[0] + ' [Stranger disconnected, finding new session]' print pstring log.clear_rt() log.write(pstring) closelist = ["bitly", "tyoyu"] while True: if not status and time.time() - t > 10: break site = url.urlopen(req) #We read the HTTP output to get what's going on rec = site.read() if 'waiting' in rec: t = time.time() status = 0 #print("Waiting...") elif 'connected' in rec: print status = 0 t = time.time() #Since this isn't threaded yet, it executes the talk function (yeah, turn by turn) talk(id, req, "hi") pstring = str( datetime.datetime.now()).split('.')[0] + " Cleverbot : " + "hi" #print pstring #log.write(pstring) elif 'strangerDisconnected' in rec: #pstring = str(datetime.datetime.now()).split('.')[0] +' [Stranger disconnected]' print "disconnect..." #log.write(pstring) #We start the whole process again #omegleConnect() break elif 'typing' in rec: status = 1 print "[ Stranger is typing ]" ''' print "[ Stranger is typing ]" log.write("[ Stranger is typing ]") ''' #When we receive a message, print it and execute the talk function elif 'gotMessage' in rec: status = 1 resp = rec[17:len(rec) - 3] br = 0 for phrase in closelist: if phrase in resp: br = 1 if br: break pstring = str( datetime.datetime.now()).split('.')[0] + " Stranger : " + resp print pstring log.write(pstring) try: msg = s.Ask(resp) msg.replace(' m ', ' f ') msg.replace('/m/', '/f/') except: pass pstring = str( datetime.datetime.now()).split('.')[0] + " Cleverbot : " + msg print pstring log.write(pstring) talk(id, req, msg) status = 0 t = time.time() + 10