diff --git a/baystation12.dme b/baystation12.dme index ebdf9775b3f..aede49368ad 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -1036,7 +1036,7 @@ #include "code\modules\examine\descriptions\structures.dm" #include "code\modules\examine\descriptions\turfs.dm" #include "code\modules\examine\descriptions\weapons.dm" -#include "code\modules\ext_scripts\irc.dm" +#include "code\modules\ext_scripts\discord.dm" #include "code\modules\ext_scripts\python.dm" #include "code\modules\flufftext\Dreaming.dm" #include "code\modules\flufftext\Hallucination.dm" diff --git a/bot/CORE_DATA.py b/bot/CORE_DATA.py deleted file mode 100644 index ca235888f15..00000000000 --- a/bot/CORE_DATA.py +++ /dev/null @@ -1,13 +0,0 @@ -Name = "CC_NanoTrasen" #The name he uses to connect -no_absolute_paths = True -debug_on = False -SName = ["cc","nt","trasen","nano","nanotrasen"] #Other names he will respond to, in lowercase -DISABLE_ALL_NON_MANDATORY_SOCKET_CONNECTIONS = False -directory = "bot/directory/here/" # Directory the bot is located in, make sure to keep the "/" at the end -version = "TG CC-BY-SA 6" -Network = 'YOUR.SERVER.HERE' #e.g. "irc.rizon.net" -channel = "#YOUR CHANNEL HERE" #what channel you want the bot in -channels = ["#YOUR CHANNEL HERE"] #same as above -greeting = "Welcome!" #what he says when a person he hasn't seen before joins -prefix = "!" #prefix for bot commands -Port = 7000 diff --git a/bot/C_eightball.py b/bot/C_eightball.py deleted file mode 100644 index 2ed73dafd57..00000000000 --- a/bot/C_eightball.py +++ /dev/null @@ -1,32 +0,0 @@ -from random import choice as fsample #Yay for added speed! -global responses -responses = ['Yes','Too bad','Will you turn me off if I tell you?','Absolutely', - "Not at all", "Nope", "It does", "No", "All the time", - "I don't really know", "Could be","Possibly","You're still here?",# Chaoticag - "No idea", "Of course", "Would you turn me off if I tell you?", - "Sweet!","Nah","Certainly","Yeah","Yup","I am quite confident that the answer is Yes", - "Perhaps", "Yeeeeaah... No.", "Indubitably" ] # Richard -def eightball(data,debug,sender,prefix): - global responses - arg = data.lower().replace(prefix+"eightball ","") - arg = arg.replace(prefix+"8ball ","") - if debug: - print sender+":"+prefix+"eightball", arg - if "answer" in arg and "everything" in arg and "to" in arg: - if debug: - print "Responded with",42 - return "42" - elif arg == "derp": - if debug: - print "Responded with herp" - return("herp") - elif arg == "herp": - if debug: - print "Responded with derp" - return("derp") - else: - #choice = sample(responses,1)[0] - choice = fsample(responses) - if debug: - print "Responded with", choice - return(choice) diff --git a/bot/C_heaortai.py b/bot/C_heaortai.py deleted file mode 100644 index 6e8b304e73b..00000000000 --- a/bot/C_heaortai.py +++ /dev/null @@ -1,5 +0,0 @@ -#Throws a coin, simple. -from random import random -def heaortai(debug,sender): return("Heads" if random() > 0.5 else "Tails") -# Takes 1/6th the time of doing it with random.randint(0,1) -# This file used to be a lot bigger, now it's kind of useless. diff --git a/bot/C_makequote.py b/bot/C_makequote.py deleted file mode 100644 index f79b863449a..00000000000 --- a/bot/C_makequote.py +++ /dev/null @@ -1,21 +0,0 @@ -from save_load import save -from os import listdir -import CORE_DATA -directory = CORE_DATA.directory -def mkquote(prefix,influx,sender,debug): - arg = influx[10+len(prefix):] - if debug: - print sender+":"+prefix+"makequote "+str(len(arg))+" Characters" - if len(arg) == 0: - return("Type something to a quote") - else: - files = listdir(directory+"userquotes") - numb = 0 - while True: - numb += 1 - if sender.lower()+str(numb) in files: - pass - else: - save(directory+"userquotes/"+sender.lower()+str(numb),[arg,sender.lower()]) - return("Saved as:"+sender.lower()+str(numb)) - break diff --git a/bot/C_maths.py b/bot/C_maths.py deleted file mode 100644 index 86013b74a7b..00000000000 --- a/bot/C_maths.py +++ /dev/null @@ -1,70 +0,0 @@ -### EXPERIMENTAL PROTOTYPE ### -# e = 2.7182818284590452353602874713526624977572 -# pi = math.pi -from __future__ import division #PYTHON Y U NO TELL ME THIS BEFORE -import math -import random -import re -e = "2.7182818284590452353602874713526624977572" -pi = str(math.pi) -global pre -pre = len("maths ") -def maths(influx,prefix="!",sender="NaN",debug=True,method="n"): - global pre - influx = influx.lower() - influx = influx[len(prefix)+pre:] - influx = influx.replace("pie",pi+"*"+e) - influx = influx.replace("e*",e+"*") - influx = influx.replace("*e","*"+e) - influx = influx.replace("pi",pi) - if debug: - print sender+":"+prefix+"maths" - if influx.count("**") == 0 and influx.count('"') == 0 and influx.count("'") == 0 and influx.count(";") == 0 and influx.count(":") == 0: - influx_low = influx.lower() - influx_hi = influx.upper() - if "0b" in influx_low: - influx_low = re.sub("0b[0-1]*","",influx_low) - influx_hi = re.sub("0B[0-1]*","",influx_hi) - if "0x" in influx_low: - influx_low = re.sub("0x[a-f0-9]*","",influx_low) - influx_hi = re.sub("0X[A-F0-9]*","",influx_hi) - if "rand" in influx_low: - influx_low = re.sub("rand","",influx_low) - influx_hi = re.sub("RAND","",influx_hi) - if influx_low == influx_hi: - influx = re.sub("rand","random.random()",influx) - try: - result = eval(influx.lower()) - except ZeroDivisionError: - return "Divide by zero detected." - except SyntaxError: - return "Syntax Error detected." - except TypeError: - return "Type Error detected." - except: - return "Unknown Error detected." - else: - if method == "n": #Normal - return result - elif method == "i": #Forced Int - return int(result) - elif method == "h": #Hex - try: - if "L" in hex(result)[2:]: - return hex(result)[2:-1] - else: - return hex(result)[2:].upper() - except TypeError: - return "That value (%s) cannot be interpreted properly using !hmaths" %(str(result)) - elif method == "b": #Binary - try: - return bin(result)[2:].upper() - except TypeError: - return "That value (%s) cannot be interpreted properly using !bmaths" %(str(result)) - else: - return result - else: - return "What are you trying to make me do again?" - else: - return "Those are likely to make me hang" - diff --git a/bot/C_rot13.py b/bot/C_rot13.py deleted file mode 100644 index 62b72dc2ad2..00000000000 --- a/bot/C_rot13.py +++ /dev/null @@ -1,23 +0,0 @@ -global parta,partb -parta = {"A":"N","B":"O","C":"P","D":"Q","E":"R","F":"S","G":"T","H":"U","I":"V","J":"W","K":"X","L":"Y","M":"Z"} -partb = {'O':'B','N':'A','Q':'D','P':'C','S':'F','R':'E','U':'H','T':'G','W':'J','V':'I','Y':'L','X':'K','Z':'M'} -def rot13(text): - global parta,partb - newtext = "" - for letter in text: - try: - if letter.isupper(): - newtext += parta[letter] - else: - newtext += parta[letter.upper()].lower() - except: - try: - if letter.isupper(): - newtext += partb[letter] - pass - else: - newtext += partb[letter.upper()].lower() - pass - except: - newtext += letter - return newtext diff --git a/bot/C_rtd.py b/bot/C_rtd.py deleted file mode 100644 index 96736fec21c..00000000000 --- a/bot/C_rtd.py +++ /dev/null @@ -1,96 +0,0 @@ -import random -def rtd(data,debug,sender): - backo = data - try: - arg1,arg2 = backo.split("d") - except ValueError, err: - return("Too many or too small amount of arguments") - else: - if debug: - print sender+":!rtd "+arg1+"d"+arg2 #faster than using %s's - die,die2 = [],[] - current_mark = "" - outcome = 0 - realnumberfound = False - checks = [] - count = 0 - arg1 = arg1.replace(" ","") - arg2 = arg2.replace(" ","") - try: - i_arg1 = int(arg1) - a_arg1 = abs(i_arg1) - if "+" in arg2 or "-" in arg2: - plus_spot = arg2.find("+") - minus_spot = arg2.find("-") - if plus_spot == -1 and minus_spot == -1: - nicer_form = "" - elif plus_spot != -1 and minus_spot == -1: - nicer_form = arg2[plus_spot:] - elif plus_spot == -1 and minus_spot != -1: - nicer_form = arg2[minus_spot:] - else: - if plus_spot < minus_spot: - nicer_form = arg2[plus_spot:] - else: - nicer_form = arg2[minus_spot:] - for letter in arg2: - if letter == "+" or letter == "-": - current_mark = letter - checks = [] - count += 1 - continue - checks.append(letter) - try: - next_up = arg2[count+1] - except: - if realnumberfound == False: - i_arg2 = int("".join(checks)) - checks = [] - realnumberfound = True - elif current_mark == "+": - outcome += int("".join(checks)) - else: - outcome -= int("".join(checks)) - else: - if next_up == "+" or next_up == "-": - if realnumberfound == False: - i_arg2 = int("".join(checks)) - checks = [] - realnumberfound = True - else: - if current_mark == "+": - outcome += int("".join(checks)) - else: - outcome -= int("".join(checks)) - checks = [] - count += 1 - else: - i_arg2 = int(arg2) - if a_arg1 == 0 or abs(i_arg2) == 0: - raise RuntimeError - except ValueError: - return("You lied! That's not a number!") - except RuntimeError: - return("Too many zeroes!") - else: - if a_arg1 > 100: - return("Too many rolls, I can only do one hundred at max.") - else: - for i in xrange(0,a_arg1): - if i_arg2 < 0: - dice = random.randint(i_arg2,0) - else: - dice = random.randint(1,i_arg2) - die.append(dice) - die2.append(str(dice)) - if i_arg2 < 0: - flist = "".join(die2) - else: - flist = "+".join(die2) - if len(flist) > 350: - return(str(reduce(lambda x,y: x+y, die)+outcome)) - else: - if current_mark == "": - return(flist+" = "+str(reduce(lambda x,y: x+y, die)+outcome)) - else: - return(flist+" ("+nicer_form+") = "+str(reduce(lambda x,y: x+y, die)+outcome)) diff --git a/bot/C_sarcasticball.py b/bot/C_sarcasticball.py deleted file mode 100644 index 1f5ae321816..00000000000 --- a/bot/C_sarcasticball.py +++ /dev/null @@ -1,30 +0,0 @@ -from random import choice as fsample -sarcastic_responses = ["Yeah right","What do I look like to you?","Are you kidding me?",#UsF - "As much as you","You don't believe that yourself","When pigs fly",#UsF - "Like your grandma","You would like to know, wouldn't you?", #UsF - "Like your mom", #Spectre - "Totally","Not at all", #Spectre - "AHAHAHahahaha, No.", #Strumpetplaya - "Not as much as USER","As much as USER", - "Really, you expect me to tell you that?", - "Right, and you've been building NOUNs for those USERs in the LOCATION, haven't you?" ] #Richard -locations = ["woods","baystation","ditch"] -nouns = ["bomb","toilet","robot","cyborg", - "garbage can","gun","cake", - "missile"] -def sarcasticball(data,debug,sender,users,prefix): - arg = data.lower().replace(prefix+"sarcasticball ","") - arg = arg.replace(prefix+"sball ","") - if debug: - print sender+":"+prefix+"sarcasticball", arg - choice = fsample(sarcastic_responses) - if "USER" in choice: - choice = choice.replace("USER",fsample(users),1) - choice = choice.replace("USER",fsample(users),1) - if "NOUN" in choice: - choice = choice.replace("NOUN",fsample(nouns),1) - if "LOCATION" in choice: - choice = choice.replace("LOCATION",fsample(locations),1) - if debug: - print "Responded with", choice - return(choice) diff --git a/bot/C_srtd.py b/bot/C_srtd.py deleted file mode 100644 index 761c0628d69..00000000000 --- a/bot/C_srtd.py +++ /dev/null @@ -1,35 +0,0 @@ -import random -def srtd(data,debug,sender): - try: - arg1,arg2 = data.split("d") - except ValueError, err: - if str(err) == "need more than 1 value to unpack": - return("Too small amount of arguments") - else: - return("Too many arguments") - else: - if debug: - print sender+":!rtd "+arg1+"d"+arg2 - die = [] - arg1 = arg1.replace(" ","") - arg2 = arg2.replace(" ","") - try: - i_arg1 = int(arg1) - i_arg2 = int(arg2) - if abs(i_arg1) == 0 or abs(i_arg2) == 0: - raise RuntimeError - except ValueError: - return("You lied! That's not a number!") - except RuntimeError: - return("Too many zeroes!") - else: - if abs(i_arg1) > 500: - return("Too many rolls, I can only do five hundred at max.") - else: - for i in xrange(0,abs(i_arg1)): - if i_arg2 < 0: - dice = random.randint(i_arg2,0) - else: - dice = random.randint(1,i_arg2) - die.append(dice) - return(str(reduce(lambda x,y: x+y, die))) diff --git a/bot/D_help.py b/bot/D_help.py deleted file mode 100644 index ee4e2c07cfe..00000000000 --- a/bot/D_help.py +++ /dev/null @@ -1,60 +0,0 @@ -#As new commands are added, update this. -# Last updated: 8.3.2011 - -# Updated 12.3.2011: -# - Added the missing help data for Version -# - Imported CORE_DATA to get the name. -# - Tidied some commands up a bit. -# - Replaced all "Bot"s with the Skibot's current name. - -from CORE_DATA import Name -everything = {"8ball":"[8ball ] Responds to the argument", - "allcaps":"[allcaps ] Takes an uppercase string and returns a capitalized version", - "bmaths":"[bmaths ] Takes a math equation (Like 5+5) and returns a binary result", - "coin":"[coin] Flips a coin", - "dance":"[dance] Makes %s do a little dance" %(Name), - "delquote":"(OP ONLY) [delquote ] Removes a quote with the filename equal to the argument", - "disable":"(OP ONLY) [disable] Disables all output from %s" %(Name), - "disable dance":"(HALFOP / OP ONLY) [disable dance] or [dd] Toggles dancing", - "disable fml":"(HALFOP / OP ONLY) [disable fml] Disables FML", - "eightball":"[eightball ] Responds to the argument", - "enable":"(OP ONLY) [enable] After being disabled, enable will turn output back on", - "enable fml":"{HALFOP / OP ONLY} [enable fml] After fml has been disabled, enable fml will make it available again", - "fml":"[fml] Returns a random Fuck My Life bit", - "give":"[give ] Gives the Pneumatic Disposal Unit the argument", - "help":"[help []] Returns the list of commands or a detailed description of a command if specified", - "hmaths":"[hmaths ] Takes a math equation (Like 5+5) and returns a hex result", - "makequote":"[makequote ] Creates a quote with arg being the quote itself", - "maths":"[maths ] Takes a math equation (Like 5+5) and returns a default result", - "note":"[note []] Opens a note if only arg1 is specified, Creates a note with the name of arg1 and contents of arg2 if arg2 is specified, if you prefix the note name with [CP], it creates a public note only to that channel. Which can be accessed by !note _", - "notes":"[notes] Displays all your saved notes on %s" %(Name), - "otherball":"[otherball] If Floorbot is on the same channel, %s will ask him a random question when this command is passed" %(Name), - "purgemessages":"[purgemessages] Used to delete all your Tell messages (%s,Tell )" %(Name), - "quote":"[quote []] Picks a random quote, if the author is specified, a random quote by that author", - "redmine":"[redmine] If you have a note called redmine, with a valid whoopshop redmine address, this displays all the bugs labeled as 'New' on that page. It also displays the todo note if it's found.", - "replace":"[replace] Fixes the Pneumatic Smasher if it's been broken", - "rot13":"[rot13 ] Encrypts the arg by using the rot13 method", - "rtd":"[rtd [d]] Rolls a six-sided dice if no arguments are specified, otherwise arg1 is the amount of rolls and arg2 is the amount of sides the dice have", - "sarcasticball":"[sarcasticball ] Responds to the argument sarcastically", - "sball":"[sball ] Responds to the argument sarcastically", - "srtd":"[srtd d] Rolls amount of sided die without showing the dice values separately", - "stop":"(RESTRICTED TO OP AND CREATOR) [stop] Stops %s, plain and simple" %(Name), - "suggest":"[suggest ] Saves a suggestion given to %s, to be later viewed by the creator" %(Name), - "take":"[take ] Takes an item specified in the argument from the Pneumatic Smasher", - "tban":"(OP ONLY) [tban ] When %s is an operator, You can ban an user for specified amount of seconds" %(Name), - "thm":"(RESTRICTED TO OP AND CREATOR) [thm] Normally in 8ball and sarcasticball, Users are not shown, instead replaced by things like demons or plasma researchers, toggling this changes that behaviour.", - "tm":"(OP AND CREATOR ONLY) [tm] Toggles marakov", - "togglequotemakers":"(OP ONLY) [togglequotemakers or tqm] Normally with the quote command, makers are not shown, this toggles that behaviour.", - "tqm":"(OP ONLY) [tqm or togglequotemakers] Normally with the quote command, makers are not shown, this toggles that behaviour.", - "toggleofflinemessages":"(OP ONLY) [toggleofflinemessages or tom] Allows an operator to toggle leaving Tell messages (%s, Tell ] Whenever the user says something in allcaps, it's capitalized.", - "uptime":"[uptime] Displays how long %s has been alive on the channel."%(Name), - "use":"[use] Uses the Pneumatic Smasher.", - "youtube":"[youtube ] Shows the title of a video by checking the URL provided.", - "version":"[version] Shows the current version of %s." %(Name), - "weather":"[weather ] Displays the current weather of the provided location.", - "life":"I cannot help you with that, sorry."} - diff --git a/bot/FMLformatter.py b/bot/FMLformatter.py deleted file mode 100644 index 153af61a41a..00000000000 --- a/bot/FMLformatter.py +++ /dev/null @@ -1,55 +0,0 @@ -from htmltagremove import htr -def formatter(data): - newdata = [] - data = htr(data) - bad = ["Your nick : Categories : ","\r","Advanced search - last", - "FMyLife","Get the guts to spill the beans","FML: Your random funny stories", - "Woman","Man","Choose","Health","Intimacy","Miscellaneous","Man or woman? ", - "Money","Kids","Work","Love","Email notification?", - "Moderate the FMLs","Submit your FML story", - "- If your story isn't published on the website, don't feel offended, and thank you nevertheless!", - "Pick a country","See all","Your account","Team's blog", - "Meet the FMLHello readers! Did you meet someone new this...The whole blog", - "Amazon","Borders","IndieBound","Personalized book","Terms of use", - "FML t-shirts -","Love - Money - Kids - Work - Health - Intimacy - Miscellaneous - Members", - "Follow the FML Follow the FML blog Follow the FML comments ", - "_qoptions={", - "};","})();","Categories","Sign up - Password? ", " Net Avenir : gestion publicitaire", - "FMyLife, the book","Available NOW on:","Barnes & Noble"] - - for checkable in data: - if checkable in bad: - pass - elif "_gaq.push" in checkable: - pass - elif "ga.src" in checkable: - pass - elif "var _gaq" in checkable: - pass - elif "var s =" in checkable: - pass - elif "var ga" in checkable: - pass - elif "function()" in checkable: - pass - elif "siteanalytics" in checkable: - pass - elif "qacct:" in checkable: - pass - elif "\r" in checkable: - pass - elif "ic_" in checkable: - pass - elif "Please note that spam and nonsensical stories" in checkable: - pass - elif "Refresh this page" in checkable: - pass - elif "You...The whole blo" in checkable: - pass - elif "Net Avenir : gestion publicitair" in checkable: - pass - else: - if "Net Avenir : gestion publicitaireClose the advertisement" in checkable: - checkable = checkable.replace("Net Avenir : gestion publicitaireClose the advertisement","") - newdata.append(checkable) - return newdata diff --git a/bot/Marakov/Marakov.Cache b/bot/Marakov/Marakov.Cache deleted file mode 100644 index 500f4384edd..00000000000 --- a/bot/Marakov/Marakov.Cache +++ /dev/null @@ -1,2450 +0,0 @@ -(dp0 -S'all' -p1 -(lp2 -S':p' -p3 -aS'the' -p4 -asS'code' -p5 -(lp6 -S'in' -p7 -asS'stores' -p8 -(lp9 -S'that' -p10 -asS'just' -p11 -(lp12 -S'like' -p13 -aS'marakov' -p14 -aS'felt' -p15 -aS'gives' -p16 -aS'a' -p17 -aS'add' -p18 -aS'what' -p19 -asS'being' -p20 -(lp21 -S'goon' -p22 -aS'a' -p23 -asS'text' -p24 -(lp25 -S'string' -p26 -asS'dependant' -p27 -(lp28 -S'on' -p29 -asS'speedup' -p30 -(lp31 -S'at' -p32 -asS'felt' -p33 -(lp34 -S'like' -p35 -asS'installed' -p36 -(lp37 -S'tho' -p38 -asS'disabled' -p39 -(lp40 -S'it' -p41 -asS'timing' -p42 -(lp43 -S'when' -p44 -asS'psyco' -p45 -(lp46 -S'installed' -p47 -aS'is' -p48 -asS'stops' -p49 -(lp50 -S'timing' -p51 -asS'file' -p52 -(lp53 -S'too' -p54 -aS'that' -p55 -aS'where' -p56 -asS'go' -p57 -(lp58 -S'fuck' -p59 -aS'into' -p60 -aS'test' -p61 -asS'hell' -p62 -(lp63 -S'recreate' -p64 -asS'configurable' -p65 -(lp66 -S'greeting' -p67 -asS'bs12' -p68 -(lp69 -S'message' -p70 -asS'its' -p71 -(lp72 -S'fine' -p73 -aS'just' -p74 -aS'calculated' -p75 -aS'not' -p76 -aS'really' -p77 -aS'ridiculously' -p78 -aS'now' -p79 -aS'a' -p80 -aS'missing' -p81 -aS'for' -p82 -aS'false' -p83 -aS'on' -p84 -asS'before' -p85 -(lp86 -S'that' -p87 -asS'rp-heavy' -p88 -(lp89 -S'server' -p90 -asS'announcement' -p91 -(lp92 -S'like' -p93 -asS'now' -p94 -(lp95 -S'it' -p96 -aS'running' -p97 -aS'makie' -p98 -aS'i' -p99 -asS'nudge' -p100 -(lp101 -S'python' -p102 -aS'is' -p103 -asS'sourced' -p104 -(lp105 -S'under' -p106 -asS'title' -p107 -(lp108 -S'of' -p109 -asS'situations' -p110 -(lp111 -S'where' -p112 -asS'fine-tune' -p113 -(lp114 -S'it' -p115 -asS'enough' -p116 -(lp117 -S'to' -p118 -asS'send' -p119 -(lp120 -S'it' -p121 -aS'one' -p122 -asS'should' -p123 -(lp124 -S'be' -p125 -aS'learn' -p126 -aS'we' -p127 -asS'values' -p128 -(lp129 -S'dont' -p130 -asS'to' -p131 -(lp132 -S'edit' -p133 -aS'back' -p134 -aS'know' -p135 -aS'care' -p136 -aS'be' -p137 -aS'configure' -p138 -aS'the' -p139 -aS'null' -p140 -aS'phone' -p141 -aS'welcome' -p142 -aS'reverse' -p143 -aS'send' -p144 -aS'reg' -p145 -aS'point' -p146 -aS'automatically' -p147 -aS'work' -p148 -aS'waste' -p149 -aS'marshmallow' -p150 -aS'queries' -p151 -aS'+o' -p152 -aS'disable' -p153 -asS'jit' -p154 -(lp155 -S'compiler' -p156 -asS'going' -p157 -(lp158 -S'to' -p159 -asS'helps' -p160 -(lp161 -S'me' -p162 -asS'messes' -p163 -(lp164 -S'it' -p165 -asS'indeed' -p166 -(lp167 -S'it' -p168 -asS'tg' -p169 -(lp170 -S'and' -p171 -asS'has' -p172 -(lp173 -S'been' -p174 -aS'my' -p175 -asS'into' -p176 -(lp177 -S'#tgstation13' -p178 -asS'ridiculously' -p179 -(lp180 -S'simple' -p181 -asS'annoy' -p182 -(lp183 -S'downstream' -p184 -asS'them' -p185 -(lp186 -S'out' -p187 -asS'someone' -p188 -(lp189 -S'adminhelps' -p190 -asS'sense' -p191 -(lp192 -S'i' -p193 -asS'string' -p194 -(lp195 -S'called' -p196 -asS'get' -p197 -(lp198 -S'ready' -p199 -asS'python' -p200 -(lp201 -S'script' -p202 -aS'so' -p203 -aS'code' -p204 -aS'scripts' -p205 -aS'and' -p206 -aS'but' -p207 -aS'now' -p208 -aS'released' -p209 -aS'is' -p210 -aS'enough' -p211 -asS'goon' -p212 -(lp213 -S'tg' -p214 -asS'showing' -p215 -(lp216 -S'up' -p217 -asS'20ish' -p218 -(lp219 -S'line' -p220 -asS'gonna' -p221 -(lp222 -S'go' -p223 -asS'made' -p224 -(lp225 -S'doctors' -p226 -asS'every' -p227 -(lp228 -S'loop' -p229 -aS'time' -p230 -asS'know' -p231 -(lp232 -S'the' -p233 -aS'why' -p234 -aS'that' -p235 -asS'not' -p236 -(lp237 -S'just' -p238 -aS'necessary' -p239 -aS'to' -p240 -aS'so' -p241 -aS'need' -p242 -aS'sure' -p243 -aS'relaying' -p244 -aS'very' -p245 -aS'even' -p246 -asS'2' -p247 -(lp248 -S'loop' -p249 -asS'password' -p250 -(lp251 -S'var' -p252 -asS'day' -p253 -(lp254 -S'so' -p255 -asS'swapping' -p256 -(lp257 -S'to' -p258 -asS'easily' -p259 -(lp260 -S'editable' -p261 -asS'necessary' -p262 -(lp263 -S'at' -p264 -asS'like' -p265 -(lp266 -S'being' -p267 -aS'linking' -p268 -aS'to' -p269 -aS'how' -p270 -aS'it' -p271 -aS'skbzzzzzibi' -p272 -asS'course' -p273 -(lp274 -S'that' -p275 -asS'edit' -p276 -(lp277 -S'baystation' -p278 -asS'fully' -p279 -(lp280 -S'open' -p281 -asS'greeting' -p282 -(lp283 -S'message' -p284 -asS'server' -p285 -(lp286 -S'basically' -p287 -aS'' -p288 -asS'default' -p289 -(lp290 -S'config' -p291 -asS'bad' -p292 -(lp293 -S'company' -p294 -asS'channel' -p295 -(lp296 -S'or' -p297 -asS'always' -p298 -(lp299 -S'makes' -p300 -asS'went' -p301 -(lp302 -S'past' -p303 -asS'quarxink' -p304 -(lp305 -S'its' -p306 -asS'automatic' -p307 -(lp308 -S'announcement' -p309 -asS'once' -p310 -(lp311 -S'per' -p312 -asS'wrote' -p313 -(lp314 -S'most' -p315 -asS'pain' -p316 -(lp317 -S'on' -p318 -asS'system' -p319 -(lp320 -S'calls' -p321 -asS'right' -p322 -(lp323 -S'brb' -p324 -asS'decides' -p325 -(lp326 -S'not' -p327 -asS'people' -p328 -(lp329 -S'say' -p330 -aS'i' -p331 -aS'he' -p332 -asS'goddamn' -p333 -(lp334 -S'python' -p335 -asS'back' -p336 -(lp337 -S'it' -p338 -asS'used' -p339 -(lp340 -S'to' -p341 -aS'for' -p342 -asS'past' -p343 -(lp344 -S'too' -p345 -asS'cost' -p346 -(lp347 -S'of' -p348 -asS'learn' -p349 -(lp350 -S'python' -p351 -asS'are' -p352 -(lp353 -S'lawyers' -p354 -aS'actually' -p355 -aS'configurable' -p356 -aS'we' -p357 -asS'celestialike' -p358 -(lp359 -S'of' -p360 -asS'lawyers' -p361 -(lp362 -S'for' -p363 -asS'time' -p364 -(lp365 -S'he' -p366 -asS'out' -p367 -(lp368 -S'switch' -p369 -aS'slowdowns' -p370 -aS'that' -p371 -aS'why' -p372 -aS'nudge' -p373 -asS'even' -p374 -(lp375 -S'an' -p376 -asS'what' -p377 -(lp378 -S'the' -p379 -aS'is' -p380 -aS'these' -p381 -aS'was' -p382 -aS'license' -p383 -aS'about' -p384 -aS'i' -p385 -asS'said' -p386 -(lp387 -S'in' -p388 -asS'sayt' -p389 -(lp390 -S'hat' -p391 -asS'for' -p392 -(lp393 -S'that' -p394 -aS'every' -p395 -aS'the' -p396 -aS'quarx' -p397 -aS'cc_nanotrasen' -p398 -aS'homoerotic' -p399 -aS'situations' -p400 -aS'good' -p401 -asS'#tgstation13' -p402 -(lp403 -S'and' -p404 -asS'per' -p405 -(lp406 -S'name' -p407 -asS'whole' -p408 -(lp409 -S'config' -p410 -asS'state' -p411 -(lp412 -S'the' -p413 -asS'does' -p414 -(lp415 -S'the' -p416 -aS'it' -p417 -asS'goes' -p418 -(lp419 -S'on' -p420 -asS'readme' -p421 -(lp422 -S'too' -p423 -asS'new' -p424 -(lp425 -S'bot' -p426 -aS'person' -p427 -asS'learned' -p428 -(lp429 -S'python' -p430 -asS'irc' -p431 -(lp432 -S'bot' -p433 -asS'reg' -p434 -(lp435 -S'it' -p436 -asS'blow' -p437 -(lp438 -S'borgs' -p439 -asS'shut' -p440 -(lp441 -S'down' -p442 -asS'after' -p443 -(lp444 -S'an' -p445 -aS'a' -p446 -asS'ill' -p447 -(lp448 -S'switch' -p449 -asS'says' -p450 -(lp451 -S'someones' -p452 -asS'queries' -p453 -(lp454 -S'again' -p455 -asS'technocracy' -p456 -(lp457 -S'and' -p458 -asS'we' -p459 -(lp460 -S'go' -p461 -aS'do' -p462 -aS'totally' -p463 -aS'going' -p464 -aS'expect' -p465 -aS'just' -p466 -aS'dont' -p467 -aS'have' -p468 -asS'put' -p469 -(lp470 -S'all' -p471 -asS'from' -p472 -(lp473 -S'the' -p474 -asS'data11lower' -p475 -(lp476 -S'==' -p477 -asS'configuration' -p478 -(lp479 -S'for' -p480 -asS'wait' -p481 -(lp482 -S'what' -p483 -asS'on' -p484 -(lp485 -S'my' -p486 -aS'the' -p487 -aS'a' -p488 -aS'connect' -p489 -aS'svn' -p490 -aS'one' -p491 -aS'/' -p492 -asS'about' -p493 -(lp494 -S'system' -p495 -asS'ok' -p496 -(lp497 -S'thats' -p498 -asS'reverse' -p499 -(lp500 -S'engineer' -p501 -asS'license' -p502 -(lp503 -S'is' -p504 -asS'oh' -p505 -(lp506 -S'okay' -p507 -aS'ok' -p508 -aS'i' -p509 -aS'wait' -p510 -asS'starts' -p511 -(lp512 -S'timing' -p513 -asS'could' -p514 -(lp515 -S'learn' -p516 -asS'larger' -p517 -(lp518 -S'ram' -p519 -asS'bot' -p520 -(lp521 -S'is' -p522 -aS'have' -p523 -aS'shut' -p524 -aS'uses' -p525 -asS'running' -p526 -(lp527 -S'it' -p528 -aS'the' -p529 -aS'on' -p530 -asS'times' -p531 -(lp532 -S'on' -p533 -aS'reported' -p534 -aS'went' -p535 -asS'where' -p536 -(lp537 -S'he' -p538 -asS'heck' -p539 -(lp540 -S':d' -p541 -asS'idk' -p542 -(lp543 -S'magic' -p544 -asS'receives' -p545 -(lp546 -S'a' -p547 -asS'bots' -p548 -(lp549 -S'showing' -p550 -asS'slightly' -p551 -(lp552 -S'larger' -p553 -asS'or' -p554 -(lp555 -S'know' -p556 -aS'what' -p557 -aS'work' -p558 -aS'should' -p559 -aS'data11lower' -p560 -asS'automatically' -p561 -(lp562 -S'state' -p563 -asS'thats' -p564 -(lp565 -S'not' -p566 -aS'the' -p567 -aS'kind' -p568 -asS'ugh' -p569 -(lp570 -S'fuck' -p571 -asS'major' -p572 -(lp573 -S'ss13' -p574 -aS'three' -p575 -asS'py' -p576 -(lp577 -S'file' -p578 -asS'soss' -p579 -(lp580 -S'server' -p581 -asS'dont' -p582 -(lp583 -S'need' -p584 -aS'have' -p585 -aS'send' -p586 -aS'want' -p587 -aS'speak' -p588 -asS'hostmask' -p589 -(lp590 -S'combination' -p591 -asS'point' -p592 -(lp593 -S'out' -p594 -aS'has' -p595 -asS'simple' -p596 -(lp597 -S'to' -p598 -asS'miura' -p599 -(lp600 -S'doesnt' -p601 -asS'variables' -p602 -(lp603 -S'in' -p604 -asS'recreate' -p605 -(lp606 -S'it' -p607 -asS'welcome' -p608 -(lp609 -S'to' -p610 -asS'linking' -p611 -(lp612 -S'them' -p613 -asS'down' -p614 -(lp615 -S'when' -p616 -asS'why' -p617 -(lp618 -S'its' -p619 -aS'it' -p620 -aS'is' -p621 -asS'doesnt' -p622 -(lp623 -S'play' -p624 -aS'call' -p625 -asS'marakov' -p626 -(lp627 -S'loops' -p628 -aS'helps' -p629 -asS'laugh' -p630 -(lp631 -S'when' -p632 -asS'pony' -p633 -(lp634 -S'asshole' -p635 -asS'message' -p636 -(lp637 -S'has' -p638 -aS'should' -p639 -asS'open' -p640 -(lp641 -S'sourced' -p642 -aS'source' -p643 -asS'brb' -p644 -(lp645 -S'swapping' -p646 -asS'speak' -p647 -(lp648 -S'python' -p649 -asS'pastebin' -p650 -(lp651 -S'the' -p652 -asS'line' -p653 -(lp654 -S'core' -p655 -aS'on' -p656 -asS'three' -p657 -(lp658 -S'being' -p659 -asS'yay' -p660 -(lp661 -S'it' -p662 -asS'meatbag' -p663 -(lp664 -S'when' -p665 -asS'would' -p666 -(lp667 -S'be' -p668 -aS'expect' -p669 -asS'script' -p670 -(lp671 -S'that' -p672 -asS'illegal' -p673 -(lp674 -S'ban' -p675 -asS'there' -p676 -(lp677 -S'are' -p678 -aS'we' -p679 -asS'add' -p680 -(lp681 -S'that' -p682 -aS'a' -p683 -asS'been' -p684 -(lp685 -S'processed' -p686 -asS'name' -p687 -(lp688 -S'/' -p689 -aS'when' -p690 -asS'ai' -p691 -(lp692 -S'malf' -p693 -asS'marshmallow' -p694 -(lp695 -S'pony' -p696 -asS'of' -p697 -(lp698 -S'the' -p699 -aS'ss13' -p700 -aS'tgstation13' -p701 -aS'a' -p702 -aS'course' -p703 -aS'it' -p704 -aS'soss' -p705 -aS'annoying' -p706 -aS'any' -p707 -aS'me' -p708 -aS'cap' -p709 -aS'technocracy' -p710 -asS'call' -p711 -(lp712 -S'me' -p713 -asS'too' -p714 -(lp715 -S':' -p716 -aS'fast' -p717 -asS'basic' -p718 -(lp719 -S'configuration' -p720 -asS'var' -p721 -(lp722 -S'and' -p723 -asS'calc' -p724 -(lp725 -S'times' -p726 -asS'was' -p727 -(lp728 -S'going' -p729 -aS'it' -p730 -aS'that' -p731 -aS'not' -p732 -aS'intended' -p733 -asS'tell' -p734 -(lp735 -S'people' -p736 -asS'500' -p737 -(lp738 -S'chance' -p739 -asS'gives' -p740 -(lp741 -S'a' -p742 -asS'sort' -p743 -(lp744 -S'of' -p745 -asS'svn' -p746 -(lp747 -S'size' -p748 -asS'only' -p749 -(lp750 -S'does' -p751 -aS'2' -p752 -asS'10-30%' -p753 -(lp754 -S'speedup' -p755 -asS'knows' -p756 -(lp757 -S'about' -p758 -asS'webpage' -p759 -(lp760 -S'title' -p761 -asS'that' -p762 -(lp763 -S'makes' -p764 -aS'would' -p765 -aS'the' -p766 -aS'needs' -p767 -aS'to' -p768 -aS'at' -p769 -aS'for' -p770 -aS'was' -p771 -aS'data' -p772 -asS'company' -p773 -(lp774 -S'2' -p775 -asS'under' -p776 -(lp777 -S'cc-by-sa' -p778 -asS'editable' -p779 -(lp780 -S'config' -p781 -asS'but' -p782 -(lp783 -S'of' -p784 -asS'idea' -p785 -(lp786 -S'what' -p787 -asS'released' -p788 -(lp789 -S'under' -p790 -asS'part' -p791 -(lp792 -S'before' -p793 -asS'link' -p794 -(lp795 -S'said' -p796 -aS'to' -p797 -asS'basically' -p798 -(lp799 -S'it' -p800 -asS'doctors' -p801 -(lp802 -S'useless' -p803 -asS'==' -p804 -(lp805 -S'channel' -p806 -aS'channel1::' -p807 -asS'be' -p808 -(lp809 -S'an' -p810 -aS'called' -p811 -aS'a' -p812 -aS'in' -p813 -aS'running' -p814 -aS'used' -p815 -asS'editing' -p816 -(lp817 -S'goddamn' -p818 -asS'with' -p819 -(lp820 -S'the' -p821 -aS'easily' -p822 -aS'adminhelps' -p823 -aS'my' -p824 -aS'a' -p825 -asS'those' -p826 -(lp827 -S'are' -p828 -asS'he' -p829 -(lp830 -S'put' -p831 -aS'disabled' -p832 -aS'is' -p833 -aS'keeps' -p834 -aS'knows' -p835 -aS'stores' -p836 -aS'notices' -p837 -aS'only' -p838 -aS'doesnt' -p839 -aS'receives' -p840 -aS'says' -p841 -aS'messes' -p842 -asS'me' -p843 -(lp844 -S'figure' -p845 -aS'laugh' -p846 -aS'to' -p847 -aS'meatbag' -p848 -asS'also' -p849 -(lp850 -S'i' -p851 -aS'we' -p852 -aS'now' -p853 -asS'kind' -p854 -(lp855 -S'of' -p856 -asS'main' -p857 -(lp858 -S'bot' -p859 -asS'/' -p860 -(lp861 -S'hostmask' -p862 -aS'off' -p863 -asS'full' -p864 -(lp865 -S'of' -p866 -asS'these' -p867 -(lp868 -S'are' -p869 -asS'makie' -p870 -(lp871 -S'it' -p872 -asS'sleepers' -p873 -(lp874 -S'made' -p875 -asS'up' -p876 -(lp877 -S'elsewhere' -p878 -aS'me' -p879 -aS'a' -p880 -asS'will' -p881 -(lp882 -S'annoy' -p883 -asS'computer' -p884 -(lp885 -S'explodd' -p886 -asS'limit' -p887 -(lp888 -S'on' -p889 -asS'can' -p890 -(lp891 -S'fine-tune' -p892 -aS'add' -p893 -aS'i' -p894 -aS'we' -p895 -asS'how' -p896 -(lp897 -S'its' -p898 -aS'he' -p899 -asS'were' -p900 -(lp901 -S'the' -p902 -asS'malf' -p903 -(lp904 -S'blow' -p905 -asS'baystation' -p906 -(lp907 -S'12' -p908 -asS'other' -p909 -(lp910 -S'loop' -p911 -asS'my' -p912 -(lp913 -S'end' -p914 -aS'computer' -p915 -aS'code' -p916 -asS'called' -p917 -(lp918 -S'as' -p919 -aS'when' -p920 -asS'loop' -p921 -(lp922 -S'times' -p923 -asS'expect' -p924 -(lp925 -S'it' -p926 -asS'and' -p927 -(lp928 -S'bs12' -p929 -aS'stops' -p930 -aS'i' -p931 -aS'do' -p932 -aS'to' -p933 -aS'make' -p934 -aS'he' -p935 -aS'preferably' -p936 -aS'thats' -p937 -aS'sayt' -p938 -aS'fascism' -p939 -asS'dedicated' -p940 -(lp941 -S'solely' -p942 -asS'changed' -p943 -(lp944 -S'it' -p945 -asS'sees' -p946 -(lp947 -S'a' -p948 -asS'relaying' -p949 -(lp950 -S'adminhelps' -p951 -asS'figure' -p952 -(lp953 -S'out' -p954 -asS'do' -p955 -(lp956 -S'not' -p957 -aS'it' -p958 -aS'seem' -p959 -asS'ran' -p960 -(lp961 -S'the' -p962 -asS'ah' -p963 -(lp964 -S'running' -p965 -aS'ok' -p966 -asS'is' -p967 -(lp968 -S'baystation' -p969 -aS'a' -p970 -aS'that' -p971 -aS'it' -p972 -aS'coded' -p973 -aS'python' -p974 -aS'open' -p975 -aS'dependant' -p976 -aS'so' -p977 -aS'apparently' -p978 -asS'ram' -p979 -(lp980 -S'footprint' -p981 -asS'am' -p982 -(lp983 -S'the' -p984 -asS'it' -p985 -(lp986 -S'up' -p987 -aS'starts' -p988 -aS'receives' -p989 -aS'just' -p990 -aS'expires' -p991 -aS'works' -p992 -aS'always' -p993 -aS'decides' -p994 -aS'on' -p995 -aS'here' -p996 -aS'used' -p997 -aS'to' -p998 -aS'those' -p999 -aS'sees' -p1000 -aS'does' -p1001 -aS'myself' -p1002 -aS'a' -p1003 -aS'okay' -p1004 -aS'was' -p1005 -aS'go' -p1006 -aS'if' -p1007 -aS'once' -p1008 -aS'is' -p1009 -aS'for' -p1010 -asS'an' -p1011 -(lp1012 -S'hour' -p1013 -aS'illegal' -p1014 -aS'automatic' -p1015 -aS'error' -p1016 -asS'ready' -p1017 -(lp1018 -S'for' -p1019 -asS'say' -p1020 -(lp1021 -S'sleepers' -p1022 -aS'ai' -p1023 -aS'that*' -p1024 -aS'stop' -p1025 -asS'good' -p1026 -(lp1027 -S':p' -p1028 -asS'im' -p1029 -(lp1030 -S'not' -p1031 -aS'sorry' -p1032 -aS'lazy' -p1033 -asS'at' -p1034 -(lp1035 -S'all' -p1036 -aS'the' -p1037 -aS'no' -p1038 -asS'have' -p1039 -(lp1040 -S'no' -p1041 -aS'psyco' -p1042 -aS'the' -p1043 -aS'a' -p1044 -asS'in' -p1045 -(lp1046 -S'python' -p1047 -aS'a' -p1048 -aS'the' -p1049 -aS'100' -p1050 -asS'need' -p1051 -(lp1052 -S'to' -p1053 -aS'six' -p1054 -asS'politics' -p1055 -(lp1056 -S'of' -p1057 -asS'seem' -p1058 -(lp1059 -S'familiar' -p1060 -asS'work' -p1061 -(lp1062 -S'with' -p1063 -asS'apparently' -p1064 -(lp1065 -S'homophobic' -p1066 -aS'i' -p1067 -asS'any' -p1068 -(lp1069 -S'link' -p1070 -asS'as' -p1071 -(lp1072 -S'well' -p1073 -aS'variables' -p1074 -asS'sci-fi' -p1075 -(lp1076 -S'with' -p1077 -asS'preferably' -p1078 -(lp1079 -S'python' -p1080 -asS'really' -p1081 -(lp1082 -S'simple' -p1083 -aS'now' -p1084 -asS'needs' -p1085 -(lp1086 -S'to' -p1087 -aS'a' -p1088 -asS'null' -p1089 -(lp1090 -S'them' -p1091 -asS'because' -p1092 -(lp1093 -S'we' -p1094 -asS'want' -p1095 -(lp1096 -S'to' -p1097 -asS'no' -p1098 -(lp1099 -S'pain' -p1100 -aS'idea' -p1101 -aS'point' -p1102 -aS'the' -p1103 -asS'solely' -p1104 -(lp1105 -S'to' -p1106 -asS'nah' -p1107 -(lp1108 -S'its' -p1109 -aS'ill' -p1110 -asS'dunno' -p1111 -(lp1112 -S'is' -p1113 -asS'when' -p1114 -(lp1115 -S'it' -p1116 -aS'the' -p1117 -aS'people' -p1118 -aS'i' -p1119 -aS'can' -p1120 -aS'someone' -p1121 -aS'its' -p1122 -asS'same' -p1123 -(lp1124 -S'file' -p1125 -asS'id' -p1126 -(lp1127 -S'like' -p1128 -asS'note' -p1129 -(lp1130 -S'how' -p1131 -asS'figuring' -p1132 -(lp1133 -S'out' -p1134 -asS'bah' -p1135 -(lp1136 -S'apparently' -p1137 -asS'coded' -p1138 -(lp1139 -S'in' -p1140 -asS'take' -p1141 -(lp1142 -S'it' -p1143 -asS'hop' -p1144 -(lp1145 -S'to' -p1146 -asS'familiar' -p1147 -(lp1148 -S'message' -p1149 -asS'test' -p1150 -(lp1151 -S'server' -p1152 -aS'bots' -p1153 -aS'bad' -p1154 -asS'asshole' -p1155 -(lp1156 -g288 -asS'if' -p1157 -(lp1158 -S'it' -p1159 -aS'its' -p1160 -aS'data11lower' -p1161 -aS'he' -p1162 -asS'config' -p1163 -(lp1164 -S'file' -p1165 -aS'values' -p1166 -asS'homophobic' -p1167 -(lp1168 -S'as' -p1169 -asS'dose' -p1170 -(lp1171 -S'of' -p1172 -asS'play' -p1173 -(lp1174 -S'ss13' -p1175 -asS'sure' -p1176 -(lp1177 -S'the' -p1178 -aS'if' -p1179 -asS'okay' -p1180 -(lp1181 -S'desu' -p1182 -aS'cool' -p1183 -aS'cc' -p1184 -asS'intended' -p1185 -(lp1186 -S'to' -p1187 -asS'one' -p1188 -(lp1189 -S'of' -p1190 -aS'line' -p1191 -aS'in' -p1192 -asS'neat' -p1193 -(lp1194 -S'is' -p1195 -asS'adminhelps' -p1196 -(lp1197 -S'from' -p1198 -aS'with' -p1199 -asS'expires' -p1200 -(lp1201 -S'after' -p1202 -asS'chance' -p1203 -(lp1204 -S'every' -p1205 -asS'most' -p1206 -(lp1207 -S'of' -p1208 -asS'fascism' -p1209 -(lp1210 -g288 -asS'disable' -p1211 -(lp1212 -S'it' -p1213 -asS'connected' -p1214 -(lp1215 -S'businessman' -p1216 -asS'never' -p1217 -(lp1218 -S'learned' -p1219 -asS'scripts' -p1220 -(lp1221 -S'will' -p1222 -asS'along' -p1223 -(lp1224 -S'with' -p1225 -asS'waste' -p1226 -(lp1227 -S'space' -p1228 -asS'ss13' -p1229 -(lp1230 -S'servers' -p1231 -asS'cap' -p1232 -(lp1233 -S'troopers' -p1234 -asS'totally' -p1235 -(lp1236 -S'need' -p1237 -asS'six' -p1238 -(lp1239 -S'test' -p1240 -asS'a' -p1241 -(lp1242 -S'businessman' -p1243 -aS'message' -p1244 -aS'jit' -p1245 -aS'10-30%' -p1246 -aS'slightly' -p1247 -aS'day' -p1248 -aS'test' -p1249 -aS'config' -p1250 -aS'20ish' -p1251 -aS'bs12' -p1252 -aS'text' -p1253 -aS'new' -p1254 -aS'password' -p1255 -aS'vhost' -p1256 -aS'configurable' -p1257 -aS'link' -p1258 -aS'limit' -p1259 -aS'file' -p1260 -aS'dose' -p1261 -aS'500' -p1262 -aS'bit' -p1263 -asS'ofc' -p1264 -(lp1265 -S'i' -p1266 -asS'off' -p1267 -(lp1268 -S'of' -p1269 -asS'calls' -p1270 -(lp1271 -S'external' -p1272 -asS'i' -p1273 -(lp1274 -S'need' -p1275 -aS'can' -p1276 -aS'dont' -p1277 -aS'am' -p1278 -aS'guess' -p1279 -aS'see' -p1280 -aS'have' -p1281 -aS'just' -p1282 -aS'dunno' -p1283 -aS'wrote' -p1284 -aS'know' -p1285 -aS'was' -p1286 -aS'changed' -p1287 -aS'take' -p1288 -aS'could' -p1289 -aS'never' -p1290 -aS'should' -p1291 -aS'say' -p1292 -aS'tell' -p1293 -aS'code' -p1294 -aS'would' -p1295 -aS'like' -p1296 -aS'disabled' -p1297 -asS'makes' -p1298 -(lp1299 -S'sense' -p1300 -aS'me' -p1301 -asS'calculated' -p1302 -(lp1303 -S'for' -p1304 -asS'afk' -p1305 -(lp1306 -S'vidya' -p1307 -asS'well' -p1308 -(lp1309 -S'connected' -p1310 -asS'data' -p1311 -(lp1312 -S'in' -p1313 -asS'homoerotic' -p1314 -(lp1315 -S'sci-fi' -p1316 -asS'switch' -p1317 -(lp1318 -S'after' -p1319 -aS'goes' -p1320 -asS'so' -p1321 -(lp1322 -S'i' -p1323 -aS'uh' -p1324 -aS':p' -p1325 -aS'bad' -p1326 -aS'sly' -p1327 -asS'someones' -p1328 -(lp1329 -S'name' -p1330 -asS'keeps' -p1331 -(lp1332 -S'all' -p1333 -asS'very' -p1334 -(lp1335 -S'celestialike' -p1336 -asS'businessman' -p1337 -(lp1338 -S'of' -p1339 -ag288 -asS'the' -p1340 -(lp1341 -S'heck' -p1342 -aS'major' -p1343 -aS'well' -p1344 -aS'politics' -p1345 -aS'rp-heavy' -p1346 -aS'marakov' -p1347 -aS'law' -p1348 -aS'message' -p1349 -aS'cost' -p1350 -aS'new' -p1351 -aS'nudge' -p1352 -aS'bot' -p1353 -aS'python' -p1354 -aS'basic' -p1355 -aS'whole' -p1356 -aS'configuration' -p1357 -aS'irc' -p1358 -aS'readme' -p1359 -aS'default' -p1360 -aS'conspiracy' -p1361 -aS'config' -p1362 -aS'webpage' -p1363 -aS'channel' -p1364 -aS'server' -p1365 -aS'download' -p1366 -aS'main' -p1367 -aS'dmb' -p1368 -aS'part' -p1369 -aS'people' -p1370 -aS'same' -p1371 -aS'hell' -p1372 -aS'other' -p1373 -aS'switch' -p1374 -asS'12' -p1375 -(lp1376 -S'out' -p1377 -aS'anyway' -p1378 -asS'core' -p1379 -(lp1380 -S'py' -p1381 -asS'make' -p1382 -(lp1383 -S'sure' -p1384 -aS'the' -p1385 -asS'turns' -p1386 -(lp1387 -S'out' -p1388 -asS'external' -p1389 -(lp1390 -S'apps' -p1391 -as. \ No newline at end of file diff --git a/bot/Marakov_Chain.py b/bot/Marakov_Chain.py deleted file mode 100644 index 687c4336327..00000000000 --- a/bot/Marakov_Chain.py +++ /dev/null @@ -1,203 +0,0 @@ -import pickle -import random -import os -import sys -import time -import CORE_DATA -def merge(d1, d2, merger=lambda x,y:x+y): - #http://stackoverflow.com/questions/38987/how-can-i-merge-two-python-dictionaries-as-a-single-expression - result = dict(d1) - for k,v in d2.iteritems(): - if k in result: - result[k] = merger(result[k], v) - else: - result[k] = v - return result -full_data = {} -imported_data = {} -try: - tiedostot = os.listdir("Marakov") -except: - os.mkdir("Marakov") - tiedostot = os.listdir("Marakov") -else: - pass - -listaus = [] -for i in tiedostot: - if "marakov." not in i.lower(): - pass - else: - listaus.append(i) -for i in listaus: - tiedosto = open("Marakov/"+i,"r") - old_size = len(full_data.keys()) - if i != "Marakov.Cache": - imported_data = merge(imported_data,pickle.load(tiedosto)) - print "Added contents of "+i+" (Import)" - print "Entries: "+str(len(imported_data)) - else: - full_data = merge(full_data,pickle.load(tiedosto)) - new_size = len(full_data.keys()) - print "Added contents of "+i - print "Entries: "+str(new_size-old_size) - time.sleep(0.1) - -def give_data(data): - state = False - for a,b in zip(data.split(" "),data.split(" ")[1:]): - a = a.lower().replace(",","").replace(".","").replace("?","").replace("!","").replace("(","").replace(")","").replace("[","").replace("]","").replace('"',"").replace("'","") - b = b.lower().replace(",","").replace(".","").replace("?","").replace("!","").replace("(","").replace(")","").replace("[","").replace("]","").replace('"',"").replace("'","") - if a not in [CORE_DATA.prefix+"marakov"]+CORE_DATA.SName: - state = True - if a[:7] == "http://" or a[:7] == "http:\\\\" or a[:4] == "www.": - pass - else: - try: - if b not in full_data[a]: - full_data[a].append(b) - except: - try: - if b not in imported_data[a]: - pass - except: - full_data[a] = [] - full_data[a].append(b) - if state == True: - tiedosto = open("Marakov/Marakov.Cache","w") - pickle.dump(full_data,tiedosto) - tiedosto.close() -def form_sentence(argument=None): - length = 0 - attempts = 0 - while attempts < 20: - sentence = [] - if argument != None: - a = argument - else: - try: - a = random.choice(full_data.keys()) - except IndexError: - try: - b = random.choice(imported_data.keys()) - except IndexError: - attempts = 999 - return "No sentences formable at all" - sentence.append(a) - length = 0 - attempts += 1 - while length < 12 or sentence[-1].lower() in ["but","who","gets","im","most","is","it","if","then","after","over","every","of","on","or","as","the","wheather","whether","a","to","and","for"] and length < 24: - try: - b = random.choice(full_data[a]) - except: - try: - b = random.choice(imported_data[a]) - except IndexError: - break - except KeyError: - break - else: - sentence.append(b) - length += 1 - a = b - else: - sentence.append(b) - length += 1 - a = b - if len(sentence) > 5: - argument = None - return sentence - else: - pass - argument = None - return sentence -def remdata(arg): - try: - del(full_data[arg]) - except: - print "There is no such data" - else: - tiedosto = open("Marakov/Marakov.Cache","w") - pickle.dump(full_data,tiedosto) - tiedosto.close() -def remobject(arg1,arg2): - try: - del(full_data[arg1][full_data[arg1].index(arg2)]) - except ValueError: - print "No such object" - except KeyError: - print "No such data" - else: - tiedosto = open("Marakov/Marakov.Cache","w") - pickle.dump(full_data,tiedosto) - tiedosto.close() -def convert(filename_from,filename_to): - try: - tiedosto = open(filename_from,"r") - data = pickle.load(tiedosto) - tiedosto.close() - except: - try: - tiedosto.close() - except: - pass - print "Error!" - else: - for lista in data.keys(): - try: - a = lista[-1] - except IndexError: - pass - else: - if lista[-1] in """",.?!'()[]{}""" and not lista.islower(): - if lista[:-1].lower() in data.keys(): - data[lista[:-1].lower()] += data[lista] - print "Added "+str(len(data[lista]))+" Objects from "+lista+" To "+lista[:-1].lower() - del(data[lista]) - else: - data[lista[:-1].lower()] = data[lista] - print lista+" Is now "+lista[:-1].lower() - del(data[lista]) - elif lista[-1] in """",.?!'()[]{}""" and lista.islower(): - if lista[:-1] in data.keys(): - data[lista[:-1]] += data[lista] - print "Added "+str(len(data[lista]))+" Objects from "+lista+" To "+lista[:-1] - del(data[lista]) - else: - data[lista[:-1]] = data[lista] - print lista+" Is now "+lista[:-1] - del(data[lista]) - elif not lista.islower(): - if lista.lower() in data.keys(): - data[lista.lower()] += data[lista] - print "Added "+str(len(data[lista]))+" Objects from "+lista+" To "+lista.lower() - del(data[lista]) - else: - data[lista.lower()] = data[lista] - print lista+" Is now "+lista.lower() - del(data[lista]) - - - for a in data.keys(): - for b in data[a]: - if b.lower()[:7] == "http://" or b.lower()[:7] == "http:\\\\" or b.lower()[:4] == "www.": - data[a].pop(b) - else: - try: - if b[-1] in """",.?!'()[]{}""" and not b.islower() and not b.isdigit(): - data[a].pop(data[a].index(b)) - data[a].append(b[:-1].lower()) - print a+" | "+b +" -> "+b[:-1].lower() - elif b[-1] in """",.?!'()[]{}""" and b.islower(): - data[a].pop(data[a].index(b)) - data[a].append(b[:-1].lower()) - print a+" | "+b +" -> "+b[:-1] - elif not b.islower() and not b.isdigit(): - data[a].pop(data[a].index(b)) - data[a].append(b.lower()) - print a+" | "+b +" -> "+b.lower() - except IndexError: #If it has no letters.. well.. yeah. - data[a].pop(data[a].index(b)) - print "Removed a NULL object" - tiedosto = open(filename_to,"w") - pickle.dump(data,tiedosto) diff --git a/bot/Namecheck.py b/bot/Namecheck.py deleted file mode 100644 index 347ff7ff476..00000000000 --- a/bot/Namecheck.py +++ /dev/null @@ -1,19 +0,0 @@ -def Namecheck(name,against,sender): - __doc__ = "False = No match, True = Match" - for i in against: - if i.lower() in name.lower() and sender.lower() not in name.lower(): - return True - else: - pass -def Namecheck_dict(name,against): - __doc__ = "False = No match, True = Match" - fuse = False - for a,i in against.items(): - if i.lower() in name.lower(): - fuse = True - break - else: - pass - return fuse,a - - diff --git a/bot/NanoTrasenBot.py b/bot/NanoTrasenBot.py deleted file mode 100644 index 6f65a11dafb..00000000000 --- a/bot/NanoTrasenBot.py +++ /dev/null @@ -1,1565 +0,0 @@ -# -*- 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: - with open("psycodownload.txt","w") as tiedosto: - tiedosto.write("http://www.voidspace.org.uk/python/modules.shtml#psyco") - tiedosto.write("\nhttp://psyco.sourceforge.net/download.html") - 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 = False #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: - with open("replacenames.cache","r") as tiedosto: - replacenames = pickle.load(tiedosto) - for i in replacenames.values(): - if len(i) > call_me_max_length: - replacenames[replacenames.keys()[replacenames.values().index(i)]] = i[:call_me_max_length] - with open("replacenames.cache","w") as tiedosto: - pickle.dump(replacenames,tiedosto) - 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: - with open("peopleheknows.cache","r") as tiedosto: - peopleheknows = pickle.load(tiedosto) -except IOError: - peopleheknows = [[],[]] - with open("peopleheknows.cache","w") as tiedosto: - pass -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 and time.time()-backup > delay: - conn.send("PONG "+pongtarg) - print "Ponged" - self_time = time.time() - elif 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 and 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: - with open(targetdirectory+"banlog/"+str(int(start))+"-"+str(int(end))+".txt","w") as tiedosto: - 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") - 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 and 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 - with open(targetdirectory+"suggestions/suggestions_"+str(int(time.time()))+".txt","a") as tiedosto: - tiedosto.write(arg) - conn.privmsg(targetchannel,"Suggestion received") - 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)) - ### 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+"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+"uptime"): - arg1 = uptime_start - arg2 = time.time() - arg1 = arg2 - arg1 - arg2 = arg1 - if arg1 < 60: - conn.privmsg(targetchannel,sender+" : I have been up for "+str(round(arg1,2))+" Seconds") - elif arg1 < 3600: - arg1 = divmod(arg1,60) - arg = " Minute" if int(arg1[0]) == 1 else " Minutes" - conn.privmsg(targetchannel,sender+" : I have been up for "+str(int(arg1[0]))+arg+" and "+str(round(arg1[1],2))+" Seconds") - elif arg1 <= 86400: - arg1 = divmod(arg1,3600) - arg3 = " Hour" if int(arg1[0]) == 1 else " Hours" - arg2 = divmod(arg1[1],60) - arg = " Minute" if int(arg2[0]) == 1 else " Minutes" - conn.privmsg(targetchannel,sender+" : I have been up for "+str(int(arg1[0]))+arg3+", "+str(int(arg2[0]))+arg+" and "+str(round(arg2[1],2))+" Seconds") - elif arg1 > 86400: - arg1 = divmod(arg1,86400) - arg2 = divmod(arg1[1],3600) - arg3 = divmod(arg2[1],60) - arg4 = " Day" if int(arg1[0]) == 1 else " Days" - arg5 = " Hour" if int(arg2[0]) == 1 else " Hours" - arg6 = " Minute" if int(arg3[0]) == 1 else " Minutes" - conn.privmsg(targetchannel,sender+" : I have been up for "+str(int(arg1[0]))+arg4+", "+str(int(arg2[0]))+arg5+", "+str(int(arg3[0]))+arg6+" and "+str(round(arg3[1],2))+" Seconds") - elif cocheck(prefix+"purgemessages"): - count = 0 - for i,a in tell_list.items(): - for b in a: - if "||From: "+truesender in b: - count += 1 - del(tell_list[i][tell_list[i].index(b)]) - conn.privmsg(targetchannel, sender+" : All your "+str(count)+" messages have been purged") - elif influx.split(" ")[0].lower().replace(",","").replace(":","") in SName+[Name.lower()] and "tell" in (influx.lower().split(" ")+[""])[1]: - arg = influx.lower().split(" ") - equalarg = influx.split(" ") - next_one = False - count = 0 - spot = 0 - for i in arg: - count += 1 - if "tell" in i.lower(): - next_one = True - elif next_one == True: - next_one = i.lower() - spot = count - break - else: - pass - if next_one != True and next_one != False: - #if ("^\^".join(tell_list.values())).count(truesender) >= offline_message_limit: - if str(tell_list.values()).count("||From: "+truesender) >= offline_message_limit: - conn.privmsg(targetchannel,sender+" : Limit of "+str(offline_message_limit)+" reached! Use !purgemessages if you want to get rid of them!") - else: - try: - tell_list[next_one].append((" ".join(equalarg[spot:]))+" ||From: "+truesender) - except: - tell_list[next_one] = [(" ".join(equalarg[spot:]))+" ||From: "+truesender] - conn.privmsg(targetchannel,"Sending a message to "+next_one+" when they arrive.") - # < This part has to be within subsidiaries of the bot, and must not be modified, intentionally hidden or deleted. - elif influx.split(" ")[0].lower().replace(",","").replace(":","") in SName+[Name.lower()] and "who created you" in influx.lower(): - conn.privmsg(targetchannel, "I was created by Skibiliano.") - # The part ends here > - elif parse_xkcd and "xkcd.com/" in influx.lower(): - if influx.lower()[0:3] == "www": - data = "http://"+influx - elif influx.lower()[0:3] == "xkc": - data = "http://"+influx - else: - data = influx - data = data.split(" ") - for i in data: - if "http://" in i and "xkcd" in i: - churn = xkcdparser.xkcd(i) - if churn == "NOTHING": - pass - else: - conn.privmsg(targetchannel,sender+" : XKCD - "+churn) - break - else: - pass - elif automatic_youtube_reveal and "youtube.com/watch?v=" in influx.lower(): - temporal_list2 = [] - temporal_data = influx.split(" ") - temporal_list = [] - for block in temporal_data: - if "youtube.com/watch?v=" in block: - temporal_list.append(block) - for temdata in temporal_list: - - if temdata[0:3] == "you": - temdata = "http://www."+temdata - elif temdata[0:3] == "www": - temdata = "http://"+temdata - elif temdata[0:4] == "http": - pass - #Obscure ones - elif temdata[0:3] == "ww.": - temdata = "http://w"+temdata - elif temdata[0:3] == "w.y": - temdata = "http://ww"+temdata - elif temdata[0:3] == ".yo": - temdata = "http://www"+temdata - elif temdata[0:3] == "ttp": - temdata = "h"+temdata - elif temdata[0:3] == "tp:": - temdata = "ht"+temdata - elif temdata[0:3] == "p:/" or temdata[0:3] == "p:\\": - temdata = "htt"+temdata - elif temdata[0:3] == "://" or temdata[0:3] == ":\\\\": - temdata = "http"+temdata - elif temdata[0:2] == "//" or temdata[0:2] == "\\\\": - if temdata[2] == "y": - temdata = "http://www."+temdata[2:] - elif temdata[2] == "w": - temdata = "http:"+temdata - else: - pass - if debug: - print truesender+":"+temdata - arg = temdata - check = temdata.lower() - if check[0:5] == "https": - if len(temporal_list) == 1: - conn.privmsg(targetchannel,sender+" :Secure Youtube does NOT exist") - break - else: - temporal_list2.append("Secure Youtube does NOT exist") - break - else: - if cache_youtube_links == True: - result = YTCV2(arg) - else: - result = YTCV2(arg,0) - if type(result) == str: - ### To remove =" - if result[0:4] == 'nt="': - result = result[4:] - pass - elif result[0:2] == '="': - result = result[2:] - pass - else: - pass - if """ in result: - result.replace(""",'"') - if len(temporal_list) == 1: - conn.privmsg(targetchannel,sender+" : "+result) - break - else: - temporal_list2.append(result) - else: - if len(temporal_list) == 1: - conn.privmsg(targetchannel,sender+" : The video does not exist") - break - else: - temporal_list2.append("The video does not exist") - if len(temporal_list) == 1: - pass - else: - conn.privmsg(targetchannel,sender+" : "+str(reduce(lambda x,y: x+" :-And-: "+y,temporal_list2))) - elif RegExpCheckerForWebPages("((http://)|(https://))|([a-zA-Z0-9]+[.])|([a-zA-Z0-9](3,)\.+[a-zA-Z](2,))",influx,1): - arg2 = RegExpCheckerForWebPages("(http://)|([a-zA-Z0-9]+[.])|([a-zA-Z0-9](3,)\.+[a-zA-Z](2,))",influx,0) - if arg2 == 404: - pass - else: - if arg2[:7] == "http://": - pass - elif arg2[:4] == "www.": - arg2 = "http://"+arg2 - else: - arg2 = "http://"+arg2 - try: - arg = Whoopshopchecker.TitleCheck(arg2) - if len(arg2) == 0: - pass - else: - conn.privmsg(targetchannel,sender+" : "+arg) - except: - #conn.privmsg(targetchannel,sender+" : An odd error occurred") - pass - elif respond_of_course and "take over the" in influx.lower() or respond_of_course and "conquer the" in influx.lower(): - if debug: - print truesender+"::"+influx - conn.privmsg(targetchannel,"Of course!") - elif respond_khan and "khan" in influx.lower(): - if respond_khan: - if debug: - print truesender+"::"+influx - if "khan " in influx.lower(): - conn.privmsg(targetchannel,"KHAAAAAAN!") - elif " khan" in influx.lower(): - conn.privmsg(targetchannel,"KHAAAAAN!") - elif influx.lower() == "khan": - conn.privmsg(targetchannel,"KHAAAAAAAAAN!") - elif influx.lower() == "khan?": - conn.privmsg(targetchannel,"KHAAAAAAAAAAAAAN!") - elif influx.lower() == "khan!": - conn.privmsg(targetchannel,"KHAAAAAAAAAAAAAAAAAAN!") - elif respond_khan and influx.lower().count("k") + influx.lower().count("h") + influx.lower().count("a") + influx.lower().count("n") + influx.lower().count("!") + influx.lower().count("?") == len(influx): - if "k" in influx.lower() and "h" in influx.lower() and "a" in influx.lower() and "n" in influx.lower(): - if debug: - print truesender+"::"+influx - conn.privmsg(targetchannel,"KHAAAAN!") - elif influx.split(" ")[0].lower() in ["thanks","danke","tack"] and len(influx.split(" ")) > 1 and influx.split(" ")[1].lower().replace("!","").replace("?","").replace(".","").replace(",","") in SName+[lowname]: - conn.privmsg(targetchannel,"No problem %s" %(sender)) - elif "happy birthday" in influx.lower() and birthday_announced == time.gmtime(time.time())[0]: - conn.privmsg(targetchannel,sender+" : Thanks :)") - elif influx.split(" ")[0].lower().replace(",","").replace(".","").replace("!","").replace("?","") in SName+[lowname] and "call me" in influx.lower(): - if allow_callnames == True: - arg = influx.split(" ") - arg2 = False - arg3 = [] - for i in arg: - if arg2 == True: - arg3.append(i) - elif i.lower() == "me": - arg2 = True - arg3 = " ".join(arg3) - truesender_lower = truesender.lower() - arg3_lower = arg3.lower() - tell_checker = Namecheck.Namecheck(arg3_lower,users,truesender) - for name in replacenames.values(): - if arg3_lower == name.lower(): - tell_checker = True - break - else: - pass - if tell_checker == True: - conn.privmsg(targetchannel,sender+" : I can't call you that, I know someone else by that name") - elif len(arg3) > call_me_max_length: - conn.privmsg(targetchannel,sender+" : I cannot call you that, Too long of a name.") - pass - else: - replacenames[truesender] = arg3 - with open("replacenames.cache","w") as pickle_save: - pickle.dump(replacenames,pickle_save) - conn.privmsg(targetchannel,sender+" : Calling you "+arg3+" From now on") - else: - conn.privmsg(targetchannel,sender+" : Sorry, I am not allowed to do that.") - elif influx.split(" ")[0].lower().replace(",","").replace(".","").replace("?","").replace("!","") in SName+[lowname] and "your birthday" in influx.lower() and "is your" in influx.lower(): - conn.privmsg(targetchannel,sender+" : My birthday is on the 15th day of December.") - elif influx.split(" ")[0].lower().replace(",","") in SName+[lowname] and "version" in influx.replace("?","").replace("!","").lower().split(" "): - if debug == True: - print truesender+"::%s Version" %(Name) - conn.privmsg(targetchannel,sender+", My version is "+pregen) - elif influx.split(" ")[0].lower().replace(",","") in SName+[lowname] and influx.lower().count(" or ") > 0 and len(influx.split(" ")[1:]) <= influx.lower().count("or") * 3: - cut_down = influx.lower().split(" ") - arg = [] - count = -1 - for i in cut_down: - count += 1 - try: - if cut_down[count+1] == "or": - arg.append(i) - - except: - pass - try: - if i not in arg and cut_down[count-1] == "or": - arg.append(i) - except: - pass - try: - conn.privmsg(targetchannel,random.choice(arg).capitalize().replace("?","").replace("!","")) - except IndexError: - # arg is empty, whORe etc. - pass - elif influx.lower()[0:len(Name)] == lowname and influx.lower()[-1] == "?" and influx.count(" ") > 1 and "who started you" in influx.lower() or \ - influx.split(" ")[0].lower().replace(",","") in SName and influx.lower()[-1] == "?" and "who started you" in influx.lower(): - conn.privmsg(targetchannel,sender+" : I was started by %s"%(os.getenv("USER"))+" on "+time.strftime("%d.%m.%Y at %H:%M:%S",time.gmtime(uptime_start))) - elif influx.lower()[0:len(Name)] == lowname and influx.lower()[-1] == "?" and influx.count(" ") > 1 or \ - influx.split(" ")[0].lower().replace(",","") in SName and influx.lower()[-1] == "?" and influx.count(" ") > 1: - dice = random.randint(0,1) - if dice == 0: - conn.privmsg(targetchannel,sender+" : "+C_eightball.eightball(influx.lower(),debug,truesender,prefix)) - else: - 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 influx.lower()[0:len(Name)] == lowname and not influx.lower()[len(Name):].isalpha() or \ - influx.split(" ")[0].lower().replace(",","") in SName and not influx.lower()[len(influx.split(" ")[0].lower()):].isalpha(): - conn.privmsg(targetchannel, random.choice(["Yea?","I'm here","Ya?","Yah?","Hm?","What?","Mmhm, what?","?","What now?","How may I assist?"])) - comboer = truesender - comboer_time = time.time() - elif influx.lower()[-1] == "?" and comboer == truesender and looptime - discard_combo_messages_time < comboer_time: - comboer = "" - dice = random.randint(0,1) - if dice == 0: - conn.privmsg(targetchannel,sender+" : "+C_eightball.eightball(influx.lower(),debug,truesender,prefix)) - else: - 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 influx.lower() == prefix+"tm": - if truesender in operators and targetchannel==channel: - marakov = not marakov - conn.privmsg(targetchannel,sender+" : Marakov Output is now "+str(marakov)) - else: - conn.privmsg(targetchannel,sender+" : I can't let you access that") - elif personality_greeter == True and True in map(lambda x: x in influx.lower(),["greetings","afternoon","hi","hey","heya","hello","yo","hiya","howdy","hai","morning","mornin'","evening", "night","night", "evening","'sup","sup","hallo","hejssan"]): - if comboer != "" and looptime - discard_combo_messages_time > comboer_time: - combo_check = sbna(["greetings","afternoon","hi","hey","heya","hello","yo","hiya","howdy","hai","morning","mornin'","evening", "night","night", "evening","'sup","sup","hallo","hejssan","all night"], #ONLY ONE OF THESE - ["greetings","afternoon","hi","hey","heya","hello","yo","hiya","howdy","hai","morning","mornin'","evening", "night","night", "evening","'sup","sup","hallo","hejssan"], #ATLEAST ONE OF THESE - influx.lower()) - else: - combo_check = sbna(SName+[lowname, - #lowname+".",lowname+"!",lowname+"?", - "everybody", - #"everybody!","everybody?", - "everyone", - #"everyone!","everyone?", - "all", - #"all!","all?" - "all night", - ], #ONLY ONE OF THESE - ["greetings","afternoon","hi", - #"hi,", - "hey","heya","hello","yo","hiya","howdy","hai","morning","mornin'","evening", "night","night", "evening","'sup","sup","hallo","hejssan"], #ATLEAST ONE OF THESE - influx.lower().replace(",","").replace(".","").replace("!","")) - if combo_check: - combo_check = False - comboer = "" - if "evening" in influx.lower() and "all" in influx.lower() and len(influx.lower().split(" ")) > 3: - pass - elif truesender not in operators: - if debug: - print truesender+"::"+influx - dice = random.randint(0,19) - if dice == 0: - conn.privmsg(targetchannel,"Well hello to you too "+sender) - elif dice == 1: - if optimize_greeting == False: - hours = time.strftime("%H") - #time.strftime("%H:%M:%S") == 12:28:41 - hours = int(hours) - if hours in xrange(0,12): - conn.privmsg(targetchannel,"Good Morning "+sender) - elif hours in xrange(12,15): - conn.privmsg(targetchannel,"Good Afternoon "+sender) - elif hours in xrange(15,20): - conn.privmsg(targetchannel,"Good Evening "+sender) - else: - conn.privmsg(targetchannel,"Good Night "+sender) - else: - hours = time.strftime("%H") - hours = int(hours) - if hours in morning: - conn.privmsg(targetchannel,"Good Morning "+sender) - elif hours in afternoon: - conn.privmsg(targetchannel,"Good Afternoon "+sender) - elif hours in evening: - conn.privmsg(targetchannel,"Good Evening "+sender) - else: - conn.privmsg(targetchannel,"Good Night "+sender) - elif dice == 2: - conn.privmsg(targetchannel,"Hello!") - elif dice == 3: - conn.privmsg(targetchannel,"Hey "+sender) - elif dice == 4: - conn.privmsg(targetchannel,"Hi "+sender) - elif dice == 5: - conn.privmsg(targetchannel,"Hello "+sender) - elif dice == 6: - conn.privmsg(targetchannel,"Yo "+sender) - elif dice == 7: - conn.privmsg(targetchannel,"Greetings "+sender) - elif dice == 8: - conn.privmsg(targetchannel,"Hi") - elif dice == 9: - conn.privmsg(targetchannel,"Hi!") - elif dice == 10: - conn.privmsg(targetchannel,"Yo") - elif dice == 11: - conn.privmsg(targetchannel,"Yo!") - elif dice == 12: - conn.privmsg(targetchannel,"Heya") - elif dice == 13: - conn.privmsg(targetchannel,"Hello there!") - elif dice == 14: # Richard - conn.privmsg(targetchannel,"Statement: Greetings meatbag") - elif dice == 15: # Richard - hours = int(time.strftime("%H")) - if hours in xrange(5,12): - conn.privmsg(targetchannel,"What are you doing talking at this time of the morning?") - elif hours in xrange(12,15): - conn.privmsg(targetchannel,"What are you doing talking at this time of the day?") - elif hours in xrange(15,22): - conn.privmsg(targetchannel,"What are you doing talking at this time of the evening?") - else: - conn.privmsg(targetchannel,"What are you doing talking at this time of the night?") - elif dice == 16: # Richard - conn.privmsg(targetchannel,"Oh, you're still alive I see.") - elif dice == 17: - conn.privmsg(targetchannel,"Heya "+sender) - elif dice == 18 and time.gmtime(time.time())[1] == 12 and time.gmtime(time.time())[2] == 15: - conn.privmsg(targetchannel,"Hello! It's my birthday!") - else: - conn.privmsg(targetchannel,"Hiya "+sender) - secdice = random.randint(0,10) - if time.gmtime(time.time())[1] == 12 and time.gmtime(time.time())[2] == 15 and birthday_announced < time.gmtime(time.time())[0]: - birthday_announced = time.gmtime(time.time())[0] - conn.privmsg(channel,"Hey everybody! I just noticed it's my birthday!") - time.sleep(0.5) - tag = random.choice(["birthday","robot+birthday","happy+birthday+robot"]) - arg1 = urllib2.urlopen("http://www.youtube.com/results?search_query=%s&page=&utm_source=opensearch"%tag) - arg1 = arg1.read().split("\n") - arg2 = [] - for i in arg1: - if "watch?v=" in i: - arg2.append(i) - arg3 = random.choice(arg2) - - conn.privmsg(channel,"Here's a video of '%s' which I found! %s (%s)"%(tag.replace("+"," "),"http://www.youtube.com"+arg3[arg3.find('/watch?v='):arg3.find('/watch?v=')+20],YTCV2("http://www.youtube.com"+arg3[arg3.find('/watch?v='):arg3.find('/watch?v=')+20]))) - if truesender.lower() in tell_list.keys(): - try: - conn.privmsg(channel, "Also, "+truesender+" : "+tell_list[truesender.lower()][0]) - del(tell_list[truesender.lower()][0]) - except: - pass - else: - dice = random.randint(0,1) - if dice == 0: - conn.privmsg(targetchannel,"Greetings Master "+sender) - elif dice == 1: - conn.privmsg(targetchannel,"My deepest greetings belong to you, Master "+sender) - ### IMPORTANT ### - elif influx == "☺VERSION☺": - conn.notice(truesender,"\001VERSION nanotrasen:2:Python 2.6\001") - elif marakov and influx.lower() == prefix+"marakov": - arg = Marakov_Chain.form_sentence() - if len(arg) < 5: - conn.privmsg(targetchannel,sender+" : Not enough words harvested") - else: - conn.privmsg(targetchannel,sender+" : %s" %(" ".join(arg).capitalize())) - elif marakov and cocheck( prefix+ "marakov"): - try: - arg = influx.split(" ")[1].lower() - except: - conn.privmsg(targetchannel,sender+" : Please input a valid second argument") - else: - arg2 = Marakov_Chain.form_sentence(arg) - if len(arg2) < 5: - conn.privmsg(targetchannel,sender+" : Not enough words harvested for a sentence starting with %s" %(arg)) - else: - conn.privmsg(targetchannel,sender+" : %s" %(" ".join(arg2).capitalize())) - else: - Marakov_Chain.give_data(influx) - autodiscusscurtime = backup - if time.time() - looptime == 0: - pass - else: - print "Took",time.time()-looptime,"Seconds to finish loop" - - elif data [ 1 ] [ 0 ] == '353': - if connected == False: - connected = True - users = map(lambda x: x[1:] if x[0] == "+" or x[0] == "@" else x,data[1][4].split(" ")) - print "There are",len(users),"Users on",channel - operators = [] - for potential_operator in data[1][4].split(" "): - if potential_operator[0] == "@": - operators.append(potential_operator[1:]) - elif potential_operator[0] == "%": - halfoperators.append(potential_operator[1:]) - - elif data[1][0] == "QUIT": - sender = data[0].split("!")[0] - print sender+" Has now left the server" - try: - users.remove(sender) - try: - operators.remove(sender) - except ValueError: - pass - try: - halfoperators.remove(sender) - except ValueError: - pass - except ValueError: - pass - elif data[1][0] == "PART": - sender = data[0].split("!")[0] - targetchannel = data[1][1] - print sender+" Has now parted from the channel" - try: - users.remove(sender) - try: - operators.remove(sender) - except ValueError: - pass - try: - halfoperators.remove(sender) - except ValueError: - pass - except ValueError: - pass - elif data[1][0] == "JOIN": - sender = data[0].split("!")[0] - targetchannel = data[1][1] - if sender.lower() in tell_list.keys(): - try: - conn.privmsg(targetchannel, sender+" : "+" | ".join(tell_list[sender.lower()])) - del(tell_list[sender.lower()]) - except: - pass - for useri,nicki in replacenames.items(): - checkers = Namecheck.Namecheck_dict(sender.lower(),replacenames) - if checkers[0]: - try: - if checkers[0].lower() == sender: - pass - else: - conn.privmsg(targetchannel,checkers[1]+" : I have detected a collision with a name I call you and %s who joined" %(sender)) - del(replacenames[checkers[1]]) - with open("replacenames.cache","w") as pickle_save: - pickle.dump(replacenames,pickle_save) - except AttributeError: - #conn.privmsg(channel,"NAME COLLISION CHECK ERROR, RELATED TO %s" %(sender)) - print "NAME COLLISION CHECK ERROR, RELATED TO %s" %(sender) - break - print sender+" Has now joined" - users.append(sender) - ##### - if ".fi" in data[0] and sender.lower() == "skibiliano": - operators.append(sender) - if sender.lower() not in peopleheknows[0]: - if data[0].split("!")[1] in peopleheknows[1]: - appendion = "...you do seem familiar however" - else: - appendion = "" - if data[1][1].lower() == channel or data[1][1].lower() == channel[1:]: - conn.privmsg(data[1][1],CORE_DATA.greeting.replace("USER",sender)+" "+appendion) - else: - conn.privmsg(data[1][1],"Hello! Haven't seen you here before! Happy to meet you! %s" %(appendion)) - peopleheknows[0].append(sender.lower()) - peopleheknows[1].append(data[0].split("!")[1]) - with open("peopleheknows.cache","w") as peoplehecache: - pickle.dump(peopleheknows,peoplehecache) - - elif data[1][0] == "MODE" and data[1][2] == "+o": - sender = data[1][3] - targetchannel = data[1][1] - if targetchannel == channel: - print sender+" Is now an operator on the main channel" - operators.append(sender) - else: - print sender+" Is now an operator" - elif data[1][0] == "MODE" and data[1][2] == "-o": - sender = data[1][3] - targetchannel = data[1][1] - if targetchannel == channel: - print sender+" Is no longer an operator on the main channel" - else: - print sender+" Is no longer an operator" - try: - operators.remove(sender) - except ValueError: - pass - elif data[1][0] == "MODE" and data[1][2] == "+h": - sender = data[1][3] - print sender+" Is now an half operator" - halfoperators.append(sender) - elif data[1][0] == "MODE" and data[1][2] == "-h": - try: - halfoperators.remove(sender) - except ValueError: - pass - elif data[1][0] == "MODE" and data[1][1] == Name: - print "My mode is",data[1][2] - elif data[1][0] == "MODE" and data[1][1] != Name: - try: - sender = data[1][3] - print sender,"Was modified",data[1][2] - except IndexError: - print "SENDER RETRIEVAL FAILED:"+str(data) - elif data[1][0] == "KICK" and data[1][2] == Name: - disconnects = 99999 - print "I have been kicked! Disconnecting entirely!" - conn.quit() - elif data[1][0] == "KICK": - # data[1][0] = Kick, 1 = Channel, 2 = Who, 3 = Who(?) - print data[1][2]+" got kicked!" - elif data[1][0] == "451" and data[1][2] == "You have not registered": - print Name+" hasn't been registered" - elif data[1][0] == "NOTICE": - sender = data[0].split("!")[0] - print "NOTICE (%s): %s" %(sender,data[1][2]) - pongtarget = sender - elif data[1][0] == "NICK": - origname = data[0].split("!")[0] - newname = data[1][1] - print origname,"Is now",newname - if newname.lower() in tell_list.keys(): - try: - conn.privmsg(channel, newname+" : "+tell_list[newname.lower()][0]) - del(tell_list[newname.lower()][0]) - except: - pass - try: - users.remove(origname) - except ValueError: - pass - else: - users.append(newname) - try: - operators.remove(origname) - except ValueError: - pass - else: - operators.append(newname) - try: - halfoperators.remove(origname) - except ValueError: - pass - else: - halfoperators.append(newname) - - elif data[1][0] == "001": - # Skibot is welcomed to the Network - pass - elif data[1][0] == "002": - # Your host is... - pass - elif data[1][0] == "003": - #Server was created... - pass - elif data[1][0] == "004": - #Weird hex? - pass - elif data[1][0] == "005": - #Settings like NICKLEN and so on. - pass - elif data[1][0] == "250": - #data[1][2] is - #"Highest connection count: 1411 (1410 clients) - #(81411 connections received)" - pass - elif data[1][0] == "251": - #There are 23 users and 2491 invisible on 10 servers - pass - elif data[1][0] == "252": - #IRC Operators online - #data[1][2] - print data[1][2],"Irc operators online" - pass - elif data[1][0] == "253": - # ['253', 'Skibot_V4', '1', 'unknown connection(s)'] - print data[1][2],"Unknown connection(s)" - pass - elif data[1][0] == "254": - #1391 channels formed - pass - elif data[1][0] == "255": - #I have 406 clients and 2 servers - pass - elif data[1][0] == "265": - #data[1][2] current local users - #data[1][3] at max - try: - print "Current local users:", data[1][2],"/",data[1][3] - except IndexError: - print "Couldn't retrieve local users" - pass - elif data[1][0] == "266": - #data[1][2] current global users - #data[1][3] at max - try: - print "Current global users:", data[1][2],"/",data[1][3] - except IndexError: - print "Couldn't retrieve global users" - pass - elif data[1][0] == "315": - #End of /who list - pass - elif data[1][0] == "332": - # Topic of channel - topic = data[1][3] - pass - elif data[1][0] == "333": - # *Shrug* - pass - elif data[1][0] == "352": - #WHO command - - if len(targetlist) > 0: - if targetlist[0][0].lower() in data[1][6].lower(): - thread.start_new_thread(target,("*!*@"+data[1][4],targetlist[0][1])) - print "Created a thread with", "*!*@"+data[1][4],targetlist[0][1] - targetlist.pop(0) - else: - print targetlist[0][0].lower(), "isn't equal to?", data[1][6].lower() - print targetlist - - elif data[1][0] == "366": - # End of USERS - pass - elif data[1][0] == "372": - # Server information - pass - elif data[1][0] == "375": - # Message of the day - pass - elif data[1][0] == "376": - # End of motd - pass - elif data[1][0] == "401": - # ('network', ['401','Botname','Channel / Nick','No such nick/channel']) - print data[1][2] + " Channel does not exist" - pass - elif data[1][0] == "439": - # ('irc.rizon.no', ['439', '*', 'Please wait while we process your connection.']) - pongtarg = data[0][0] - elif data[1][0] == "477": - # You need to be identified - #TAG - conn.privmsg("nickserv","identify %s"%CORE_DATA.le_pass) - time.sleep(0.5) - conn.join(data[1][2]) - #('network', ['477', 'botname', '#channel', 'Cannot join channel (+r) - you need to be identified with services']) - - elif data[1][0] == "433": - # Skibot name already exists. - print Name+" name already exists." - Name += "_"+version - print "New name:",Name - duplicate_notify = True - conn = irchat.IRC ( Network, Port, Name, "NT_"+version, "NT_"+version, "Trasen_"+version ) - for i in CORE_DATA.channels: - conn.join(i) - sleep(0.5) - elif data[1][0] == "482": - sleep(0.05) - conn.privmsg(targetchannel,"Nevermind that, I am not an operator") - CALL_OFF = True - elif data[1] == ["too","fast,","throttled."]: - print "Reconnected too fast." - print "Halting for 2 seconds" - sleep(2) - elif data[1][0] == "Link": - if data[0] == "Closing": - print "Link was closed" - connected = False -# conn.quit() -# break - else: - print data - print data[1][0] - pass - else: - if disconnects > 9000: #IT'S OVER NINE THOUSAAAAND! - break - else: #WHAT NINE THOUSAND? THERE'S NO WAY THAT CAN BE RIGHT - sleep(responsiveness_delay) #WAIT A WHILE AND CHECK AGAIN! - try: - if not connected: - #print pongtarget - #print conn.addressquery() - conn.privmsg(pongtarget,"Pong") - sleep(1) - for i in CORE_DATA.channels: - conn.join(i) - sleep(0.5) - print "Attempted to join" - connected = True - except ValueError: - try: - conn.privmsg(conn.addressquery()[0],"Pong") - sleep(1) - for i in CORE_DATA.channels: - conn.join(i) - sleep(0.5) - print "Attempted to join the second time" - connected = True - except ValueError: - print "Both methods failed" - except AttributeError: - print "Conn is not established correctly" - except NameError: - print "Pongtarget isn't yet established" - try: - conn.privmsg(conn.addressquery()[0],"Pong") - sleep(1) - for i in CORE_DATA.channels: - conn.join(i) - sleep(0.5) - print "Attempted to join the second time" - connected = True - except: - print "Both methods failed" diff --git a/bot/Shortname.py b/bot/Shortname.py deleted file mode 100644 index ae8ac473b85..00000000000 --- a/bot/Shortname.py +++ /dev/null @@ -1,28 +0,0 @@ -def shortname(name): - lowname = name.lower() - numb = 0 - count = 0 - spot = 0 - for letter in name: - if letter.isupper(): - spot = numb - count += 1 - numb += 1 - if "_" in name: - if name.count("_") > 1: - name = " ".join(name.split("_")[0:name.count("_")]) - if name.lower()[-3:] == "the": - return name[:-4] - else: - return name - else: - return name.split("_")[0] - if count > 1: - if len(name[0:spot]) > 2: - return name[0:spot] - if len(name) < 5: - return name #Too short to be shortened - elif "ca" in lowname or "ct" in lowname or "tp" in lowname or "lp" in lowname: - return name[0:max(map(lambda x: lowname.find(x),["ca","ct","tp","lp"]))+1] - else: - return name[0:len(name)/2+len(name)%2] diff --git a/bot/Timeconverter.py b/bot/Timeconverter.py deleted file mode 100644 index a39f821c846..00000000000 --- a/bot/Timeconverter.py +++ /dev/null @@ -1,204 +0,0 @@ -#Sources: -# http://wwp.greenwichmeantime.com/time-zone/usa/eastern-time/convert/ -# http://www.timeanddate.com/library/abbreviations/timezones/na/ -# Times are GMT +- x -# For eq. -# EST = -5 -# GMT = 0 -# UTC = 0 -#Times are in hours, -#2.5 = 2 and half hours -global times -times = {"ADT":-3,"HAA":-3, #Synonyms on the same line - "AKDT":-8,"HAY":-8, - "AKST":-9,"HNY":-9, - "AST":-4,"HNA":-4, - "CDT":-5,"HAC":-5, - "CST":-6,"HNC":-6, - "EDT":-4,"HAE":-4, - "EGST":0, - "EGT":-1, - "EST":-5,"HNE":-5,"ET":-5, - "HADT":-9, - "HAST":-10, - "MDT":-6,"HAR":-6, - "MST":-7,"HNR":-7, - "NDT":-2.5,"HAT":-2.5, - "NST":-3.5,"HNT":-3.5, - "PDT":-7,"HAP":-7, - "PMDT":-2, - "PMST":-3, - "PST":-8,"HNP":-8,"PT":-8, - "WGST":-2, - "WGT":-3, - "GMT":0, - "UTC":0} -def converter(zones,time): - #Zones should be a list containing - # ( From zone - # To zone ) - global times - #from_z = for example UTC+00:00, WGT or GMT-05:30 - #to_z = same style as above. - from_z,to_z = zones - from_z = from_z.upper() - to_z = to_z.upper() - if from_z.find("+") != -1: - from_zone_offset = from_z[from_z.find("+"):] - if ":" in from_zone_offset: - try: - from_zone_offset1,from_zone_offset2 = from_zone_offset.split(":") - except ValueError: - return "Too many or too small amount of values" - try: - from_zone_offset = int(from_zone_offset1) + int(from_zone_offset2)/60.0 - except: - return "Error, the 'From Zone' variable has an incorrect offset number" - else: - try: - from_zone_offset = float(from_zone_offset) - except: - return "Error, the 'From Zone' variable has an incorrect offset number" - try: - from_zone_realtime = from_zone_offset + times[from_z[:from_z.find("+")]] - except KeyError: - return "Incorrect From zone" - - elif "-" in from_z: - from_zone_offset = from_z[from_z.find("-"):] - if ":" in from_zone_offset: - from_zone_offset1,from_zone_offset2 = from_zone_offset.split(":") - try: - from_zone_offset = -int(from_zone_offset1) + int(from_zone_offset2)/60.0 - except: - return "Error, the 'From Zone' variable has an incorrect offset number" - else: - try: - from_zone_offset = -float(from_zone_offset) - except: - return "Error, the 'From Zone' variable has an incorrect offset number" - from_zone_realtime = times[from_z[:from_z.find("-")]] - from_zone_offset - pass - else: - from_zone_offset = 0 - try: - from_zone_realtime = from_zone_offset + times[from_z] - except KeyError: - return "Incorrect From zone" - if to_z.find("+") != -1: - to_zone_offset = to_z[to_z.find("+"):] - if ":" in to_zone_offset: - try: - to_zone_offset1,to_zone_offset2 = to_zone_offset.split(":") - except ValueError: - return "Too many or too small amount of values" - try: - to_zone_offset = int(to_zone_offset1) + int(to_zone_offset2)/60.0 - except: - return "Error, the 'To Zone' variable has an incorrect offset number" - else: - try: - to_zone_offset = float(to_zone_offset) - except: - return "Error, the 'To Zone' variable has an incorrect offset number" - try: - to_zone_realtime = to_zone_offset + times[to_z[:to_z.find("+")]] - except KeyError: - return "The zone you want the time to be changed to is not found" - - elif "-" in to_z: - to_zone_offset = to_z[to_z.find("-"):] - if ":" in to_zone_offset: - to_zone_offset1,to_zone_offset2 = to_zone_offset.split(":") - try: - to_zone_offset = -int(to_zone_offset1) + int(to_zone_offset2)/60.0 - except: - return "Error, the 'To Zone' variable has an incorrect offset number" - else: - try: - to_zone_offset = -float(to_zone_offset) - except: - return "Error, the 'To Zone' variable has an incorrect offset number" - to_zone_realtime = times[to_z[:to_z.find("-")]] -to_zone_offset - - pass - else: - to_zone_offset = 0 - try: - to_zone_realtime = to_zone_offset + times[to_z] - except KeyError: - return "Incorrect To zone" - try: - time_hour,time_minute = time.split(":") - time_hour,time_minute = int(time_hour),int(time_minute) - string = ":" - except: - try: - time_hour,time_minute = time.split(".") - time_hour,time_minute = int(time_hour),int(time_minute) - string = "." - except ValueError: - return "The time was input in an odd way" - if to_zone_realtime % 1.0 == 0.0 and from_zone_realtime % 1.0 == 0.0: - time_hour = time_hour + (to_zone_realtime - from_zone_realtime) - return str(int(time_hour))+string+str(int(time_minute)) - else: - if to_zone_realtime % 1.0 != 0.0 and from_zone_realtime % 1.0 != 0.0: - time_minute = time_minute + (((to_zone_realtime % 1.0) * 60) - ((from_zone_realtime % 1.0) * 60)) - elif to_zone_realtime % 1.0 != 0.0 and from_zone_realtime % 1.0 == 0.0: - time_minute = time_minute + (((to_zone_realtime % 1.0) * 60) - 0) - elif to_zone_realtime % 1.0 == 0.0 and from_zone_realtime % 1.0 != 0.0: - time_minute = time_minute + (0 - ((from_zone_realtime % 1.0) * 60)) - else: - print "Wut?" - time_hour = time_hour + (int(to_zone_realtime//1) - int(from_zone_realtime//1)) - return str(int(time_hour))+string+str(int(time_minute)) - - -def formatter(time): - if "." in time: - string = "." - elif ":" in time: - string = ":" - else: - return time - hours,minutes = time.split(string) - days = 0 - if int(minutes) < 0: - buphours = int(hours) - hours,minutes = divmod(int(minutes),60) - hours += buphours - if int(minutes) > 60: - hours,minutes = divmod(int(minutes),60) - hours += int(hours) - if int(hours) < 0: - days = 0 - days,hours = divmod(int(hours),24) - if int(hours) > 24: - days = 0 - days,hours = divmod(int(hours),24) - if int(hours) == 24 and int(minutes) > 0: - days += 1 - hours = int(hours) - 24 - hours = str(hours) - minutes = str(minutes) - if len(minutes) == 1: - minutes = "0"+minutes - if len(hours) == 1: - hours = "0"+hours - if days > 0: - if days == 1: - return hours+string+minutes+" (Tomorrow)" - else: - return hours+string+minutes+" (After "+str(days)+" days)" - elif days < 0: - if days == -1: - return hours+string+minutes+" (Yesterday)" - else: - return hours+string+minutes+" ("+str(abs(days))+" days ago)" - return hours+string+minutes - - - - - diff --git a/bot/Weather.py b/bot/Weather.py deleted file mode 100644 index 1fb786e8f4f..00000000000 --- a/bot/Weather.py +++ /dev/null @@ -1,61 +0,0 @@ -# -*- coding: cp1252 -*- -import urllib,xml.sax.handler -# S10 COMPATIABLE -def message(data): - if data["type"] == "PRIVMSG": - try: - splitdata = data["content"].lower().split(" ") - if splitdata[0] == ":weather" and len(splitdata) > 1: - data = Weather(" ".join(splitdata[1:])) - - data["conn"].privmsg(data["target"],"Weather for "+data[1]+": "+data[0]) - return True - except KeyError: - print "WUT" - else: - return -1 -def Weather(question): - question = question.replace("ä","a") - url = "http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query="+question - opener = urllib.FancyURLopener({}) - f = opener.open(url) - data = f.read() - f.close() - bufferi = [] - seen = False - for i in data.split("\n"): - if "" in i: - stuff = cutter(i,"") - if len(stuff) > 7: - bufferi.append("Temperature: "+stuff) - elif "" in i: - stuff = cutter(i,"") - if len(stuff) > 19: - bufferi.append(stuff) - elif "" in i: - stuff = cutter(i,"") - if len(stuff) > 0: - bufferi.append("Weather: "+stuff) - elif "" in i: - stuff = cutter(i,"") - if len(stuff) > 0: - bufferi.append("Humidity: "+stuff) - elif "" in i: - stuff = cutter(i,"") - if len(stuff) > 0: - bufferi.append("Wind blows "+stuff) - elif "" in i: - stuff = cutter(i,"") - if len(stuff) > 9: - bufferi.append("Air pressure is "+stuff) - elif "" in i and seen == False: - seen = True - where = cutter(i,"") - if len(where) == 4: - where = "Location doesn't exist" - return [", ".join(bufferi),where] -def cutter(fullstring,cut): - fullstring = fullstring.replace(cut,"") - fullstring = fullstring.replace(" 11: #Longer than normal, presume troll. - youtube_url.replace(cut_down,cut_down[:11]) - elif len(cut_down) < 11: #Shorter than normal - pass - except IndexError: - return "Reflex: Where's the watch?v=?" - first_two = cut_down[0:2] - try: - if no_absolute_paths: - tiedosto = open("YTCache/"+first_two+".tcc","r") - else: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","r") - except: - prev_dict = {} - else: - try: - prev_dict = pickle.load(tiedosto) - except EOFError: # Cache is corrupt - os.remove(directory+tiedosto.name) - print "REMOVED CORRUPT CACHE: "+tiedosto.name - prev_dict = {} - tiedosto.close() # I think this should belong here. - if cut_down in prev_dict.keys(): - return prev_dict[cut_down] - else: - pass - try: - if no_absolute_paths: - tiedosto = open("YTCache/"+first_two+".tcc","w") - else: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","w") - except IOError,error: - if len(prev_dict.keys()) > 0: - try: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","w") #This is a Just In Case - except IOError: - if did_tell == False: - did_tell = True - return "COULD NOT ACCESS FILE "+first_two+".tcc! The next time you run this link, it checks it through the web" - Do_not_open = False - else: - did_tell = False - pickle.dump(prev_dict,tiedosto) - tiedosto.close() - else: - pass - return "Very odd error occurred: " + str(error) - youtube_url = youtube_url.replace("http//","http://") - if youtube_url.lower()[0:7] != "http://" and youtube_url[0:4] == "www.": - youtube_url = "http://" + youtube_url - if youtube_url.count("/") + youtube_url.count("\\") < 3: - if len(prev_dict.keys()) > 0: - if Do_not_open == True: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","w") #This is a Just In Case - pickle.dump(prev_dict,tiedosto) - tiedosto.close() - else: - pass - return "Reflex: Video cannot exist" - else: - if "http://" in youtube_url[0:12].lower() and youtube_url[0:7].lower() != "http://": - youtube_url = youtube_url[youtube_url.find("http://"):] - elif youtube_url[0:7].lower() != "http://": - if len(prev_dict.keys()) > 0: - if Do_not_open == True: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","w") #This is a Just In Case - pickle.dump(prev_dict,tiedosto) - tiedosto.close() - return "Reflex: Incorrect link start" - if "?feature=player_embedded&" in youtube_url: - youtube_url = youtube_url.replace("?feature=player_embedded&","?") - try: - website = urlopen(youtube_url) - except: - if len(prev_dict.keys()) > 0: - if Do_not_open == True: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","w") #This is a Just In Case - pickle.dump(prev_dict,tiedosto) - tiedosto.close() - else: - pass - return "Reflex: Incorrect link!" - for i in website.readlines(): - if i.count('',contentvar)] - if "&quot;" in result: - result = result.replace("&quot;",'"') - else: - pass - if "&amp;" in result: - result = result.replace("&amp;","&") - else: - pass - if "&#39;" in result: - result = result.replace("&#39;","'") - else: - pass - if Do_not_open == True: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","w") #This is a Just In Case - prev_dict[cut_down] = result - pickle.dump(prev_dict,tiedosto) - tiedosto.close() - return result - if Do_not_open == True: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","w") #This is a Just In Case - prev_dict[cut_down] = "No title for video, Removed / Needs Age verification / Does not exist" - pickle.dump(prev_dict,tiedosto) - tiedosto.close() - return "No title for video, Removed / Needs age verification / Does not exist" diff --git a/bot/_____Readme.txt b/bot/_____Readme.txt deleted file mode 100644 index 1c56f9ad128..00000000000 --- a/bot/_____Readme.txt +++ /dev/null @@ -1,74 +0,0 @@ -/// Adminhelp relay IRC bot setup guide -/// CC_Nanotrasen bot created by Skibiliano and distributed under the CC-BY-SA 3.0 license -/// All derivative works of this bot must properly credit Skibiliano as the original author -/// Big thanks to Skibiliano his bot and allowing distribution, and to BS12 for sharing their code for making use of it ingame - -QUESTION: What does this bot do? -ANSWER: It, in conjunction with BYOND, relays adminhelps to a designated channel, along with various extra functions that can be accessed by saying !help in the same channel/in a query with the bot. - -Some basic info before you set this up: -CC_Nanotrasen is coded in python 2.6 and requires a serverside installation of python 2.6 (obtainable at http://www.python.org/getit/releases/2.6/) -- Python MUST BE installed to the same directory as the .dmb you are using to host your server/server config folder -- CC_Nanotrasen supports, but does not require, Psyco (obtainable at http://psyco.sourceforge.net/download.html) which increases the speed 20-30% and slightly increases RAM usage - -Now that that's out of the way, I'll teach you how to set this up. - -BOT CONFIG: -Move everything in this folder (this file noninclusive) to the same folder as the hosting server (where your .dmb, config folder, and python are installed) -Open CORE_DATA.py with a text editor of your choice (recommended to be notepad++ or notepad) -You should see 14 lines of code which look like - Name = "CC_NanoTrasen" #The name he uses to connect - no_absolute_paths = True #Do not change this. - debug_on = False - SName = ["cc","nt","trasen","nano","nanotrasen"] #Other names he will respond to, must be lowercase - DISABLE_ALL_NON_MANDATORY_SOCKET_CONNECTIONS = False - directory = "BOT DIRECTORY GOES HERE/" #make sure to keep the "/" at the end - version = "TG CC-BY-SA 6" - Network = 'irc.server.goes.here' #e.g. "irc.rizon.net" - channel = "#CHANNEL GOES HERE" #what channel you want the bot in - channels = ["#CHANNEL GOES HERE","#ALSO ANOTHER CHANNEL GOES HERE IF YOU WANT"] #same as above - greeting = "Welcome!" #what he says when a person he hasn't seen before joins - prefix = "!" #prefix for bot commands - Port = 7000 -There are some basic comments besides every important config option in here, but I'll summarize them in detail -NAME - The name the bot assumes when it connects to IRC, so in this example it would join the IRC under the nickname "CC_Nanotrasen" -SNAME - A list of secondary names, with commas, that the bot will respond to for commands (for example, this setup will allow the bot to respond to "nt, tell quarxink he's a terrible writer") -DIRECTORY - The directory of the bot files, dmb, python, and config folder IN FORWARD SLASHES, WITH FORWARD SLASH AT THE END(for example, I host my test server from "c:\tgstation\tgstation13\tgstation.dmb" so for me the line would say directory = "c:/tgstation/tgstation13/") -NETWORK - The IRC server it will connect to, such as "irc.rizon.net" -CHANNEL/CHANNELS - what channel the bot will join (channels allows for multiple channel connections, in the same formatting as SName separates nicknames) -GREETING - CC_Nanotrasen will store the names of people it has seen before, but when a nickname joins that it hasn't seen before it will greet that person with whatever message is put in this -PREFIX = What character/string will be placed before commands for the bot (so if you changed this to "$", you would pull up the bot's help menu by saying $help instead of !help) -PORT - What port to connect to for the IRC server (if you are unsure of what port to use, most IRC clients will show you what port you are connecting to) - -Once you have that ready, you're on to step two. -Open up the config folder in your install dir, and open config.txt -Scroll to the bottom, right below #FORBID_SINGULO_POSSESSION should be - ##Remove the # mark if you are going to use the SVN irc bot to relay adminhelps - #USEIRCBOT -Just remove the "#" in front of USEIRCBOT (you don't even have to recompile your DMB! - -Got that all ready to go? Good, it's time for step three. -Open Dream Daemon (that thing you use when you host) -On the bottom of the window you should see port, security, and visibility. -Change security to "Trusted" - -Congratulations, you've set up this bot! -A few things to note as far as features: -Use !help to list most commands for the bot. -You can leave notes for other users! Just say "[bot name], tell [other user's name] [message]" - So let's say you wonder if I'm going to jump in to your IRC ever and you want to tell me this readme was horrible, you would say "Nano, tell Quarxink Your readme was horrible" - -TROUBLESHOOTING: -Attempting to run the bot gives me an error about encoding.utf-8. - You've probably installed python to a separate folder than the bot/server, move python's files over and it should run fine - -It's telling me connection refused when someone adminhelps. - You've moved the bot to a separate folder from the nudge script, most likely. - -BYOND asks me on any restart if I want to allow nudge.py to run. - Set security to trusted in Dream Daemon - - - - -If you have any requests, suggestions, or issues not covered by this guide, I can be contacted as Quarxink at #coderbus on irc.rizon.net (If I don't respond, leave me a query with your problem and how to reach you [preferably an email address, steam, other irc channel, or aim/msn]) \ No newline at end of file diff --git a/bot/borealis/bot.py b/bot/borealis/bot.py new file mode 100644 index 00000000000..d559566c1a1 --- /dev/null +++ b/bot/borealis/bot.py @@ -0,0 +1,499 @@ +import discord +import socket +import logging +import yaml +import os.path +import struct +import random +import pickle +import _thread +from urllib import parse + +class DiscordBot(discord.Client): + def __init__(self, config, **kwargs): + super(DiscordBot, self).__init__(**kwargs) + + self.read_config(config) + self.listening = False + + def run(self): + self.login(self.credentials['email'], self.credentials['password']) + logging.info("Starting bot.") + + super(DiscordBot, self).run() + + def on_ready(self): + logging.info("Bot ready and running.") + logging.info("Logged in as: {0}.".format(self.user.name)) + self.do_greeting(None) + + _thread.start_new_thread(self.receive_nudges, ()) + + def on_message(self, msg): + words = msg.content.split(' ') + + if words[0] == None: + return + + if words[0][0] == "!": + self.do_command(msg, words) + + return + + def read_config(self, config_path): + if os.path.isfile(config_path) == False: + raise Exception("Invalid config path.") + + logging.info("Reading config from file: {0}.".format(config_path)) + with open(config_path, 'r') as f: + config = yaml.load(f) + + self.last_config = config_path + + self.credentials = config['credentials'] + self.channels = config['channels'] + + self.allow_everyone = config['allow_everyone'] + self.allow_nudging = config['allow_nudging'] + self.nudge_config = config['nudge_config'] + + self.greeting = config['greeting'] + + self.server_info = config['server_info'] + + self.commands = config['commands'] + + self.authorization = config['authorization'] + + def do_greeting(self, channel): + if self.greeting == None or self.greeting == "": + return + + if channel != None: + self.send_message(channel, self.greeting) + else: + self.forward_message("lobby", self.greeting) + + def check_authorization(self, user, required_access): + if required_access == None or isinstance(user, discord.Member) == False: + return False + + for role in user.roles: + if role.name.lower() in self.authorization['admin']: + return True + + if required_access == 1 and role.name.lower() in self.authorization['mod']: + return True + + if required_access == 2 and role.name.lower() in self.authorization['cciaa']: + return True + + return False + + def do_command(self, msg, words): + command = words[0][1:].lower() + response = None + + if command in self.commands['admin_commands'] or command in self.commands['cciaa_commands'] or command in self.commands['mod_commands']: + authorization = 1 + + if command in self.commands['cciaa_commands']: + authorization = 2 + elif command in self.commands['admin_commands']: + authorization = 3 + + if self.check_authorization(msg.author, authorization) == False: + self.send_message(msg.channel, "Error: you lack authorization to use this command.") + return + + #General commands + if command == "help": + response = "```-----------BOREALIS Directives-----------\n" + for sorted_command in sorted(self.commands['public_commands'].keys()): + response += "[+] !{0} - {1}\n".format(sorted_command, self.commands['public_commands'][sorted_command]) + + response += "----------------------------------------```" + elif command == "helpadmin" or command == "helpmod" or command == "helpcciaa": + use_list = "admin_commands" + if command == "helpmod": + use_list = "mod_commands" + elif command == "helpcciaa": + use_list = "cciaa_commands" + + response = "```-------------Restricted Commands-------------\n" + response += "These commands have mark-up syntax! Replace all [placeholders] with pure text, no brackets needed!\n" + response += "Note that these commands are authorized based on your chat server role! If you do not have authorization, you will be informed as such and the command will fail!\n" + response += "----------------------------------------\n" + for sorted_command in sorted(self.commands[use_list].keys()): + response += "[+] !{0} - {1}\n".format(sorted_command, self.commands[use_list][sorted_command]) + + response += "----------------------------------------```" + elif command == "greet": + self.do_greeting(msg.channel) + elif command == "mentionstatus": + response = "I will use the everyone-mention." + if self.allow_everyone == False: + response = "I will not use the everyone-mention." + + response = "{0} - {1}".format(msg.author.mention(), response) + elif command == "nudgestatus": + response = "I am actively receiving nudges." + if self.allow_nudging == False: + response = "I am not receiving nudges." + + response = "{0} - {1}".format(msg.author.mention(), response) + elif command == "playercount": + count = self.ping_server(b"players") + + if count == None: + response = "{0} - Sorry! I was unable to ping the server!".format(msg.author.mention()) + else: + response = "{0} - There are {1} players on the server.".format(msg.author.mention(), count) + elif command == "admincount": + count = self.ping_server(b"admins") + + if count == None: + response = "{0} - Sorry! I was unable to ping the server!".format(msg.author.mention()) + else: + response = "{0} - There are {1} admins and mods on the server.".format(msg.author.mention(), count) + elif command == "cciaacount": + count = self.ping_server(b"cciaa") + + if count == None: + response = "{0} - Sorry! I was unable to ping the server!".format(msg.author.mention()) + else: + response = "{0} - There are {1} duty officers on the server.".format(msg.author.mention(), count) + elif command == "gamemode": + gamemode = self.ping_server(b"gamemode") + + if gamemode == None: + response = "{0} - Sorry! I was unable to ping the server!".format(msg.author.mention()) + else: + response = "{0} - The current gamemode is {1}.".format(msg.author.mention(), gamemode) + elif command == "manifest": + server_reply = self.ping_server(b"manifest") + + if server_reply == None: + response = "{0} - Sorry! I was unable to ping the server!".format(msg.author.mention()) + elif isinstance(server_reply, str): + response = "{0} - The server replied with this: {1}.".format(msg.author.mention(), server_reply) + else: + response = "Current crew manifest:\n\n```\n" + for key in sorted(server_reply.keys()): + response += "{0}:\n".format(key.upper()) + + for chunk in server_reply[key].split('&'): + chunk = chunk.replace("+", " ") + dat = chunk.split('=') + if len(dat) == 2: + response += "{0} as {1}\n".format(parse.unquote(dat[0]), parse.unquote(dat[1])) + response += "\n\n" + response += "```" + elif command == "who": + server_reply = self.ping_server(b"who") + + if server_reply == None: + response = "{0} - Sorry! I was unable to ping the server!".format(msg.author.mention()) + else: + response = "Current player list:\n\n```\n" + for value in server_reply.split('&'): + response += value + response += "\n" + response += "```" + + #Authorized commands: + elif command == "togglenudges": + self.allow_nudging = not self.allow_nudging + + if self.allow_nudging == True: + response = "{0} - Nudge receiver now accepts connections. Now forwarding messages from within the game.".format(msg.author.mention()) + else: + response = "{0} - Nudge receiver no longer accepting connections. No longer forwarding messages from within the game.".format(msg.author.mention()) + elif command == "togglementions": + self.allow_everyone = not self.allow_everyone + + if self.allow_everyone == True: + response = "{0} - Now mentioning everyone when needed.".format(msg.author.mention()) + else: + response = "{0} - No longer mentioning everyone in my messages.".format(msg.author.mention()) + elif command == "refreshconfig": + response = "{0} - Config refreshed, as per your request.".format(msg.author.mention()) + try: + self.read_config(self.last_config) + except Exception as e: + response = "{0} - error refreshing config: {1}".format(msg.author.mention(), e) + elif command == "adminmsg": + if len(words) < 3: + response = "Not enough arguments passed! Couldn't execute the command." + else: + message = "" + i = 2 + while i < len(words): + message += words[i] + + if i < len(words) - 1: + message += "+" + + i += 1 + + to_send = "adminmsg={0}&key={1}&sender={2}&msg={3}".format(words[1], self.server_info["key"], msg.author.name, message) + + server_reply = self.ping_server(bytes(to_send, "utf-8")) + + if server_reply == None: + response = "Sorry! I couldn't execute the command for whatever reason!" + else: + response = "Got a reply back from the server! '{0}'".format(server_reply) + elif command == "mute": + if len(words) < 2: + response = "Not enough argumetns passed! Couldn't execute the command." + else: + server_reply = self.ping_server(bytes("mute={0}&admin={1}&key={2}".format(words[1], msg.author.name, self.server_info["key"]), "utf-8")) + + if server_reply == None: + response = "Sorry! I couldn't execute the command for whatever reason!" + else: + response = "Got a reply back from the server! '{0}'".format(server_reply) + elif command == "restartserver": + logging.info("Server restart command issued by {0}.".format(msg.author.name)) + server_reply = self.ping_server(bytes("restart={0}&key={1}".format(msg.author.name, self.server_info["key"]), "utf-8")) + + if server_reply == None: + response = "I think we did it. I didn't get a response, so I think it worked!" + elif command == "announceserver": + if len(words) < 2: + response = "Not enough arguments passed! Couldn't execute the command." + else: + message = "" + i = 1 + while i < len(words): + message += words[i] + + if i < len(words) - 1: + message += "+" + + i += 1 + + server_reply = self.ping_server(bytes("announce={0}&key={1}&msg={2}".format(msg.author.name, self.server_info["key"], message), "utf-8")) + + if server_reply == None: + response = "Sorry! I couldn't execute the command for whatever reason!" + else: + response = "Got a reply back from the server! '{0}'".format(server_reply) + elif command == "notes": + if len(words) < 2: + response = "Not enough argumetns passed! Couldn't execute the command." + else: + server_reply = self.ping_server(bytes("notes={0}&key={1}".format(words[1], self.server_info["key"]), "utf-8")) + + if server_reply == None: + response = "Sorry! I couldn't execute the command for whatever reason!" + else: + response = server_reply + elif command == "info": + if len(words) < 2: + response = "Not enough arguments passed! Couldn't execute the command." + else: + server_reply = self.ping_server(bytes("info={0}&key={1}".format(words[1], self.server_info["key"]), "utf-8")) + + if server_reply == None: + response = "Sorry! I was unable to ping the server!" + elif isinstance(server_reply, str): + response = "The server replied with this: {0}.".format(server_reply) + else: + response = "Information on {0}:\n\n```\n".format(server_reply["key"]) + for key in sorted(server_reply.keys()): + if key == "damage" and server_reply[key] != "non-living": + for chunk in server_reply[key].split('&'): + chunk = chunk.replace("+", " ") + dat = chunk.split('=') + if len(dat) == 2: + response += "{0} damage at: {1}\n".format(parse.unquote(dat[0]), parse.unquote(dat[1])) + else: + response += "{0} = {1}\n".format(key, server_reply[key]) + response += "```" + elif command == "age": + if len(words) < 2: + response = "Not enough arguments passed! Couldn't execute the command." + else: + server_reply = self.ping_server(bytes("age={0}&key={1}".format(words[1], self.server_info["key"]), "utf-8")) + + if server_reply == None: + response = "Sorry! I was unable to ping the server!" + else: + response = "The server replied with this: {0}.".format(server_reply) + elif command == "faxlist": + received = "received" + if len(words) < 2: + self.send_message(msg.channel, "{0} - You didn't specify whether you want received or sent faxes. Assuming you wanted **received**.".format(msg.author.mention())) + elif words[1].lower() != "received" and words[1].lower() != "sent": + self.send_message(msg.channel, "{0} - You used an invalid key on specifying whether you want received or sent faxes. Assuming you wanted **received**.".format(msg.author.mention())) + else: + received = words[1].lower() + + server_reply = self.ping_server(bytes("faxlist={0}&key={1}".format(received, self.server_info["key"]), "utf-8")) + + if server_reply == None: + response = "Sorry! I couldn't execute the command for whatever reason!" + else: + if isinstance(server_reply, str) == True: + response = server_reply + else: + response = "Here are the faxes I got!" + for key in server_reply: + response += "\n{0} - {1}".format(key, server_reply[key]) + elif command == "getfax": + received = "received" + if len(words) < 3: + response = "Not enough arguments passed! Couldn't execute the command." + elif words[1].isdigit == False: + response = "{0} - You didn't give me an integer! I cannot work with this!".format(msg.author.mention()) + else: + if words[2].lower() != "received" and words[2].lower() != "sent": + self.send_message(msg.channel, "{0} - You used an invalid key on specifying whether you want received or sent faxes. Assuming you wanted **received**.".format(msg.author.mention())) + else: + received = words[2].lower() + + fax_id = words[1] + server_reply = self.ping_server(bytes("getfax={0}&key={1}&received={2}".format(fax_id, self.server_info["key"], received), "utf-8")) + + if server_reply == None: + response = "Sorry! I couldn't execute the command for whatever reason!" + else: + if isinstance(server_reply, str): + response = server_reply + else: + response = "Fax titled '{0}':\n\n```{1}```".format(server_reply["title"], server_reply["content"]) + + if response != None: + self.send_message(msg.channel, response) + elif random.randrange(10) == 8: + self.send_message(msg.channel, "..Were you talking to me...?") + + def forward_message(self, destination, msg): + if destination not in self.channels: + return + + if msg == None: + return + + if self.allow_everyone == False and msg.find("@everyone") != -1: + msg.replace("@everyone", "") + + invite = self.get_invite(self.channels[destination]) + self.accept_invite(invite) + self.send_message(invite.channel, msg) + + def receive_nudges(self): + if self.nudge_config['port'] == None or self.nudge_config['hostname'] == None: + logging.error("Runtime error while starting receive_nudges(): hostname or port unspecified.") + return + + if self.listening == True: + return + else: + self.listening = True + + logging.info("Receive_nudges() started.") + port = self.nudge_config['port'] + host = self.nudge_config['hostname'] + backlog = 5 + size = 1024 + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.bind((host, port)) + s.listen(backlog) + + while True: + client, _ = s.accept() + + if self.allow_nudging == False: + client.close() + continue + + data = client.recv(size) + client.close() + truedata = pickle.loads(data) + to = None + msg = None + + if truedata.get('key', '') != self.nudge_config['key']: + continue + + if truedata.get('channel', None) != None: + to = truedata['channel'] + else: + continue + + msg = truedata['data'] + self.forward_message(to, msg) + + def decode_packet(self, packet): + if packet != "": + if b"\x00" in packet[0:2] or b"\x83" in packet[0:2]: + + sizebytes = struct.unpack('>H', packet[2:4]) # array size of the type identifier and content # ROB: Big-endian! + size = sizebytes[0] - 1 # size of the string/floating-point (minus the size of the identifier byte) + if b'\x2a' in packet[4:5]: # 4-byte big-endian floating-point + unpackint = struct.unpack('f', packet[5:9]) # 4 possible bytes: add them up together, unpack them as a floating-point + + return int(unpackint[0]) + elif b'\x06' in packet[4:5]: # ASCII string + unpackstr = '' # result string + index = 5 # string index + indexend = index + size + + string = packet[5:indexend].decode("utf-8") + string = string.replace('\x00', '') + + return string + return None + + def ping_server(self, question): + try: + + query = b'\x00\x83' + query += struct.pack('>H', len(question) + 6) + query += b'\x00\x00\x00\x00\x00' + query += question + query += b'\x00' + + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.connect((self.server_info['hostname'], self.server_info['port'])) + s.settimeout(30) + + if s == None: + return None + + s.sendall(query) + + data = b'' + while True: + buf = s.recv(1024) + data += buf + szbuf = len(buf) + if szbuf < 1024: + break + + s.close() + + response = self.decode_packet(bytes(data)) + + if response != None: + if isinstance(response, int) == True or (response.find('&') + response.find('=') == -2): + return response + else: + parsed_response = {} + for chunk in response.split('&'): + chunk = chunk.replace("+", " ") + dat = chunk.split('=') + parsed_response[dat[0]] = '' + if len(dat) == 2: + parsed_response[dat[0]] = parse.unquote(dat[1]) + + return parsed_response + else: + return None + except socket.timeout: + return None + except socket.error: + return None diff --git a/bot/borealisbot.py b/bot/borealisbot.py new file mode 100644 index 00000000000..3ac8287316c --- /dev/null +++ b/bot/borealisbot.py @@ -0,0 +1,18 @@ +import borealis.bot as borealisbot +import logging +import os + +def main(): + logging.basicConfig(format='%(asctime)s: %(levelname)-8s - %(message)s', datefmt='%m/%d/%Y %I:%M:%S', level=logging.INFO) + config_path = 'config.yml' + + while True: + try: + bot = borealisbot.DiscordBot(config_path) + bot.run() + except Exception as e: + logging.critical(e) + break + +if __name__ == '__main__': + main() diff --git a/bot/config.example.yml b/bot/config.example.yml new file mode 100644 index 00000000000..aee82850f35 --- /dev/null +++ b/bot/config.example.yml @@ -0,0 +1,71 @@ +#Email and password used to log into the discord account. +credentials: + email: 'bot@somemail.com' + password: 'apassword' + +#Dictionary of channels to be used. +channels: + lobby: 'https://discord.gg/foo' + admin_channel: 'https://discord.gg/foobar' + +#A greeting message. Displayed whenever the bot starts up, usually sent to the lobby. +greeting: 'Reactor: online. Sensors: online. Connection established. All systems nominal.' + +#Config settings for behaviour control. +allow_everyone: True +allow_nudging: True + +#Config for setting up the nudge_receiver() proc. +nudge_config: + hostname: 'localhost' + port: 5555 + key: 'foobar' + +#Server info for the game. Key must be the same as comms_password in ../config/config.txt. +server_info: + hostname: 'localhost' + port: 4444 + key: 'foobar' + +#All commands the bot is meant to recognize, along with helper text. +#Split into different dictionaries, depending on the access required to use them. +commands: + public_commands: + help: Sends this message to you. + helpadmin: Showcases all admin commands, and their syntax. + helpmod: Showcases all mod commands, and their syntax. + helpcciaa: Showcases all duty officer commands, and their syntax. + greet: Forces me to greet you!. + playercount: Checks the playercount of the server and returns it to you. + admincount: Checks the amount of admins on the server and returns it to you. + docount: Checks the amount of DOs on the server and returns it to you. + gamemode: Tells you the servers current gamemode. + mentionstatus: Tells you whether or not I am set to mention everyone. + nudgestatus: Tells you whether or not I am forwarding messages from within the game. + + admin_commands: + togglenudges: Toggles my status on nudges. + togglementions: Toggles my usage of the everyone mention. + refreshconfig: Refreshes my config file, and loads new values into it. + restartserver: Restarts the main game server. + announceserver: Sends an admin anonuncement to the game server. Syntax !announceserver [message to announce]. + adminmsg: Sends a PM to the player whose CKey is specified. Syntax !adminmsg [player ckey] [message to send]. + + mod_commands: + adminmsg: Sends a PM to the player whose CKey is specified. Syntax !adminmsg [player ckey] [message to send]. + + cciaa_commands: + faxlist: Returns a list of fax IDs and their subjects that have been sent or received this round. Replace [received] with either the word "sent" or "received". Syntax !faxlist [received]. + getfax: Returns the content of the fax with the ID specified. Replace [received] with either the word "sent" or "received" and [fax_id] with a number. Syntax !getfax [fax_id] [received]. + +#Authorized server-groups for specific commands. Cciaa are authorized for cciaa_commands, etcetera. +authorization: + admin: [ + 'administrators' + ] + mod: [ + 'moderators' + ] + cciaa: [ + 'duty officers' + ] diff --git a/bot/gen_fml.py b/bot/gen_fml.py deleted file mode 100644 index 358fac8700e..00000000000 --- a/bot/gen_fml.py +++ /dev/null @@ -1,15 +0,0 @@ -from FMLformatter import formatter -from urllib2 import urlopen -try: - from hashlib import md5 -except: - from md5 import md5 -from save_load import save,load -import CORE_DATA -directory = CORE_DATA.directory -FML = urlopen("http://www.fmylife.com/random") -formatted = formatter(FML.read().split("\n")) -for Quote in formatted: - exact = Quote[:Quote.find("#")] -# print exact - save(directory+"fmlquotes/"+md5(exact).hexdigest()+".txt",exact) diff --git a/bot/htmltagremove.py b/bot/htmltagremove.py deleted file mode 100644 index c9d13086d51..00000000000 --- a/bot/htmltagremove.py +++ /dev/null @@ -1,28 +0,0 @@ -def htr(data): - ignore = False - if type(data) == list: - b = [] - for olio in data: - tempolio = "" - for letter in olio: - if letter == "<": - ignore = True - else: - pass - if ignore != True: - tempolio += letter - else: - pass - if letter == ">": - ignore = False - else: - pass - tempolio = tempolio.replace("\t","") - if len(tempolio) == 0: - pass - elif len(tempolio.replace(" ","")) == 0: - pass - else: - b.append(tempolio) - #Finetuning - return b diff --git a/bot/irchat.py b/bot/irchat.py deleted file mode 100644 index 46ae2d4caf7..00000000000 --- a/bot/irchat.py +++ /dev/null @@ -1,94 +0,0 @@ -import socket -import time -class IRC: - queue = [] - partial = '' - def __init__ ( self, network, port, name, hostName, serverName, realName ): - self.network = network - self.port = port - self.hostName = hostName - self.serverName = serverName - self.realName = realName - self.socket = socket.socket ( socket.AF_INET, socket.SOCK_STREAM ) - self.socket.connect ( ( self.network, self.port ) ) - self.address = self.socket.getpeername() - self.nick ( name ) - self.send ( 'USER ' + self.name + ' ' + self.serverName + ' ' + self.hostName + ' :' + self.realName ) - def quit ( self ): - self.send ( 'QUIT' ) - self.socket.close() - def send ( self, text ): - count = 0 - try: - count += 1 - self.socket.send ( text + '\r\n' ) - except: - if count > 10: - time.sleep(1) - self.socket.send(text+'\r\n') - else: - count = 0 - def nick ( self, name ): - self.name = name - self.send ( 'NICK ' + self.name ) - def addressquery(self): - print self.address - aha = socket.gethostbyaddr(str(self.address[0])) - return aha - def recv ( self, size = 2048 ): - commands = self.socket.recv ( size ).split ( '\r\n' ) - if len ( self.partial ): - commands [ 0 ] = self.partial + commands [ 0 ] - self.partial = '' - if len ( commands [ -1 ] ): - self.partial = commands [ -1 ] - self.queue.extend ( commands [ :-1 ] ) - else: - self.queue.extend ( commands ) - def retrieve ( self ): - if len ( self.queue ): - command = self.queue [ 0 ] - self.queue.pop ( 0 ) - return command - else: - return False - def dismantle ( self, command ): - if command: - source = command.split ( ':' ) [ 1 ].split ( ' ' ) [ 0 ] - parameters = command.split ( ':' ) [ 1 ].split ( ' ' ) [ 1: ] - if len(parameters) > 0: - if not len ( parameters [ -1 ] ): - parameters.pop() - if command.count ( ':' ) > 1: - parameters.append(command[command.find(":",command.find(":")+1)+1:]) - return source, parameters - def privmsg ( self, destination, message ): - self.send ( 'PRIVMSG ' + destination + ' :' + message ) - def handshake(self,hexstring): - self.send("PONG :"+hexstring) - def notice ( self, destination, message ): - self.send ( 'NOTICE ' + destination + ' :' + message ) - def join ( self, channel ): - self.send ( 'JOIN ' + channel ) - def part ( self, channel ): - self.send ( 'PART ' + channel ) - def topic ( self, channel, topic = '' ): - self.send ( 'TOPIC ' + channel + ' ' + topic ) - def names ( self, channel ): - self.send ( 'NAMES ' + channel ) - def invite ( self, nick, channel ): - self.send ( 'INVITE ' + nick + ' ' + channel ) - def mode ( self, channel, mode, nick = '' ): - self.send ( 'MODE ' + channel + ' ' + mode + ' ' + nick ) - def banon(self,channel,name): - self.mode(channel,"+b",name) - def banoff(self,channel,name): - self.mode(channel,"-b",name) - def kick ( self, channel, nick, reason = '' ): - self.send ( 'KICK ' + channel + ' ' + nick + ' ' + reason ) - def who ( self, pattern ): - self.send ( 'WHO ' + pattern ) - def whois ( self, nick ): - self.send ( 'WHOIS ' + nick ) - def whowas ( self, nick ): - self.send ( 'WHOWAS ' + nick ) diff --git a/bot/linereader.py b/bot/linereader.py deleted file mode 100644 index cef804935b8..00000000000 --- a/bot/linereader.py +++ /dev/null @@ -1,43 +0,0 @@ -import os -directory = "" -raw = os.listdir(directory) -extract = [] -for i in raw: - if i[-3:] == ".py": - extract.append(i) -toc = 0 -toc3 = 0 -toc2 = 0 -print len(extract),"Files" -lista = [] -for ob in extract: - count3 = 0 - if directory == "": - tiedosto = open(ob,"r") - tiedosto2 = open(ob,"r") - count3 += os.path.getsize(ob) - toc3 += count3 - else: - tiedosto = open(directory+"/"+ob,"r") - tiedosto2 = open(directory+"/"+ob,"r") - count3 += os.path.getsize(directory+"/"+ob) - toc3 += count3 - count = 0 - count2 = 0 - line = tiedosto.readline() - while line != "": - count += 1 - toc += 1 - line = tiedosto.readline() - count2 += len(tiedosto2.read()) - toc2 += count2 - lista.append([count,count2,ob,count3]) - tiedosto.close() - tiedosto2.close() -print toc,"Lines in total" -print toc2,"Letters in total" -print toc3,"Bytes in total" - -for linecount, lettercount, filename, bytecount in lista: - print str(linecount)+" Lines (%s%%) || "%(str(round((float(linecount)/toc)*100,1))),str(lettercount)+" Letters (%s%%) in file " %(str(round((float(lettercount)/toc2)*100,1)))+filename - print str(bytecount) + " Bytes (%s%%) "%(str(round((float(bytecount)/toc3)*100,1))) diff --git a/bot/nudge.py b/bot/nudge.py deleted file mode 100644 index e39ebc314c5..00000000000 --- a/bot/nudge.py +++ /dev/null @@ -1,39 +0,0 @@ -import sys,pickle,socket, CORE_DATA -#def pack(): -# path = "/home/ski/Nanotrasen/message.txt" -# ip = sys.argv[1] -# dictionary = {"ip":ip,"data":1} -# try: -# targetfile = open(path,"r") -# except IOError: -# targetfile = open(path,"w") -# pickle.dump(dictionary,targetfile) -# targetfile.close() -# nudge() -# else: -# targetfile.close() #Professionals, have standards. -# pass -def pack(): - ip = sys.argv[1] - try: - data = sys.argv[2:] #The rest of the arguments is data - except: - data = "NO DATA SPECIFIED" - dictionary = {"ip":ip,"data":data} - pickled = pickle.dumps(dictionary) - nudge(pickled) -def nudge(data): - if CORE_DATA.DISABLE_ALL_NON_MANDATORY_SOCKET_CONNECTIONS: - pass - else: - HOST = "localhost" - PORT = 45678 - size = 1024 - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.connect((HOST,PORT)) - s.send(data) - s.close() - -if __name__ == "__main__" and len(sys.argv) > 1: # If not imported and more than one argument - pack() - diff --git a/bot/save_load.py b/bot/save_load.py deleted file mode 100644 index 34eac990726..00000000000 --- a/bot/save_load.py +++ /dev/null @@ -1,24 +0,0 @@ -import pickle -def save(filename,data,dnrw=0): - if dnrw == 1: - try: - tiedosto = open(filename,"r") - except: - tiedosto = open(filename,"w") - else: - return False - else: - tiedosto = open(filename,"w") - - if "http//" in data: - data = data.replace("http//","http://") - pickle.dump(data,tiedosto) - tiedosto.close() -def load(filename): - try: - tiedosto = open(filename,"r") - except IOError: - return "ERROR ERROR ERROR ERR" - a = pickle.load(tiedosto) - tiedosto.close() - return a diff --git a/bot/some_but_not_all_2.py b/bot/some_but_not_all_2.py deleted file mode 100644 index 211eef9fd52..00000000000 --- a/bot/some_but_not_all_2.py +++ /dev/null @@ -1,20 +0,0 @@ -def sbna2(only_one,one_of_these,data): - if type(only_one) != list: - only_one = list(only_one) - if type(data) != list: - data = data.split(" ") - count = 0 - for datoid in only_one: - if datoid in data and count >= 1: - return False - elif datoid in data: - count += 1 - pass - else: - pass - if count == 0: - return False - for datoid in one_of_these: - if datoid in data: - return True - return False diff --git a/bot/xkcdparser.py b/bot/xkcdparser.py deleted file mode 100644 index 24d6f514165..00000000000 --- a/bot/xkcdparser.py +++ /dev/null @@ -1,40 +0,0 @@ -from urllib2 import urlopen -from json import loads -from pickle import dump,load -from CORE_DATA import no_absolute_paths -def xkcd(link): - try: - filename = link[link.find("xkcd.com")+9:].replace("/","").replace("\\","") - if no_absolute_paths: - tiedosto = open("xkcdcache/"+filename,"r") - else: - tiedosto = open(directory+"xkcdcache/"+filename,"r") - except: - try: - if no_absolute_paths: - tiedosto = open("xkcdcache/"+filename,"w") - else: - tiedosto = open(directory+"xkcdcache/"+filename,"w") - except IOError: - return "NOTHING" - else: - try: - return load(tiedosto) - except EOFError: - tiedosto = open("xkcdcache/"+filename,"w") - pass #Corrupt cache, moving on. - if link[-1] == "/" or link[-1] == "\\": #Ending is fine. - link += "info.0.json" - else: - link += "/info.0.json" - try: - data = urlopen(link).read() - except: - return "NOTHING" - try: - newdata = loads(data)["title"] - dump(newdata,tiedosto) - return newdata - except: - return "NOTHING" - diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 6c21fed7523..ea01ad942fa 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -168,12 +168,10 @@ var/list/gamemode_cache = list() var/enter_allowed = 1 - var/use_irc_bot = 0 - var/irc_bot_host = "" - var/irc_bot_export = 0 // whether the IRC bot in use is a Bot32 (or similar) instance; Bot32 uses world.Export() instead of nudge.py/libnudge - var/main_irc = "" - var/admin_irc = "" - var/python_path = "" //Path to the python executable. Defaults to "python" on windows and "/usr/bin/env python2" on unix + var/use_discord_bot = 0 + var/discord_bot_host = "localhost" + var/discord_bot_port = 0 + var/python_path = "python" //Path to the python executable. Defaults to "python" on windows and "/usr/bin/env python2" on unix var/use_lib_nudge = 0 //Use the C library nudge instead of the python nudge. var/use_overmap = 0 @@ -522,12 +520,6 @@ var/list/gamemode_cache = list() if("allow_holidays") Holiday = 1 - if("use_irc_bot") - use_irc_bot = 1 - - if("irc_bot_export") - irc_bot_export = 1 - if("ticklag") Ticklag = text2num(value) @@ -579,14 +571,14 @@ var/list/gamemode_cache = list() if("comms_password") config.comms_password = value - if("irc_bot_host") - config.irc_bot_host = value + if("use_discord_bot") + config.use_discord_bot = 1 - if("main_irc") - config.main_irc = value + if("discord_bot_host") + config.discord_bot_host = value - if("admin_irc") - config.admin_irc = value + if("discord_bot_port") + config.discord_bot_port = value if("python_path") if(value) diff --git a/code/game/gamemodes/game_mode.dm b/code/game/gamemodes/game_mode.dm index d5e55f4c128..b0ffa96309a 100644 --- a/code/game/gamemodes/game_mode.dm +++ b/code/game/gamemodes/game_mode.dm @@ -440,8 +440,6 @@ var/global/list/additional_antag_types = list() if(escaped_on_pod_5 > 0) feedback_set("escaped_on_pod_5",escaped_on_pod_5) - send2mainirc("A round of [src.name] has ended - [surviving_total] survivors, [ghosts] ghosts.") - return 0 /datum/game_mode/proc/check_win() //universal trigger to be called at mob death, nuke explosion, etc. To be called from everywhere. diff --git a/code/game/gamemodes/gameticker.dm b/code/game/gamemodes/gameticker.dm index 2b74ee9488e..ce99b333e30 100644 --- a/code/game/gamemodes/gameticker.dm +++ b/code/game/gamemodes/gameticker.dm @@ -144,10 +144,10 @@ var/global/datum/controller/gameticker/ticker var/admins_number = 0 for(var/client/C) - if(C.holder) + if(C.holder && (C.holder.rights & (R_MOD|R_ADMIN))) admins_number++ if(admins_number == 0) - send2adminirc("Round has started with no admins online.") + send_to_admin_discord("@everyone Round has started with no admins online.") /* supply_controller.process() //Start the supply shuttle regenerating points -- TLE // handled in scheduler master_controller.process() //Start master_controller.process() diff --git a/code/game/verbs/who.dm b/code/game/verbs/who.dm index 44c1fecd1fa..2340ba266c6 100644 --- a/code/game/verbs/who.dm +++ b/code/game/verbs/who.dm @@ -151,8 +151,8 @@ cciaamsg += "\t[C] is a [C.holder.rank]\n" num_cciaa_online++ - if(config.admin_irc) - src << "Adminhelps are also sent to IRC. If no admins are available in game try anyway and an admin on IRC may see it and respond." + if(config.use_discord_bot) + src << "Adminhelps are also sent to Discord. If no admins are available in game try anyway and an admin on Discord may see it and respond." msg = "Current Admins ([num_admins_online]):\n" + msg if(config.show_mods) diff --git a/code/modules/admin/player_notes_sql.dm b/code/modules/admin/player_notes_sql.dm index 44416a11a82..1d447110771 100644 --- a/code/modules/admin/player_notes_sql.dm +++ b/code/modules/admin/player_notes_sql.dm @@ -183,6 +183,47 @@ dat += "" usr << browse(dat,"window=lookupnotes;size=900x500") +/proc/show_player_info_discord(var/ckey) + if (!ckey) + return "No ckey given!" + + establish_db_connection() + + if (!dbcon.IsConnected()) + return "Unable to establish database connection! Aborting!" + + var/DBQuery/info_query = dbcon.NewQuery("SELECT ip, computerid FROM ss13_player WHERE ckey = :ckey") + info_query.Execute(list(":ckey" = ckey)) + + var/address = null + var/computer_id = null + if (info_query.NextRow()) + address = info_query.item[1] + computer_id = info_query.item[2] + + var/query_content = "SELECT a_ckey, adddate, content FROM ss13_notes WHERE visible = '1' AND ckey = :ckey" + var/query_details = list(":ckey" = ckey, ":address" = address, ":computerid" = computer_id) + if (address) + query_content += " OR ip = :address" + if (computer_id) + query_content += " OR computerid = :computerid" + + var/DBQuery/query = dbcon.NewQuery(query_content) + query.Execute(query_details, 1) + + var/notes + while (query.NextRow()) + notes += "\"[query.item[3]]\" - by [query.item[1]] on [query.item[2]]\n\n" + + if (!notes) + return "[ckey] has no notes that could be retreived!" + else + var/content = "Displaying [ckey]'s notes:\n\n" + content += "```\n" + content += notes + content += "```" + return content + /*/proc/notes_transfer() msg_scopes("Locating master list.") var/savefile/note_list = new("data/player_notes.sav") diff --git a/code/modules/admin/verbs/adminhelp.dm b/code/modules/admin/verbs/adminhelp.dm index 1c36dbff722..94fc6a7c496 100644 --- a/code/modules/admin/verbs/adminhelp.dm +++ b/code/modules/admin/verbs/adminhelp.dm @@ -116,8 +116,6 @@ var/list/adminhelp_ignored_words = list("unknown","the","a","an","of","monkey"," var/admin_number_present = admins.len - admin_number_afk log_admin("HELP: [key_name(src)]: [original_msg] - heard by [admin_number_present] non-AFK admins.") if(admin_number_present <= 0) - send2adminirc("Request for Help from [key_name(src)]: [html_decode(original_msg)] - !![admin_number_afk ? "All admins AFK ([admin_number_afk])" : "No admins online"]!!") - else - send2adminirc("Request for Help from [key_name(src)]: [html_decode(original_msg)]") + send_to_admin_discord("@everyone Request for Help from [key_name(src)]: [html_decode(original_msg)] - !![admin_number_afk ? "All admins AFK ([admin_number_afk])" : "No admins online"]!!") feedback_add_details("admin_verb","AH") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! return diff --git a/code/modules/admin/verbs/adminpm.dm b/code/modules/admin/verbs/adminpm.dm index ea90252bfe9..a75aacd7999 100644 --- a/code/modules/admin/verbs/adminpm.dm +++ b/code/modules/admin/verbs/adminpm.dm @@ -108,7 +108,6 @@ C << 'sound/effects/adminhelp.ogg' log_admin("PM: [key_name(src)]->[key_name(C)]: [msg]") - send2adminirc("Reply: [key_name(src)]->[key_name(C)]: [html_decode(msg)]") //we don't use message_admins here because the sender/receiver might get it too for(var/client/X in admins) @@ -118,31 +117,25 @@ if(X.key != key && X.key != C.key && (X.holder.rights & (R_ADMIN|R_MOD))) X << "" + create_text_tag("pm_other", "PM:", X) + " [key_name(src, X, 0)] to [key_name(C, X, 0)]: [msg]" -/client/proc/cmd_admin_irc_pm(sender) +/client/proc/cmd_admin_discord_pm(sender) if(prefs.muted & MUTE_ADMINHELP) src << "Error: Private-Message: You are unable to use PM-s (muted)." return - var/msg = input(src,"Message:", "Reply private message to [sender] on IRC / 400 character limit") as text|null + var/msg = input(src,"Message:", "Reply private message to [sender] on Discord") as text|null if(!msg) return sanitize(msg) - // Handled on Bot32's end, unsure about other bots -// if(length(msg) > 400) // TODO: if message length is over 400, divide it up into seperate messages, the message length restriction is based on IRC limitations. Probably easier to do this on the bots ends. -// src << "Your message was not sent because it was more then 400 characters find your message below for ease of copy/pasting" -// src << "\blue [msg]" -// return + send_to_admin_discord("PlayerPM to [sender] from [key_name(src)]: [html_decode(msg)]") - send2adminirc("PlayerPM to [sender] from [key_name(src)]: [html_decode(msg)]") + src << "" + create_text_tag("pm_out_alt", "", src) + " to Discord-[sender]: [msg]" - src << "" + create_text_tag("pm_out_alt", "", src) + " to IRC-[sender]: [msg]" - - log_admin("PM: [key_name(src)]->IRC-[sender]: [msg]") + log_admin("PM: [key_name(src)]->Discord-[sender]: [msg]") for(var/client/X in admins) if(X == src) continue if(X.holder.rights & (R_ADMIN|R_MOD)) - X << "" + create_text_tag("pm_other", "PM:", X) + " [key_name(src, X, 0)] to IRC-[sender]: [msg]" + X << "" + create_text_tag("pm_other", "PM:", X) + " [key_name(src, X, 0)] to Discord-[sender]: [msg]" diff --git a/code/modules/admin/verbs/pray.dm b/code/modules/admin/verbs/pray.dm index 313de0150d9..3099be86c71 100644 --- a/code/modules/admin/verbs/pray.dm +++ b/code/modules/admin/verbs/pray.dm @@ -38,6 +38,8 @@ else if (R_CCIAA & C.holder.rights) C << msg_cciaa + send_to_cciaa_discord("!!! @everyone - Emergency message from the station: \"[msg]\", sent by [Sender] !!!") + /proc/Syndicate_announce(var/msg, var/mob/Sender) msg = "\blue ILLEGAL:[key_name(Sender, 1)] (PP) (VV) (SM) (JMP) (CA) (BSA) (RPLY): [msg]" for(var/client/C in admins) diff --git a/code/modules/client/client defines.dm b/code/modules/client/client defines.dm index bbb2359f13e..5684d5cb0f0 100644 --- a/code/modules/client/client defines.dm +++ b/code/modules/client/client defines.dm @@ -34,9 +34,9 @@ // comment out the line below when debugging locally to enable the options & messages menu //control_freak = 1 - var/received_irc_pm = -99999 - var/irc_admin //IRC admin that spoke with them last. - var/mute_irc = 0 + var/received_discord_pm = -99999 + var/discord_admin //IRC- no more IRC, K? Discord admin that spoke with them last. + var/mute_discord = 0 //////////////////////////////////// diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm index 578902d9c04..09127b10095 100644 --- a/code/modules/client/client procs.dm +++ b/code/modules/client/client procs.dm @@ -45,14 +45,14 @@ cmd_admin_pm(C,null) return - if(href_list["irc_msg"]) - if(!holder && received_irc_pm < world.time - 6000) //Worse they can do is spam IRC for 10 minutes - usr << "You are no longer able to use this, it's been more then 10 minutes since an admin on IRC has responded to you" + if(href_list["discord_msg"]) + if(!holder && received_discord_pm < world.time - 6000) //Worse they can do is spam IRC for 10 minutes + usr << "You are no longer able to use this, it's been more then 10 minutes since an admin on Discord has responded to you" return - if(mute_irc) - usr << "" + if(mute_discord) + usr << "" return - cmd_admin_irc_pm(href_list["irc_msg"]) + cmd_admin_discord_pm(href_list["discord_msg"]) return diff --git a/code/modules/ext_scripts/discord.dm b/code/modules/ext_scripts/discord.dm new file mode 100644 index 00000000000..24fddb5788b --- /dev/null +++ b/code/modules/ext_scripts/discord.dm @@ -0,0 +1,33 @@ +#define CHAN_ADMIN "admin_channel" +#define CHAN_CCIAA "cciaa_channel" + +/proc/send_to_discord(var/channel, var/message) + if (!config.use_discord_bot) + return + if (!channel) + log_game("send_to_discord() called without channel arg.") + return + if (!message) + log_game("send_to_discord() called without message arg.") + return + + var/arguments = " --key=\"[config.comms_password]\"" + arguments += " --channel=\"[channel]\"" + if (config.discord_bot_host) + arguments += " --host=\"[config.discord_bot_host]\"" + if (config.discord_bot_port) + arguments += " --port=[config.discord_bot_port]" + + message = replacetext(message, "\"", "\\\"") + + ext_python("discordbot_message.py", "[arguments] [message]") + return + +/proc/send_to_admin_discord(var/message) + send_to_discord(CHAN_ADMIN, message) + +/proc/send_to_cciaa_discord(var/message) + send_to_discord(CHAN_CCIAA, message) + +#undef CHAN_CCIAA +#undef CHAN_ADMIN diff --git a/code/modules/mob/logout.dm b/code/modules/mob/logout.dm index bb01c846caf..72f484f36c4 100644 --- a/code/modules/mob/logout.dm +++ b/code/modules/mob/logout.dm @@ -8,7 +8,7 @@ message_admins("Admin logout: [key_name(src)]") if(admins_number == 0) //Apparently the admin logging out is no longer an admin at this point, so we have to check this towards 0 and not towards 1. Awell. - send2adminirc("[key_name(src)] logged out - no more admins online.") + send_to_admin_discord("@everyone [key_name(src)] logged out - no more admins online.") ..() - return 1 \ No newline at end of file + return 1 diff --git a/code/modules/paperwork/faxmachine.dm b/code/modules/paperwork/faxmachine.dm index 17872c4c871..b9d8dbed46d 100644 --- a/code/modules/paperwork/faxmachine.dm +++ b/code/modules/paperwork/faxmachine.dm @@ -217,3 +217,5 @@ var/list/sent_faxes = list() //cache for faxes that have been sent by the admins for(var/client/C in admins) if((R_ADMIN|R_CCIAA) & C.holder.rights) C << msg + + send_to_cciaa_discord("New fax arrived! [faxname]: \"[sent.name]\" by [sender].") diff --git a/code/world.dm b/code/world.dm index af45ed2265f..88dea018a5f 100644 --- a/code/world.dm +++ b/code/world.dm @@ -102,6 +102,32 @@ var/world_topic_spam_protect_time = world.timeofday n++ return n + else if (T == "admins") + var/n = 0 + for (var/client/client in clients) + if (client.holder && client.holder.rights & (R_MOD|R_ADMIN)) + n++ + + return n + + else if (T == "cciaa") + var/n = 0 + for (var/client/client in clients) + if (client.holder && (client.holder.rights & R_CCIAA) && !(client.holder.rights & R_ADMIN)) + n++ + + return n + + else if (T == "gamemode") + return master_mode + + else if (T == "who") + var/list/players = list() + for (var/client/C in clients) + players += C.key + + return list2params(players) + else if (copytext(T,1,7) == "status") var/input[] = params2list(T) var/list/s = list() @@ -151,6 +177,9 @@ var/world_topic_spam_protect_time = world.timeofday return list2params(s) else if(T == "manifest") + if (!ticker) + return "Game not started yet!" + var/list/positions = list() var/list/set_names = list( "heads" = command_positions, @@ -184,25 +213,35 @@ var/world_topic_spam_protect_time = world.timeofday return list2params(positions) - else if(T == "revision") - if(revdata.revision) - return list2params(list(branch = revdata.branch, date = revdata.date, revision = revdata.revision)) - else - return "unknown" + else if(copytext(T,1,5) == "mute") + var/input[] = params2list(T) + var/bad_key = do_topic_spam_protection(addr, input["key"]) + + if (bad_key) + return bad_key + + for (var/client/C in clients) + if (C.ckey == ckey(input["mute"])) + C.mute_discord = !C.mute_discord + + switch (C.mute_discord) + if (1) + C << "You have been muted from replying to Discord PMs by [input["admin"]]!" + log_and_message_admins("[C] has been muted from Discord PMs by [input["admin"]].") + return "[C.key] is now muted from replying to Discord PMs." + if (0) + C << "You have been unmuted from replying to Discord PMs by [input["admin"]]!" + log_and_message_admins("[C] has been unmuted from Discord PMs by [input["admin"]].") + return "[C.key] is now unmuted from replying to Discord PMs." + + return "I couldn't find that ckey!" else if(copytext(T,1,5) == "info") var/input[] = params2list(T) - if(input["key"] != config.comms_password) - if(world_topic_spam_protect_ip == addr && abs(world_topic_spam_protect_time - world.time) < 50) + var/bad_key = do_topic_spam_protection(addr, input["key"]) - spawn(50) - world_topic_spam_protect_time = world.time - return "Bad Key (Throttled)" - - world_topic_spam_protect_time = world.time - world_topic_spam_protect_ip = addr - - return "Bad Key" + if (bad_key) + return bad_key var/list/search = params2list(input["info"]) var/list/ckeysearch = list() @@ -237,6 +276,9 @@ var/world_topic_spam_protect_time = world.timeofday var/mob/M = match[1] var/info = list() info["key"] = M.key + if (M.client) + var/client/C = M.client + info["discordmuted"] = C.mute_discord ? "Yes" : "No" info["name"] = M.name == M.real_name ? M.name : "[M.name] ([M.real_name])" info["role"] = M.mind ? (M.mind.assigned_role ? M.mind.assigned_role : "No role") : "No mind" var/turf/MT = get_turf(M) @@ -262,10 +304,7 @@ var/world_topic_spam_protect_time = world.timeofday info["gender"] = M.gender return list2params(info) else - var/list/ret = list() - for(var/mob/M in match) - ret[M.key] = M.name - return list2params(ret) + return "Multiple matches found!" else if(copytext(T,1,9) == "adminmsg") /* @@ -279,17 +318,10 @@ var/world_topic_spam_protect_time = world.timeofday var/input[] = params2list(T) - if(input["key"] != config.comms_password) - if(world_topic_spam_protect_ip == addr && abs(world_topic_spam_protect_time - world.time) < 50) + var/bad_key = do_topic_spam_protection(addr, input["key"]) - spawn(50) - world_topic_spam_protect_time = world.time - return "Bad Key (Throttled)" - - world_topic_spam_protect_time = world.time - world_topic_spam_protect_ip = addr - - return "Bad Key" + if (bad_key) + return bad_key var/client/C var/req_ckey = ckey(input["adminmsg"]) @@ -305,11 +337,11 @@ var/world_topic_spam_protect_time = world.timeofday if(!rank) rank = "Admin" - var/message = "IRC-[rank] PM from IRC-[input["sender"]]: [input["msg"]]" - var/amessage = "IRC-[rank] PM from IRC-[input["sender"]] to [key_name(C)] : [input["msg"]]" + var/message = "Discord-[rank] PM from Discord-[input["sender"]]: [input["msg"]]" + var/amessage = "Discord-[rank] PM from Discord-[input["sender"]] to [key_name(C)] : [input["msg"]]" - C.received_irc_pm = world.time - C.irc_admin = input["sender"] + C.received_discord_pm = world.time + C.discord_admin = input["sender"] C << 'sound/effects/adminhelp.ogg' C << message @@ -322,37 +354,20 @@ var/world_topic_spam_protect_time = world.timeofday return "Message Successful" else if(copytext(T,1,6) == "notes") - /* - We got a request for notes from the IRC Bot - expected output: - 1. notes = ckey of person the notes lookup is for - 2. validationkey = the key the bot has, it should match the gameservers commspassword in it's configuration. - */ var/input[] = params2list(T) - if(input["key"] != config.comms_password) - if(world_topic_spam_protect_ip == addr && abs(world_topic_spam_protect_time - world.time) < 50) + var/bad_key = do_topic_spam_protection(addr, input["key"]) - spawn(50) - world_topic_spam_protect_time = world.time - return "Bad Key (Throttled)" + if (bad_key) + return bad_key - world_topic_spam_protect_time = world.time - world_topic_spam_protect_ip = addr - return "Bad Key" - - return show_player_info_irc(ckey(input["notes"])) + return show_player_info_discord(ckey(input["notes"])) else if(copytext(T,1,4) == "age") var/input[] = params2list(T) - if(input["key"] != config.comms_password) - if(world_topic_spam_protect_ip == addr && abs(world_topic_spam_protect_time - world.time) < 50) - spawn(50) - world_topic_spam_protect_time = world.time - return "Bad Key (Throttled)" + var/bad_key = do_topic_spam_protection(addr, input["key"]) - world_topic_spam_protect_time = world.time - world_topic_spam_protect_ip = addr - return "Bad Key" + if (bad_key) + return bad_key var/age = get_player_age(input["age"]) if(isnum(age)) @@ -363,6 +378,119 @@ var/world_topic_spam_protect_time = world.timeofday else return "Database connection failed or not set up" + else if (copytext(T, 1, 8) == "restart") + var/input[] = params2list(T) + var/bad_key = do_topic_spam_protection(addr, input["key"]) + + if (bad_key) + log_and_message_admins("Remote restart attempted and stopped. Dumping topic call data.") + log_and_message_admins("TOPIC: \"[T]\", from: [addr], master: [master], key: [key].") + return bad_key + + world << "Server restarting by remote command." + log_and_message_admins("World restart initiated remotely by [input["restart"]].") + feedback_set_details("end_error","remote restart") + + if (blackbox) + blackbox.save_all_data_to_sql() + + sleep(50) + log_game("Rebooting due to remote command.") + world.Reboot(2) + + return "Server successfully restarted." + + else if (copytext(T, 1, 9) == "announce") + var/input[] = params2list(T) + var/bad_key = do_topic_spam_protection(addr, input["key"]) + + if (bad_key) + return bad_key + + var/message = replacetext(input["msg"], "\n", "
") + world << "[input["announce"] ? input["announce"] : "Administrator"] Announces via Discord:

