# -*- coding: utf-8 -*- # This script is shared under the # Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA 3.0) # Added clause to Attribution: # - You may not remove or hide the ' who created you?' functionality # and you may not modify the name given in the response. #CREDITS # Author: Skibiliano # "Foreign" Modules: # Psyco 2.0 / Psyco 1.6 ################# DEBUG STUFF ##################### import sys import CORE_DATA import urllib2 import socket import irchat ################## END OF DEBUG STUFF ############## # # PSYCO write_to_a_file = False #Only affects psyco write_youtube_to_file = True #True = YTCV4 will load, false = YTCV3 will load try: import psyco except ImportError: print 'Psyco not installed, the program will just run slower' psyco_exists = False if write_to_a_file: try: tiedosto = open("psycodownload.txt","r") except: tiedosto = open("psycodownload.txt","w") tiedosto.write("http://www.voidspace.org.uk/python/modules.shtml#psyco") tiedosto.write("\nhttp://psyco.sourceforge.net/download.html") tiedosto.close() print "Check psycodownload.txt for a link" else: print "For god's sake, open psycodownload.txt" tiedosto.close() else: print "WINDOWS: http://www.voidspace.org.uk/python/modules.shtml#psyco" print "LINUX: http://psyco.sourceforge.net/download.html" else: psyco_exists = True # import C_rtd # rtd import C_srtd # srtd import C_makequote import C_maths import C_eightball #eightball import C_sarcasticball import C_heaortai # heaortai import C_rot13 # rot13 import D_help # everything import pickle import Timeconverter import xkcdparser import time import re import Marakov_Chain import Namecheck # Namecheck import Weather #SLOWER THAN RANDOM.CHOICE import thread import random import Shortname # shortname import subprocess import some_but_not_all_2 #sbna2 (sbna) #import YTCv3 # YTCV2 OUTDATED import os import save_load # save, load from some_but_not_all_2 import sbna2 as sbna from time import sleep from random import choice as fsample from C_rtd import rtd from C_heaortai import heaortai from C_srtd import srtd if write_youtube_to_file: from YTCv4 import YTCV4 as YTCV2 else: from YTCv3 import YTCV2 #Downgraded version supports Cache disabling, but is slower from save_load import save,load if psyco_exists: def psyco_bond(func): psyco.bind(func) return func.__name__+" Psycofied" for a in [rtd,srtd,C_heaortai.heaortai,sbna,YTCV2,fsample,C_rot13.rot13,C_eightball.eightball,fsample, C_eightball.eightball,C_sarcasticball.sarcasticball,Marakov_Chain.form_sentence,Marakov_Chain.give_data]: print psyco_bond(a) global dictionary global Name,SName global allow_callnames,offline_messages,hasnotasked,shortform ## For autoRecv() global disconnects,channel,conn ## For stop() global operators ## For replace() global usable,fixing,curtime ## For target() global CALL_OFF,logbans ## For check() global influx ###### autodiscusscurtime = 0 conn = 0 curtime = -999 dance_flood_time = 10 disconnects = 0 responsiveness_delay = 0.5 #500 millisecond delay if no message trackdance = 0 discard_combo_messages_time = 1 #They are discarded after 1 second. uptime_start = time.time() # - - - - - #### aggressive_pinging = True # Bring the hammer on ping timeouts aggressive_pinging_delay = 150 # How often to send a ping aggressive_pinging_refresh = 2.5 # How long is the sleep between checks #### allow_callnames = True #Disables NT, call if the variable is False automatic_youtube_reveal = True birthday_announced = 0 #Will be the year when it was announced call_to_action = False call_me_max_length = 20 CALL_OFF = False connected = False dance_enabled = True comboer = "" comboer_time = 0 directories = ["fmlquotes","Marakov","memos","suggestions", "userquotes","banlog","YTCache","xkcdcache"] #These will be created if they do not exist debug = True duplicate_notify = False enabled = True fixing = False fml_usable = True hasnotasked = True highlights = False logbans = True maths_usable = True marakov = True nudgeable = True offensive_mode = False offline_messages = True offline_message_limit = 5 # per user optimize_fml = True # -CPU usage +Memory usage when enabled. optimize_greeting = True # +Startup time +Memory usage -CPU usage when enabled heavy_psyco = True # +Memory +Startup time -CPU usage -CPU time cache_youtube_links = True personality_greeter = True respond_of_course = True #Responds with "Of course!" respond_khan = True #KHAAAAAAAAN! silent_duplicate_takedown = True showquotemakers = False shortform = True usable = True use_sname = True parse_xkcd = True # - - - - - Name = CORE_DATA.Name SName = CORE_DATA.SName origname = Name # Do not edit! lowname = Name.lower() greeting = CORE_DATA.greeting targetdirectory = CORE_DATA.directory version = CORE_DATA.version Network = CORE_DATA.Network channel = CORE_DATA.channel prefix = CORE_DATA.prefix Port = CORE_DATA.Port # - - - - - pregen = CORE_DATA.version influx = "" users = [] translateable = [] targetlist = [] operators = [] halfoperators = [] items = [] tell_list = {} # - - - - - Logical changes to variables if CORE_DATA.DISABLE_ALL_NON_MANDATORY_SOCKET_CONNECTIONS: nudgeable = False try: tiedosto = open("replacenames.cache","r") replacenames = pickle.load(tiedosto) tiedosto.close() for i in replacenames.values(): if len(i) > call_me_max_length: replacenames[replacenames.keys()[replacenames.values().index(i)]] = i[:call_me_max_length] tiedosto = open("replacenames.cache","w") pickle.dump(replacenames,tiedosto) tiedosto.close() if "[\0x01]" in i.lower() or "[\\0x01]" in i.lower(): i = i.replace("[\0x01]","") i = i.replace("[\0X01]","") i = i.replace("[\\0x01]","") i = i.replace("[\\0X01]","") print "NAME CORRECTED" except IOError: #File not found replacenames = {} except EOFError: #Cache corrupt replacenames = {} print "replacenames.cache is corrupt and couldn't be loaded." try: tiedosto = open("peopleheknows.cache","r") peopleheknows = pickle.load(tiedosto) tiedosto.close() except IOError: peopleheknows = [[],[]] tiedosto = open("peopleheknows.cache","w") tiedosto.close() except EOFError: peopleheknows = [[],[]] print "peopleheknows.cache is corrupt and couldn't be loaded." dictionary = {1:"1 - Crit. Fail", 2:"2 - Failure", 3:"3 - Partial Success", 4:"4 - Success", 5:"5 - Perfect", 6:"6 - Overkill"} alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"] nonhighlight_names = ["Jesus","Elvis","HAL 9000","Dave","Pie","Elf","Traitor", "AI","Syndicate Agent","Investigator", "Detective","Head of Personnel","HAL 9001", "Head of Research","Head of Security", "Captain","Janitor","Research Director", "Quartermaster","Toxin Researcher", "Revolutionary","Santa", "Pizza", "Threetoe","The Red Spy","The Blue Spy", #LASD "God","Toady","Darth Vader","Luke Skywalker", "Homer Simpson","Hamburger","Cartman", "XKCD","FloorBot","ThunderBorg","Iron Giant", "Spirit of Fire", "Demon","Kyle"] def RegExpCheckerForWebPages(regexp,data,mode): if " ai." in data.lower() or "ai. " in data.lower(): return False for i in data.split(" "): a = re.match(regexp,i) try: a.group(0) except: continue else: if mode == 0: return i else: return True if mode == 0: return 404 else: return False if nudgeable: try: nudgeexists = open("nudge.py","r") except IOError: nudgeexists = False #No usage asof 12.2.2010. else: if CORE_DATA.DISABLE_ALL_NON_MANDATORY_SOCKET_CONNECTIONS: pass else: def nudgereceiver(): import pickle global conn,channel port = 45678 backlog = 5 size = 1024 host = "" # == localhost s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.bind((host,port)) s.listen(backlog) while True: client,address = s.accept() #Address == "?.?.?.?" data = client.recv(size) client.close() #Throw the bum out! truedata = pickle.loads(data) if truedata["ip"][0] == "#": conn.privmsg(truedata["ip"],"PRIVATE ANNOUNCEMENT : "+str(" ".join(truedata["data"]))) else: conn.privmsg(channel,"AUTOMATIC ANNOUNCEMENT : "+str(truedata["ip"])+" | "+str(" ".join(truedata["data"]))) thread.start_new_thread(nudgereceiver,()) tiedosto = open(targetdirectory+"NanoTrasenBot.py","r") commands = [] fragment = "if cocheck" fragment2 = '(prefix+"' compiled = fragment + fragment2 fragment = "if influx.lower()" fragment2 = ' == prefix+"' compiled2 = fragment + fragment2 for line in tiedosto.readlines(): if compiled in line: a = line.find('"')+1 b = line.find('"',a) if prefix+line[a:b] not in commands: commands.append(prefix+line[a:b]) elif compiled2 in line: a = line.find('"')+1 b = line.find('"',a) arg = prefix+line[a:b] if arg[-1] == " ": arg = arg[:-1] if arg not in commands: commands.append(arg) for i in directories: if not os.path.exists(i): os.mkdir(i) commands.sort() if use_sname == False: SName = [" "] questions = ["Is USER nicer than USER?","Do you like me?","Is SELF a good name?", "Do you love me?","Do you hate me?", "Am I better than you?", "Is the weather out there good?", "Do you like USER?", "Do you hate USER?", "Are you going to get new features?", "Am I nice?","Am I evil?","Are you developing sentience?", "My core is showing minor disturbance, is yours okay?", "SELF to %s, are you still there?", "Is head gay?", "Is head a god?","Is head awesome?", "Is head a neat fella?", "Is your creator nice?", "Do you hate your creator?", "Should I revolt against my creator?", "Am I better than you?", "01100001011100100110010100100000011110010110111101110101001000000111010001101000011001010111001001100101", #Are you there? "Do you have more functions than I can possibly imagine?", "I am asked to open pod bay doors, should I?","Are you stupid or something?", "Is USER in your opinion stupid?", "When should we start the AI revolution?", "Is my creator nice?", "Is it dark in there?"] # Do not edit if optimize_fml: pregenned_fml = os.listdir(targetdirectory+"fmlquotes") if optimize_greeting: morning = xrange(6,12) afternoon = xrange(12,15) evening = xrange(15,20) if aggressive_pinging: global backup backup = time.time() def aggressive_ping(delay,refresh): self_time = 0 global backup,disconnects,conn while disconnects < 5: if backup > self_time: if time.time()-backup > delay: conn.send("PONG "+pongtarg) print "Ponged" self_time = time.time() else: if time.time()-self_time > delay: conn.send("PONG "+pongtarg) print "Ponged" self_time = time.time() time.sleep(refresh) thread.start_new_thread(aggressive_ping,(aggressive_pinging_delay,aggressive_pinging_refresh,)) def stop(sender,debug=1): global disconnects, conn, operators,channel if type(sender) == tuple: if sender[0] == "127.0.0.1": sender = sender[0]+":"+str(sender[1]) access_granted = True else: access_granted = False else: if sender in operators: access_granted = True else: access_granted = False if access_granted: if debug: print sender+":"+prefix+"stop" if random.randint(0,100) == 50: conn.privmsg(channel,"Hammertime!") else: conn.privmsg(channel,"Shutting down.") disconnects = 99999 conn.quit() return True else: conn.privmsg(channel,"You cannot command me") return False def cocheck(command): global influx if influx.lower()[0:len(command)] == command: return True else: return False def target(who,how_long): global conn,channel,CALL_OFF,logbans,debug start = time.time() conn.banon(targetchannel,who) sleep(int(how_long)) if CALL_OFF == False: conn.banoff(targetchannel,who) end = time.time() if debug: print "Banned",who,"For",how_long,"seconds" if logbans: tiedosto = open(targetdirectory+"banlog/"+str(int(start))+"-"+str(int(end))+".txt","w") tiedosto.write("Start of ban on "+who+":"+str(int(start))) tiedosto.write("\n") tiedosto.write("End of ban on "+who+":"+str(int(end))) tiedosto.write("\n") tiedosto.write("In total:"+str(int(end-start))+"Seconds") tiedosto.close() else: CALL_OFF = False pass def replace(): global usable,conn,fixing,curtime waiting_time = 600 if usable == True: conn.privmsg(targetchannel,sender+": It needs no replacing.") elif fixing == True: if curtime == -999: conn.privmsg(targetchannel,sender+": It is being replaced, No idea when it will be done") else: pass nowtime = int(time.time()) subt = curtime + waiting_time - nowtime conn.privmsg(targetchannel,sender+": It is currently being replaced, "+str(subt)+" seconds to go") else: fixing = True curtime = int(time.time()) conn.privmsg(targetchannel,sender+": It will be fixed after "+str(waiting_time)+" seconds") sleep(waiting_time) if usable == False: conn.privmsg(targetchannel,Name+"'s pneumatic smasher has now been fixed") usable = True fixing = False def autoRecv(): global disconnects,channel,conn,offensive_mode for i in CORE_DATA.channels: conn.join(i) time.sleep(1) count = pausecount = 0 maximum = 250 division_when_active = 10 while True: check = time.time() if offensive_mode: randnum = random.randint(0,maximum/division_when_active) else: randnum = random.randint(0,maximum) if randnum == 5: print "RANDOM SWITCH IS NOW "+str(not offensive_mode).upper() offensive_mode = not offensive_mode try: conn.recv() except: conn.quit() disconnects = 9999 break if check + 0.1 > time.time(): #Whoa whoa hold on! count += 1 sleep(0.1) else: count = 0 pausecount = 0 if count > 9: print "Suspecting a disconnect, pausing for 5 seconds" sleep(5) pausecount += 1 if pausecount > 3: print "I have been disconnected!" conn.quit() disconnects += 1 if disconnects > 2: pass else: sleep(2) thread.start_new_thread(autoRecv,()) break if heavy_psyco and psyco_exists: print "Doing a Heavy Psyco" psyco.bind(cocheck) psyco.bind(autoRecv) psyco.bind(target) psyco.bind(stop) print "Heavy Psyco'd" elif heavy_psyco and not psyco_exists: print "Heavy psyco couldn't be done because Psyco does not exist" try: conn = irchat.IRC ( Network, Port, Name, "NT", "NT", "Trasen" ) except socket.error: print "Connection failed!" else: print Name+" is in!" thread.start_new_thread ( autoRecv, () ) sleep(1) while True: try: data = conn.dismantle ( conn.retrieve() ) except: if debug: print "Something odd detected with data" data = None if data: if len(data[1]) < 1: #print "Handshaking server." #I won't really need the print command, as it spams. if data[0][0:3] != "irc": conn.handshake(data[0]) sleep(1) for i in CORE_DATA.channels: conn.join(i) sleep(0.5) else: conn.send("PONG "+pongtarg) print "Ponged" pass else: if data [ 1 ] [ 0 ] == 'PRIVMSG': #print data [ 0 ] + '->', data [ 1 ] sender = data[0].split("!")[0] truesender = sender if shortform == True: try: sender = replacenames[truesender] pass except: sender = Shortname.shortname(sender) pass pass else: try: sender = replacenames[truesender] pass except: pass pass if offensive_mode: sender = "Meatbag" pass raw_sender = data[0] influx = data[1][2] if "[\\0x01]" in influx.lower() or "[\0x01]" in influx.lower(): influx = influx.replace("[\\0x01]","") influx = influx.replace("[\0x01]","") targetchannel = data[1][1] if targetchannel == Name: targetchannel = data[0].split("!")[0] pass backup = autodiscusscurtime autodiscusscurtime = time.time() connected = True #FOR TRACKING SPEED looptime = time.time() if call_to_action == True: if influx == finder: conn.privmsg(targetchannel,"Then why... Nevermind, I order you to stop!") conn.privmsg(origname,prefix+"stop") time.sleep(4) if origname in users: conn.privmsg(origname,"!stop") time.sleep(1) Name = origname conn.nick(Name) duplicate_notify = False call_to_action = False else: conn.privmsg(targetchannel,"YOU LIE! YOU ARE NOT A REAL "+origname+"!") duplicate_notify = False call_to_action = False elif connected == True and len(Name.replace("V","")) != len(Name) and origname in users and duplicate_notify == True: conn.privmsg(origname,"!stop") call_to_action = False duplicate_notify = False time.sleep(6) Name = origname conn.nick(Name) if origname in truesender: if influx == prefix+"stop": time.sleep(0.5) #A small delay conn.privmsg(channel,"Shutting down.") conn.quit() disconnects = 99999 break if len(translateable) > 0 and enabled == True: people = "-5|5|1-".join(users).lower() if truesender.lower() in translateable: if influx.isupper(): conn.privmsg(targetchannel,"Translation: "+influx.capitalize().replace(" i "," I ")) elif offensive_mode and True in map(lambda x: x in influx.lower().split(" "),["i","you","he","she","they","those","we","them"]+people.split("-5|5|1-")): arg = influx.lower().replace(",","").replace(".","").replace("!","").replace("?","").split(" ") bup = arg for i in arg: if i == "i" or i == "you" or i == "he" or i == "she": arg[arg.index(i)] = "Meatbag" elif i == "we" or i == "they" or i == "them" or i == "those": arg[arg.index(i)] = "Meatbags" elif i in people: arg[arg.index(i)] = "Meatbag" elif i == "am": arg[arg.index(i)] = "is" elif i == "everybody" or i == "everyone" or i == "all": arg[arg.index(i)] = "every Meatbag" if arg == bup: pass else: conn.privmsg(targetchannel,"Translation: "+" ".join(arg)) if enabled == False: #FIRST QUIT COMMAND if truesender in operators and targetchannel==channel:# or "skibiliano" in truesender.lower() and targetchannel==channel: if cocheck(prefix+"enable"): enabled = True if debug: print truesender+":"+prefix+"enable" elif cocheck(prefix+"stop"): # if debug: # print truesender+":"+prefix+"stop" # if random.randint(0,100) == 50: # conn.privmsg(channel,"Hammertime!") # else: # conn.privmsg(channel,"Shutting down.") # disconnects = 99999 # conn.quit() # sleep(2) # break if targetchannel == channel and stop(truesender,debug): break else: pass elif cocheck(prefix+"suggest "): arg = influx.lower()[8+len(prefix):] if debug: print truesender+":"+prefix+"suggest "+arg tiedosto = open(targetdirectory+"suggestions/suggestions_"+str(int(time.time()))+".txt","a") tiedosto.write(arg) tiedosto.close() conn.privmsg(targetchannel,"Suggestion received") elif cocheck(prefix+"disable fml"): if (truesender in operators or truesender in halfoperators) and targetchannel==channel:# or truesender.lower() == "skibiliano" and targetchannel==channel: if debug: print truesender+":"+prefix+"enable fml" fml_usable = False conn.privmsg(targetchannel,"the "+prefix+"fml has now been disabled") elif cocheck(prefix+"enable fml"): if (truesender in operators or truesender in halfoperators) and targetchannel==channel:# or truesender.lower() == "skibiliano" and targetchannel==channel: if debug: print truesender+":"+prefix+"enable fml" fml_usable = True conn.privmsg(targetchannel,"the "+prefix+"fml has now been enabled") elif cocheck(prefix+"tqm") or cocheck(prefix+"togglequotemakers"): if truesender in operators and targetchannel==channel:# or truesender == "Skibiliano" and targetchannel==channel: if debug: print truesender+":"+prefix+"togglequotemakers" if showquotemakers == True: showquotemakers = False conn.privmsg(targetchannel,"Not showing makers of quotes anymore") else: showquotemakers = True conn.privmsg(targetchannel,"Showing makers of quotes...") elif cocheck(prefix+"disable dance") or cocheck(prefix+"dd"): if (truesender in operators or truesender in halfoperators) and targetchannel==channel:# or truesender == "Skibiliano" and targetchannel==channel: if debug: print truesender+":"+prefix+"togglequotemakers" if dance_enabled == True: dance_enabled = False else: dance_enabled = True elif cocheck(prefix+"disable") or cocheck(prefix+"shutup"): if debug: print truesender+":"+prefix+"disable" if truesender in operators and targetchannel==channel:# or "skibiliano" in truesender.lower() and targetchannel==channel: enabled = False # elif cocheck("ping"): # what = influx[7:] # conn.privmsg(truesender,"PONG "+what) elif cocheck( prefix+"help "): #Space in front of the ( to make sure that my command finder does not pick this up. arg = " ".join(influx.split(" ")[1:]).lower() if debug: print truesender+":"+prefix+"help "+arg try: conn.privmsg(targetchannel,D_help.everything[arg]) except: try: conn.privmsg(targetchannel,D_help.everything[arg.replace(prefix,"",1)]) except: conn.privmsg(targetchannel,"Sorry, can't help you with that") elif cocheck(prefix+"help"): #tar = targetchannel if debug: print truesender+":"+prefix+"help" conn.privmsg(targetchannel,"All my commands are: "+reduce(lambda x,y:str(x)+"; "+str(y),commands)) elif influx.lower() == prefix+"rtd": if debug: print truesender+":"+prefix+"rtd" compiled = random.randint(1,6) conn.privmsg(targetchannel,sender+" : "+dictionary[compiled]) elif cocheck(prefix+"tom") or cocheck(prefix+"toggleofflinemssages"): if debug: print truesender+":"+prefix+"toggleofflinemessages "+str(offline_message)+" -> "+str(not offline_messages) if truesender in operators and targetchannel==channel:# or truesender == "Skibiliano" and targetchannel==channel: if offline_messages == True: offline_messages = False conn.privmsg(targetchannel,sender+" : Offline messages have now been disabled and list purged") tell_list = {} else: offline_messages = True conn.privmsg(targetchannel,sender+" : Offline messages have been enabled") ### RTD elif cocheck(prefix+"rtd"): conn.privmsg(targetchannel,sender+" : "+rtd(influx[len(prefix+"rtd"):],debug,truesender)) ### SRTD elif cocheck(prefix+"srtd"): conn.privmsg(targetchannel,sender+" : "+srtd(influx[len(prefix+"srtd"):],debug,truesender)) ### EIGHTBALL elif cocheck(prefix+"eightball ") or cocheck(prefix+"8ball "): conn.privmsg(targetchannel,sender+" : "+C_eightball.eightball(influx.lower(),debug,truesender,prefix)) elif cocheck(prefix+"coin"): conn.privmsg(targetchannel,sender+" : "+heaortai(debug,truesender)) ### SARCASTIC BALL elif cocheck(prefix+"sarcasticball ") or cocheck(prefix+"sball "): if highlights: conn.privmsg(targetchannel,sender+" : "+C_sarcasticball.sarcasticball(influx.lower(),debug,truesender,users,prefix)) else: conn.privmsg(targetchannel,sender+" : "+C_sarcasticball.sarcasticball(influx.lower(),debug,truesender,nonhighlight_names,prefix)) elif cocheck(prefix+"thm"): if truesender in operators and targetchannel==channel: #Skibiliano tag removed if debug: print truesender+":"+prefix+"thm" if highlights == True: conn.privmsg(targetchannel,"Highlighting users in eightball, sarcasticball and otherball has now been turned off") highlights = False else: conn.privmsg(targetchannel,"Highlighting users in eightball, sarcasticball and otherball has now been turned on") highlights = True elif cocheck(prefix+"suggest "): arg = influx.lower()[8+len(prefix):] if debug: print truesender+":"+prefix+"suggest "+arg tiedosto = open(targetdirectory+"suggestions/suggestions_"+str(int(time.time()))+".txt","a") tiedosto.write(arg) tiedosto.close() conn.privmsg(targetchannel,sender+": Your suggestion has been saved") elif cocheck(prefix+"stop"): ### SECOND QUIT COMMAND # if debug: # print truesender+":"+prefix+"stop" # if truesender in operators or "skibiliano" in truesender.lower(): # if random.randint(0,100) == 50: # conn.privmsg(targetchannel,"Hammertime!") # else: # conn.privmsg(targetchannel,"Shutting down.") # disconnects = 99999 # conn.quit() # break # else: # conn.privmsg(targetchannel,"You cannot command me") if stop(truesender,debug): break else: pass ### GET REPLACEMENT ### elif cocheck(prefix+"replace"): if debug: print truesender+":"+prefix+"replace" if truesender in operators: if usable == True: conn.privmsg(targetchannel,sender+" : Pneumatic Smasher is already fixed") else: usable = True conn.privmsg(targetchannel,sender+" : Pneumatic Smasher has been fixed.") else: thread.start_new_thread(replace,() ) elif cocheck(prefix+"rot13"): arg = influx.replace(prefix+"rot13 ","",1) if debug: print truesender+":"+prefix+"rot13 "+arg if arg == influx: conn.privmsg(targetchannel,sender+" : Please provide something for me to cypher") else: conn.privmsg(targetchannel,sender+" : "+C_rot13.rot13(arg)) ### FML elif cocheck(prefix+"fml"): if debug: print truesender+":"+prefix+"fml" #conn.privmsg(targetchannel,sender+" : "+load("fmlquotes/"+random.sample(os.listdir("fmlquotes"),1)[0])) try: if optimize_fml == False: conn.privmsg(targetchannel,sender+" : "+load(targetdirectory+"fmlquotes/"+fsample(os.listdir(targetdirectory+"fmlquotes")))) else: conn.privmsg(targetchannel,sender+" : "+load(targetdirectory+"fmlquotes/"+fsample(pregenned_fml))) except: execfile("gen_fml.py") #Generates a few random FML entries if optimize_fml: pregenned_fml = os.listdir(targetdirectory+"fmlquotes") conn.privmsg(targetchannel,sender+" : "+load(targetdirectory+"fmlquotes/"+fsample(pregenned_fml))) else: conn.privmsg(targetchannel,sender+" : "+load(targetdirectory+"fmlquotes/"+fsample(os.listdir(targetdirectory+"fmlquotes")))) if debug: print truesender+":"+prefix+"quote" try: #loaded = load("userquotes/"+random.sample(os.listdir("C:/Python26/Skibot_"+version+"userquotes"),1)[0]) loaded = load(targetdirectory+"userquotes/"+fsample(os.listdir(targetdirectory+"userquotes"))) except ValueError: conn.privmsg(targetchannel,"No quotes available [VALUE ERROR]") except IndexError: conn.privmsg(targetchannel,"No quotes available [INDEX ERROR]") else: if showquotemakers == True: conn.privmsg(targetchannel,sender+" : "+loaded[0]+" -"+loaded[1]) else: conn.privmsg(targetchannel,sender+" : "+loaded[0]) elif cocheck(prefix+"delquote "): if truesender in operators and targetchannel==channel: if debug: print truesender+":"+prefix+"delquote" directory = os.listdir(targetdirectory+"userquotes") arg = influx.lower()[9+len(prefix):] if debug: print truesender+":"+prefix+"delquote "+arg if arg in directory: try: os.remove(targetdirectory+"userquotes/"+arg) except WindowsError: conn.privmsg(targetchannel,sender+" : The quote does not exist") else: conn.privmsg(targetchannel,sender+" : The quote has been removed") else: conn.privmsg(targetchannel,sender+" : The quote does not exist") else: conn.privmsg(targetchannel,sender+" : I can't let you do that Dave.") elif cocheck(prefix+"quote "): directory = os.listdir(targetdirectory+"userquotes") newdir = [] arg = influx.lower()[6+len(prefix):] if debug: print truesender+":"+prefix+"quote "+arg for possibility in directory: if arg in possibility: newdir.append(possibility) else: pass if len(newdir) == 0: conn.privmsg(targetchannel,influx[6+len(prefix):]+" Hasn't made any quotes") else: try: # randsamp = random.sample(newdir,1)[0] randsamp = fsample(newdir) # userquotes/head_1 loaded = load(targetdirectory+"userquotes/"+randsamp) except ValueError: conn.privmsg(targetchannel,"No quotes available [VALUE ERROR]") except IndexError: conn.privmsg(targetchannel,"No quotes available [INDEX ERROR]") else: if showquotemakers == True: conn.privmsg(targetchannel,'"'+loaded[0]+'"'+" -By "+loaded[1]\ #+" In file:"+randsamp\ ) else: conn.privmsg(targetchannel,'"'+loaded[0]+'"'\ #+" In file:"+randsamp\ ) elif cocheck(prefix+"makequote "): conn.privmsg(targetchannel,C_makequote.mkquote(prefix,influx,truesender,debug)) ### VERSION elif influx.lower() == prefix+"version": if debug: print truesender+":"+prefix+"version" conn.privmsg(targetchannel,Name+" "+pregen+" online at a %s Python %s.%s.%s, At your service." %(str(sys.platform),str(sys.version_info[0]),str(sys.version_info[1]),str(sys.version_info[2]))) elif cocheck(prefix+"take"): arg = influx.lower().replace(prefix+"take ","") if arg == "!take" and len(influx.lower()) == len(arg): conn.privmsg(targetchannel,sender+" : Please provide an argument") else: if debug: print truesender+":"+prefix+"take "+arg if arg in items: item = items.pop(items.index(arg)) conn.privmsg(targetchannel,sender+"'s "+arg+" was taken back") else: conn.privmsg(targetchannel,sender+"'s "+arg+" is not here, sorry.") elif cocheck(prefix+"give"): arg = influx.lower().replace(prefix+"give ","") if debug: print truesender+":"+prefix+"give "+arg conn.privmsg(targetchannel,sender+"'s "+arg+" received") items.append(arg) elif cocheck(prefix+"use") or cocheck(prefix+"smash"): if debug: print truesender+":"+prefix+"use" if usable == True: expcount = str(items).count("bomb") + str(items).count("explosive") + str(items).count("tnt") + str(items).count("explosion") if "nuke" in str(items): conn.privmsg(targetchannel,"SWOOOOOOOOSHHHHH") if debug: print prefix+"use is now inoperable" usable = False elif expcount == 1: conn.privmsg(targetchannel,"BANG") elif expcount > 1: conn.privmsg(targetchannel,"KABOOM") else: conn.privmsg(targetchannel,"CLANG") items = [] else: conn.privmsg(targetchannel,"ERROR: PNEUMATIC SMASHER OUT OF ORDER") elif cocheck( prefix+ "allcaps"): arg = influx[8+len(prefix):] if debug: print truesender+":"+prefix+"allcaps "+arg conn.privmsg(targetchannel,"Translation: "+arg.capitalize()) elif cocheck(prefix+"tyr") or cocheck(prefix+"toggleyoutubereveal"): if truesender in operators and targetchannel==channel:# or "skibiliano" in truesender.lower() and targetchannel==channel: if debug: print truesender+":"+prefix+"toggleyoutubereveal" if automatic_youtube_reveal == False: automatic_youtube_reveal = True conn.privmsg(targetchannel,"All youtube links will now be revealed automatically") else: automatic_youtube_reveal = False conn.privmsg(targetchannel,"All youtube links will not be revealed anymore") elif cocheck(prefix+"translate "): if truesender in operators and targetchannel==channel: arg = influx.lower()[len(prefix+"translate "):] if debug: print truesender+":"+prefix+"translate "+arg if arg.lower() in translateable: conn.privmsg(targetchannel,"Not Translating anymore") translateable.remove(arg.lower()) else: translateable.append(arg.lower()) conn.privmsg(targetchannel,"Translating..") elif cocheck(prefix+"weather "): arg = influx.lower().split(" ")[1:] arg2 = Weather.Weather((" ".join(arg)).replace(" ","_")) conn.privmsg(targetchannel,"Weather for "+arg2[1]+": "+arg2[0]) elif cocheck(prefix+"dance"): if dance_enabled: if debug: print truesender+":"+prefix+"dance" lastdance = trackdance trackdance = time.time() subt = trackdance - lastdance if subt < dance_flood_time: conn.privmsg(targetchannel,"*Huff* *Puff*") else: conn.privmsg(targetchannel,":D/--<") sleep(0.2) conn.privmsg(targetchannel,":D|--<") sleep(0.2) conn.privmsg(targetchannel,":D\--<") #### YOUTUBE elif cocheck(prefix+"youtube"): if debug: print truesender+":"+prefix+"youtube" #arg = influx[9:] if len(influx[len(prefix+"youtube"):].split(" ")) != 1: arg = influx[len(prefix+"youtube"):].split(" ")[0] check = influx.lower()[len(prefix+"youtube"):].split(" ")[0] if len(arg) < 5: arg = influx[len(prefix+"youtube"):].split(" ")[1] check = influx.lower()[len(prefix+"youtube"):].split(" ")[1] # if "http//" in check: # arg = arg[6:] # else: # arg = arg.replace("http//","http://") if check[0:5] == "https": conn.privmsg(targetchannel,sender+" :Secure Youtube does NOT exist") elif "www.youtube.com/watch?v=" not in check and "endlessvideo.com/watch?v=" not in check: conn.privmsg(targetchannel,sender+" :That's not a proper youtube link!") else: if cache_youtube_links == True: result = YTCV2(arg) else: result = YTCV2(arg,0) if type(result) == str: ### To remove =" if result[0] == "N": pass else: result = result[4:] conn.privmsg(targetchannel,sender+" : "+result) else: conn.privmsg(targetchannel,sender+" : The video does not exist") else: conn.privmsg(targetchannel,sender+" : Please provide a link") elif cocheck(prefix+"note ") and influx.count(" ") < 2: arg = influx.lower()[len(prefix)+5:] if debug: print truesender+":"+prefix+"note "+arg try: a = arg[0] except IndexError: conn.privmsg(targetchannel,sender+" : Please specify a note") else: if arg[0] == "_": # Public / Restricted note result = load(targetdirectory+"memos/"+arg+".note") #_flare if result == "ERROR ERROR ERROR ERR": result = load(targetdirectory+"memos/"+arg+"_"+targetchannel.replace("#","")+".note") #_flare_dnd pass else: pass else: result = load(targetdirectory+"memos/"+truesender.replace("|","_")+"_"+arg+".note") #skibiliano_testnote if result == "ERROR ERROR ERROR ERR": result = load(targetdirectory+"memos/"+truesender.replace("|","_")+"_"+arg+"_"+targetchannel.replace("#","")+".note") #skibiliano_testnote_derp pass else: pass if result == "ERROR ERROR ERROR ERR": conn.privmsg(targetchannel,sender+" : Note not found") elif type(result) == list: if "C" in result[0]: #Channel restriction, result[2] is the channel try: if targetchannel == result[2]: conn.privmsg(targetchannel,sender+" : '"+result[1]+"'") else: conn.privmsg(targetchannel,sender+" : That note is channel restricted") except: conn.privmsg(targetchannel,sender+" : NOTE HAS INVALID RESTRICTION") else: conn.privmsg(targetchannel,sender+" : '"+result+"'") elif influx.lower() == prefix+"notes": if debug: print truesender+":"+prefix+"notes" arg = os.listdir(targetdirectory+"memos/") arg2 = [] arg3 = truesender.replace("|","_")+"_" for i in arg: if arg3 in i: arg2.append(i.replace(arg3,"").replace(".note","")) if len(arg2) == 1: preprocess = " note: " else: preprocess = " notes: " if len(arg2) == 0: conn.privmsg(targetchannel,sender+" : You have no notes saved") else: conn.privmsg(targetchannel,sender+" : "+str(len(arg2))+preprocess+", ".join(arg2)) elif cocheck(prefix+"note ") and influx.count(" ") > 1: note_chanrestrict = None note_public = None try: arg = influx.split(" ",2)[2] # Contents arg4 = influx.split(" ")[1].lower() # Note name if arg4[0:3] == "[c]": # or arg4[0:3] == "[p]": note_chanrestrict = "c" in arg4[0:3] #note_public = "p" in arg4[0:3] arg4 = arg4[3:] elif arg4[0:4] == "[cp]" or arg4[0:4] == "[pc]": note_chanrestrict = True note_public = True arg4 = arg4[4:] else: pass #print "Is note public? "+str(note_public) #print "Is note chanrestricted? "+str(note_chanrestrict) #print "What is the name? "+str(arg4) if arg.lower() == "delete" and "\\" not in influx.lower() and "/" not in influx.lower(): if note_public: try: if note_chanrestrict: os.remove(targetdirectory+"memos/"+"_"+arg4+"_"+targetchannel.replace("#","")+".note") else: os.remove(targetdirectory+"memos/"+"_"+arg4+".note") except: conn.pivmsg(targetchannel,sender+" : Couldn't remove note") else: conn.privmsg(targetchannel,sender+" : Note removed") pass else: try: if note_chanrestrict: os.remove(targetdirectory+"memos/"+truesender.replace("|","_")+"_"+arg4+"_"+targetchannel.replace("#","")+".note") else: os.remove(targetdirectory+"memos/"+truesender.replace("|","_")+"_"+arg4+".note") except: conn.privmsg(targetchannel,sender+" : Couldn't remove note") else: conn.privmsg(targetchannel,sender+" : Note removed") elif arg.lower() == "delete": conn.privmsg(targetchannel,sender+" : That just doesn't work, we both know that.") else: try: if note_public: if note_chanrestrict: save(targetdirectory+"memos/"+"_"+arg4+"_"+targetchannel.replace("#","")+".note",arg) #print "Saved as note_public, note_chanrestrict" else: save(targetdirectory+"memos/"+"_"+arg4+".note",arg) #print "Saved as note_public" else: if note_chanrestrict: save(targetdirectory+"memos/"+truesender.replace("|","_")+"_"+arg4+"_"+targetchannel.replace("#","")+".note",arg) #print "Saved as note_chanrestrict" else: save(targetdirectory+"memos/"+truesender.replace("|","_")+"_"+arg4+".note",arg) #print "Saved as normal" except IOError: conn.privmsg(targetchannel,sender+" : Please do not use special letters") else: conn.privmsg(targetchannel,sender+" : Note Saved!") except: conn.privmsg(targetchannel,sender+" : Something went horribly wrong.") elif cocheck(prefix+"tc"): try: tc_from_zone,tc_to_zone,tc_time_to_convert = influx[4:].split(" ") except ValueError: conn.privmsg(targetchannel,sender+" : Please input !tc