def botspeak(self, what_is_said,que): what_was_said="derp derp" what_is_said = ' '.join(what_is_said) chatbot_url ='http://www.pandorabots.com/pandora/talk?botid=afdae4b56e344e25&skin=custom_input' post_stuff = urllib.parse.urlencode([("botcust2","9a41a3f618c439e2"),("input",what_is_said)]) page= urllib.request.urlopen(urllib.request.Request(chatbot_url),post_stuff.encode('ascii'),120).read() pagelist = str(page).split("\n") i=0 botreply= pagelist[-1] while botreply.find("ALICE:") == 0: botreply=pagelist[i] i-=1 botreply=str(botreply) botreply=botreply.replace("\\n", "") botreply=botreply.replace("\\", "") start = "" end = "" result = re.search('%s(.*)%s' % (start,end), botreply).group(1) result=result.replace("""
""","") result=result.replace("""Go back the the ALICE AI Foundation and pick the free ALICE download that best for your system. and create your own chat robot!

Maybe you should check out the document DON'T READ ME too.""", "Feels good, man.") que.put(result) return result def onPMMessage(self,pm,user,body): try: que2 = queue.Queue() data = body.split(" ") ret = self.botspeak(data,que2) t = threading.Timer(len(ret.split(" "))*0.20, self.pm.message,[user, ret]) t.start() except Exception as e: print("\n"+e+"\n")