__module_name__ = "pyChuckBot" __module_version__ = "1.0" __module_description__ = "Parses A website for 5 random chuck norris facts" import xchat, pycurl, StringIO, re, time, os oldtime = 0 def reply(word, word_eol, userdata): """Takes everything that is said in the chat and checks for the word google, then curls for the search terms and prints the top 5 URLS""" mt = time.time() ot = globals()['oldtime'] if mt >= ot + 5: p = re.compile('!chuck', re.IGNORECASE) # Search for google within the text m = p.search(word[1]) # If triggered then parse the website if m: c = pycurl.Curl() c.setopt(pycurl.URL, "http://66.111.201.60/chuck/rss.php" ) b = StringIO.StringIO() c.setopt(pycurl.WRITEFUNCTION, b.write) c.setopt(pycurl.FOLLOWLOCATION, 1) c.setopt(pycurl.MAXREDIRS, 5) c.perform() # Find the links within the html h = re.compile("