def handle( packet ): try: if packet['rest'][0] == "#": # just parsing channel messages here user = strbetween( packet['host'], ":", "!" ) if __main__.getAccessLevel( user ) < 0: return False # Get out of here banned loser! msgsplit = packet['rest'].split( " :", maxsplit=1 ) channel = msgsplit[0] splitmessage = msgsplit[1].split( " " ) titleFound = False for totest in splitmessage: if urlregex.search( totest ): # great, we found a URL! if not totest.startswith( "http" ): # We need this at the start for some damn reason totest = "http://" + totest try: # who knows what we got sent to tosend = "" if "imgur.com" in totest: tosend = imgur( totest ) elif "youtube.com" in totest or "youtu.be" in totest: tosend = youtube( totest ) else: tosend = normalLink( totest ) tosend = tosend.replace( "google", "Google" ).replace( "Google", "\x02\x03" + "02,00G\x03" + "04,00o\x03" + "08,00o\x03" + "02,00g\x03" + "03,00l\x03" + "04,00e\x03\x02" ) if tosend != "": __main__.sendMessage( tosend, channel ) titleFound = True except: continue return titleFound return False except: return False
def handle( packet ): try: if packet['rest'][0] != "#": # just parsing PM messages here message = packet['rest'].split( " :", maxsplit=1 )[1].strip() if message[0] != "\x01" and message[-1] != "\x01": # CTCPs tend to use this, derp return False user = strbetween( packet['host'], ":", "!" ) if __main__.getAccessLevel( user ) < 0: return False # Get out of here banned loser! message = message[1:-1] # Just chop off the \x01s now toSend = "" if message == "VERSION": toSend = "NOTICE " + user + " :\x01VERSION PyBot " + __main__.pyBotVersion + ".\x01" elif message == "TIME": toSend = "NOTICE " + user + " :\x01TIME " + time.strftime( "%a %b %d %X" ) + "\x01" elif message.startswith( "PING " ): toSend = "NOTICE " + user + " :\x01" + message + "\x01" if toSend != "": __main__.sendPacket( __main__.makePacket( toSend ) ) return True return False except: return False