[message]

" + log_and_message_admins("[input["announce"]] announced remotely: [input["msg"]].") + + return "Announcement successfully sent." + + else if (copytext(T, 1, 8) == "faxlist") + var/input[] = params2list(T) + var/bad_key = do_topic_spam_protection(addr, input["key"]) + + if (bad_key) + return bad_key + + if (!ticker) + return "Round hasn't started yet! No faxes to display!" + + var/list/faxes = list() + switch (input["faxlist"]) + if ("received") + faxes = arrived_faxes + if ("sent") + faxes = sent_faxes + + if (!faxes || !faxes.len) + return "No faxes found!" + + var/list/output = list() + for (var/i = 1, i <= faxes.len, i++) + var/obj/item/a = faxes[i] + output += "ID [i]" + output["ID [i]"] = a.name ? a.name : "Untitled Fax" + + return list2params(output) + + else if (copytext(T, 1, 7) == "getfax") + var/input[] = params2list(T) + var/bad_key = do_topic_spam_protection(addr, input["key"]) + + if (bad_key) + return bad_key + + var/list/faxes = list() + switch (input["received"]) + if ("received") + faxes = arrived_faxes + if ("sent") + faxes = sent_faxes + + if (!faxes || !faxes.len) + return "No faxes found!" + + var/fax_id = text2num(input["getfax"]) + if (fax_id > faxes.len || fax_id < 1) + return "Invalid fax ID!" + + var/output = list() + if (istype(faxes[fax_id], /obj/item/weapon/paper)) + var/obj/item/weapon/paper/a = faxes[fax_id] + output["title"] = a.name ? a.name : "Untitled Fax" + + var/content = replacetext(a.info, "
", "\n") + content = strip_html_properly(content, 0) + output["content"] = content + + return list2params(output) + else if (istype(faxes[fax_id], /obj/item/weapon/photo)) + return "The fax is a photo. I cannot send images, unfortunately..." + else if (istype(faxes[fax_id], /obj/item/weapon/paper_bundle)) + var/obj/item/weapon/paper_bundle/b = faxes[fax_id] + output["title"] = b.name ? b.name : "Untitled Paper Bundle" + + if (!b.pages || !b.pages.len) + return "The bundle was empty! How is that even possible?" + + var/i = 0 + for (var/obj/item/weapon/paper/c in b.pages) + i++ + var/content = replacetext(c.info, "
", "\n") + content = strip_html_properly(content, 0) + output["content"] += "Page [i]:\n[content]\n\n" + + return list2params(output) + + return "Unable to recognize the fax type. Cannot send contents!" /world/Reboot(var/reason) /*spawn(0) @@ -560,3 +688,21 @@ proc/establish_db_connection() return 1 #undef FAILED_DB_CONNECTION_CUTOFF + +/world/proc/do_topic_spam_protection(var/addr, var/key) + if (!config.comms_password || config.comms_password == "") + return "No comms password configured, aborting." + + if (key == config.comms_password) + return 0 + else + if (world_topic_spam_protect_ip == addr && abs(world_topic_spam_protect_time - world.time) < 50) + + spawn(50) + world_topic_spam_protect_time = world.time + return "Bad Key (Throttled)" + + world_topic_spam_protect_time = world.time + world_topic_spam_protect_ip = addr + + return "Bad Key" diff --git a/html/changelogs/skull132-discord-bot.yml b/html/changelogs/skull132-discord-bot.yml new file mode 100644 index 00000000000..b2f847f1ad6 --- /dev/null +++ b/html/changelogs/skull132-discord-bot.yml @@ -0,0 +1,6 @@ +author: Skull132 + +delete-after: True + +changes: + - rscadd: "Adds discordbot, nicknamed BOREALIS. Basically: this enables admins to interact with the game without even being on the server. Should push come to shove, we can restart the server remotely, and answer adminhelps remotely. Also makes some other functionality possible." diff --git a/scripts/discordbot_message.py b/scripts/discordbot_message.py new file mode 100644 index 00000000000..f6162a808a2 --- /dev/null +++ b/scripts/discordbot_message.py @@ -0,0 +1,49 @@ +# nudge.py --channel="nudges|ahelps" --id="Server ID" --key="access key" Message! More message! +# Credit to the gents at VGStation13/N3XIS for this code. + +import sys +import pickle +import socket +import argparse +import html + +def pack(host, port, key, channel, message): + + data = {} + + data['key'] = key + data['channel'] = channel + + try: + d = [] + for in_data in message: # The rest of the arguments is data + d += [html.unescape(in_data)] + data['data'] = ' '.join(d) + + # Buffer overflow prevention. + if len(data['data']) > 400: + data['data'] = data['data'][:400] + except: + data['data'] = "NO DATA SPECIFIED" + pickled = pickle.dumps(data) + nudge(host, port, pickled) + +def nudge(hostname, port, data): + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.connect((hostname, port)) + s.send(data) + s.close() + +if __name__ == "__main__" and len(sys.argv) > 1: # If not imported and more than one argument + argp = argparse.ArgumentParser() + + argp.add_argument('message', nargs='*', type=str, help='String to send to the server.') + + argp.add_argument('--host', dest='hostname', default='localhost', help='Hostname expecting a nudge.') + argp.add_argument('--port', dest='port', type=int, default=5555, help='Port expecting a nudge.') + argp.add_argument('--channel', dest='channel', default='lobby', help='Channel flag to direct this message to.') + argp.add_argument('--key', dest='key', default='', help='Access key of the bot or receiving script.') + + args = argp.parse_args() + + pack(args.hostname, args.port, args.key, args.channel, args.message) diff --git a/scripts/ircbot_message.py b/scripts/ircbot_message.py deleted file mode 100644 index 4339019e03d..00000000000 --- a/scripts/ircbot_message.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python2 - -# Four arguments, password host channel and message. -# EG: "ircbot_message.py hunter2 example.com #adminchannel ADMINHELP, people are killing me!" - -import sys,cPickle,socket,HTMLParser - -def pack(): - ht = HTMLParser.HTMLParser() - - passwd = sys.argv[1] - ip = sys.argv[3] - try: - data = [] - for in_data in sys.argv[4:]: #The rest of the arguments is data - data += {ht.unescape(in_data)} - except: - data = "NO DATA SPECIFIED" - dictionary = {"ip":ip,"data":[passwd] + data} - pickled = cPickle.dumps(dictionary) - nudge(pickled) -def nudge(data): - HOST = sys.argv[2] - PORT = 45678 - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.connect((HOST,PORT)) - s.send(data) - s.close() - -if __name__ == "__main__" and len(sys.argv) > 1: # If not imported and more than one argument - pack()