def action(self, complete): name=complete.message().split()[0] loadAs="" if len(complete.message().split())==3: loadAs = complete.message().split()[2] loadBlacklist=["special"] if name.lower() in loadBlacklist and isAllowed(complete.userMask())<150: return ["PRIVMSG $C$ :Owner only plugin!"] if isAllowed(complete.userMask())<getLevel(complete.cmd()[0]): return ["PRIVMSG $C$ :Sorry, only elevated users can load plugins!"] if name in globalv.loadedAliases.keys(): try: extension=globalv.loadedAliases[name] unload_plugin(name) pluginName=extension.split()[0] x=__import__(pluginName) reload(x) globalv.loadedPlugins[pluginName]=x.pluginClass() load_alias(name, extension) msg="Reloaded alias "+name+" successfully!" except Exception as detail: msg="Load failure: "+str(detail) else: try: state=load_plugin(name, loadAs) msg="oaded "+name+" successfully!" msg="L"+msg if state==0 else "Rel"+msg except Exception as detail: msg="Load failure: "+str(detail) if complete.message().split()[1:]==["silently"]: return [""] else: return ["PRIVMSG $C$ :"+msg]
def action(self, complete): msg=complete.message() kickee = msg.split()[0] kickMessage=' '.join(msg.split()[1:]) if kickMessage=="": kickMessage="Go away." print "kickee", kickee, "user", complete.user(), "allowed", isAllowed(complete.userMask()), "cmd/level", complete.cmd()[0], getLevel(complete.cmd()[0]) if kickee == '$U$' or kickee == complete.user() or isAllowed(complete.userMask())>=getLevel('kick'): toKick=["KICK $C$ "+kickee+" :"+kickMessage] return toKick else: return ["PRIVMSG $C$ :ACTION kicks "+kickee+" in the shin (%s)"%kickMessage]
def action(self, complete): if isAllowed(complete.userMask())<1: return [""] MCName=complete.message().split()[0] IRCName=complete.user() settingsHandler.writeSetting("stripMCBotNames", ["minecraft", "irc"], [MCName, IRCName]) return ["PRIVMSG $C$ :Names linked - please reload stripMCBotNames for the changes to take effect"]
def action(self, complete): msg = complete.message() if isAllowed(complete.userMask()) >= getLevel(complete.cmd()[0]): trigger = msg.split()[0] command = ' '.join(msg.split()[1:]) try: if trigger not in [ x[0] for x in settingsHandler.readSettingRaw( "'core-expansions'", "trigger") ]: settingsHandler.writeSetting("'core-expansions'", ["trigger", "command"], [trigger, command]) else: settingsHandler.updateSetting("'core-expansions'", "command", command, where="trigger='%s'" % trigger) msg = "%s will now substitute to the output of %s" % (trigger, command) except Exception as detail: msg = "Failure: %s" % detail else: msg = "Sorry, you need to be elevated to use this command!" return ["PRIVMSG $C$ :" + msg]
def action(self, complete): msg = complete.message() sender = complete.userMask() if len(msg.split()) > 1: mode = msg.split()[1].lower() else: mode = "on" msg = msg.split()[0] print sender print globalv.basePlugin if msg == "list": return [ "PRIVMSG $C$ :" + ', '.join([ x[0] for x in settingsHandler.readSettingRaw( "coreAutoLoad", "loadAs") ]) ] if isAllowed(sender) >= getLevel(complete.cmd()[0]): if mode == "on": settingsHandler.writeSetting("coreAutoLoad", ["plugin", "loadAs"], [globalv.basePlugin[msg], msg]) return ["PRIVMSG $C$ :Plugin set to autoload"] else: settingsHandler.deleteSetting("coreAutoLoad", "loadAs", msg) return ["PRIVMSG $C$ :Plugin no longer autoloading"] return ["PRIVMSG $C$ :You do not have the required access rights!"]
def action(self, complete): msg=complete.message() blacklist=["quit","part","join","kick","nick","mode"] nick=complete.userMask() if isAllowed(nick)<getLevel(complete.cmd()[0]): return [""] return [msg]
def action(self, complete): msg=complete.message() amsg=msg if isAllowed(complete.userMask())<getLevel(complete.cmd()[0]): return ["PRIVMSG $C$ :No."] if msg=="*": #settingsHandler.deleteSetting("coreIgnorance","1","1") settingsHandler.dropTable("coreIgnorance") settingsHandler.newTable("coreIgnorance","ignorance","nickname") return ["PRIVMSG $C$ :Unignored everything, my lord"] if msg in globalv.miscVars[0]: msg=globalv.miscVars[0][msg] try: if amsg in [x[0] for x in settingsHandler.readSettingRaw("coreIgnorance","ignorance")]: settingsHandler.deleteSetting("coreIgnorance","ignorance",amsg) return ["PRIVMSG $C$ :"+amsg + " successfully unignored, cap'n!"] msg=".*@"+msg.split('@')[1] if msg.find('@')>0 else msg if msg in [x[0] for x in settingsHandler.readSettingRaw("coreIgnorance","ignorance")]: settingsHandler.deleteSetting("coreIgnorance","ignorance",msg) return ["PRIVMSG $C$ :"+amsg + " successfully unignored, cap'n!"] else: matches=difflib.get_close_matches(msg,[x[0] for x in settingsHandler.readSettingRaw("coreIgnorance","ignorance")],3,0.4) matches=["None"] if matches==[] else matches globalv.variables['ignored']=matches[0] return ["PRIVMSG $C$ :"+msg+" is not ignored, commander! Near matches: "+', '.join(matches)+". ~ignored~ set to nearest match."] except Exception as detail: return ["PRIVMSG $C$ :"+msg+" not unignored: "+str(detail)] return ["PRIVMSG $C$ :"+amsg + " successfully unignored, cap'n!"]
def action(self, complete): msg=complete.message() pluginBlacklist=["special"] if len(msg.split()) == 1: if msg.split()[0] in globalv.aliasExtensions.keys(): if globalv.aliasExtensions[msg.split()[0]]=="": return ["PRIVMSG $C$ :Alias has no additional arguments"] return ["PRIVMSG $C$ :!%s %s"%(globalv.basePlugin[msg.split()[0]], globalv.aliasExtensions[msg.split()[0]].strip())] else: return ["PRIVMSG $C$ : Command is not an alias!"] if msg.split()[0] in pluginBlacklist and not (isAllowed(complete.userMask())>=getLevel(complete.cmd()[0])): msg=["PRIVMSG $C$ :Restricted plugin!"] if msg.split()[0] not in globalv.loadedPlugins.keys(): try: load_alias(msg.split()[0], ' '.join(msg.split()[1:])) msg=["PRIVMSG $C$ :Alias successful."] except: msg=["PRIVMSG $C$ :Alias unsuccessful. Are you sure %s is a valid plugin?"%msg.split()[1]] else: msg=[] message=lambda x:msg.append("PRIVMSG $C$ :"+x) message("Alias unsuccessful. Syntax: "+globalv.commandCharacter+"alias [word] [command] [optional arguments]") message("Optional Arguments can include $C$, which will expand to the channel name, $U$, which will expand to the username of the person who sends it.") message("You can also use $number$ style syntax, where number is a one or two digit number representing the word of the input to take. (As in, $2$ would extract \"hi\" from \"!command hey hi\". Additionally, a + or - after the number can be used to grab all words before or after that word.") return msg
def action(self, complete): if not (isAllowed(complete.userMask()) >= getLevel(complete.cmd()[0])): return [""] msg = complete.message().strip() firstspace = msg.index(' ') message = msg[firstspace + 1:] recipients = msg[0:firstspace].lower() recipients = list(set(recipients.split(','))) recipients = [re.sub('[^0-9a-z-[\]*?]', '?', x) for x in recipients] sender = complete.user() senderMask = complete.userMask() timestamp = str(int(time.time())) message = message.replace('$U$', '$recipient$') for recipient in recipients: print recipient lastid = int(settingsHandler.readSetting("laterd", "COUNT(id)")) id = str(lastid + 1) settingsHandler.writeSetting("laterd", [ "id", "recipient", "sender", "senderMask", "timestamp", "message", "channel", "anonymous", "sent" ], [ id, recipient, sender, senderMask, timestamp, "dispatch " + message, "", "0", "0" ]) settingsHandler.db.commit() msg = ', '.join(recipients[:-1]) + ( (" and " + recipients[-1] if len(recipients) > 1 else recipients[-1]) + " will be informed when they next speak.") return ["PRIVMSG $C$ :" + msg]
def action(self, complete): msg=complete.message() isElevated=(isAllowed(complete.userMask())>=getLevel(complete.cmd()[0])) self.__init_answers__(complete) if len(msg.split())>=1: cmd=msg.split()[0] msg=' '.join(msg.split()[1:]) else: cmd="" msg="" if cmd=="-add" and isElevated: settingsHandler.writeSetting("'"+complete.cmd()[0]+"'","answer",msg) toReturn="Added that answer" self.__init_answers__(complete) elif cmd=="-delete" and isElevated: settingsHandler.deleteSetting("'"+complete.cmd()[0]+"'","answer",msg) toReturn="Wiped that answer." self.__init_answers__(complete) elif cmd=="-wipe" and isElevated: settingsHandler.dropTable("'"+complete.cmd()[0]+"'") settingsHandler.newTable("'"+complete.cmd()[0]+"'","answer") toReturn="Answer table wiped!" self.__init_answers__(complete) elif cmd=="-dump": self.__init_answers__(complete) return ["PRIVMSG $C$ :[%s]"%', '.join(["'"+x+"'" for x in self.answers])] else: toReturn=self.answers.pop() if complete.message()=="": toReturn=toReturn.replace("$1$","$U$") else: toReturn=toReturn.replace("$1$",complete.message()) return ["PRIVMSG $C$ :"+toReturn]
def action(self, complete): msg = complete.message().split() if len(msg) > 1: if isAllowed(complete.userMask()) >= getLevel(complete.cmd()[0]): try: calcInput = ":%s PRIVMSG %s :!%s %s" % (complete.userMask( ), complete.channel(), "calculate", ' '.join(msg[1:])) inputObj = formatInput(pluginArguments(calcInput)) output = ':'.join( globalv.loadedPlugins["calculate"].action( inputObj)[0].split(':')[1:]) globalv.variables[msg[0]] = str(output) with open(os.path.join("config", "variables"), 'w') as file: pickle.dump(globalv.variables, file, pickle.HIGHEST_PROTOCOL) except Exception as detail: return [ "PRIVMSG $C$ :Variable setting failure with expression !var %s: %s" % (complete.message(), detail) ] else: if msg[0] in globalv.variables.keys(): return ["PRIVMSG $C$ :%s" % globalv.variables[msg[0]]] else: return ["PRIVMSG $C$ :Undefined"] return [""]
def action(self, complete): msg = complete.message() nick = complete.userMask() amsg = msg nickname = "*Unknown*" if securityHandler.isAllowed(nick) >= getLevel(complete.cmd()[0]): if msg[0] == "#": nmsg = msg nickname = "" elif msg in globalv.miscVars[0]: nmsg = ".*@" + globalv.miscVars[0][msg].split('@')[1] nickname = msg else: nmsg = msg nmsg = nmsg.replace('*', '.*').replace('..*', '.*') fullCMD = nmsg if fullCMD not in [ x[0] for x in settingsHandler.readSettingRaw( "coreIgnorance", "ignorance") ]: settingsHandler.writeSetting("coreIgnorance", ["ignorance", "nickname"], [fullCMD, nickname]) return [ "PRIVMSG $C$ :" + amsg + " successfully ignored, cap'n!" ] else: return [ "PRIVMSG $C$ :" + amsg + " is already ignored, m'lord!" ] else: return ["PRIVMSG $C$ :Go away."]
def action(self, complete): msg = complete.message() msgBack = [] message = lambda x: msgBack.append("PRIVMSG $C$ :" + x) if isAllowed(complete.userMask()) >= getLevel(complete.cmd()[0]): if msg.split()[0] != "-remove": result = save_alias(msg) print globalv.loadedAliases.keys() if result == 1: message("Alias Saved.") elif result == 2: message("Alias unsuccessful. Alias is already set.") else: message( "Alias unsuccessful. Make sure you have previously !alias-ed this command" ) print globalv.loadedAliases.keys() else: settingsHandler.deleteSetting("alias", "aliasName", msg.split()[1]) message("Alias Removed") else: message( "Alias unsuccessful. This action requires higher priviledges. Use " + globalv.commandCharacter + "alias for temporary aliases.") return msgBack
def action(self, complete): msg=complete.message() if isAllowed(complete.userMask())>=getLevel(complete.cmd()[0]): users = msg.split() n = len(users) return ["MODE $C$ +%s %s" % ('v' * n, ' '.join(users))] else: return ["PRIVMSG $C$ :How about no."]
def action(self, complete): msg = complete.message() if isAllowed(complete.userMask()) >= getLevel(complete.cmd()[0]): users = msg.split() n = len(users) return ["MODE $C$ +%s %s" % ('v' * n, ' '.join(users))] else: return ["PRIVMSG $C$ :How about no."]
def action(self, complete): msg = complete.message() if isAllowed(complete.userMask()) >= getLevel(complete.cmd()[0]): if msg in globalv.miscVars[0].keys(): msg = globalv.miscVars[0][msg] return ['MODE $C$ -b ' + msg] else: return [""]
def action(self, complete): msg=complete.message() if isAllowed(complete.userMask())>=getLevel(complete.cmd()[0]): if msg in globalv.miscVars[0].keys(): msg=globalv.miscVars[0][msg] return ['MODE $C$ -b '+msg] else: return [""]
def action(self, complete): # Load the events self.file_name = "events-%s" % complete.cmd()[0] self.file_path = os.path.join("config", self.file_name) self.events = {} if os.path.exists(self.file_path): with open(self.file_path) as event_file: self.events = dict(pickle.load(event_file)) # Make also a dict with the lower case versions self.events_lower = dict(map(lambda (key,val): (key.lower(),val), self.events.items())) # Get the message tokens s = complete.message().split() command = s[0] if len(s) > 0 else "upcoming" def processEventName(name): return re.sub(r'\bmy\b', "%s's" % complete.user(), name, re.I) if command == "upcoming": n = re.search('\d+', complete.message()) if n is not None: n = int(n.group(0)) n = min(max(5,n),15) return self.show_upcoming(n) print 'hur', complete.message() is_set_command = re.search('^set (.+) as (.+?)$', complete.message()) if is_set_command is not None: event = processEventName(is_set_command.group(1)) date = is_set_command.group(2) return self.set_event(event, date) is_override_command = re.search('^override (.+) as (.+?)$', complete.message()) if is_override_command is not None: event = processEventName(is_override_command.group(1)) date = is_override_command.group(2) return self.override_event(event, date) if command == "remove": if isAllowed(complete.userMask()) < 150: return ["PRIVMSG $C$ :You don't have the privileges to remove events."] event = processEventName(' '.join(s[1:])) return self.delete_event(event) if command == "till": event = processEventName(' '.join(s[1:])) return self.show_countdown(event) event = processEventName(' '.join(s)) return self.show_countdown(event)
def action(self, complete): msg=complete.message() command=msg.split()[0] if command=="list": names=settingsHandler.readSettingRaw("laterd","recipient, sender, timestamp", where="sent='0' AND anonymous='0'") returns=[] for name in names: try: recipient=name[0] sender=name[1] timestamp=name[2] ctime=time.strftime("%H:%M on %d-%m-%Y",time.gmtime(int(timestamp))) message=recipient+" has a message from "+sender+" (Sent on "+ctime+")" returns.append(message) except: pass if returns==[]: returns.append("No messages.") return ["PRIVMSG $C$ :"+', '.join(returns)] elif command=="remove": try: senderString=" and sender=='%s'"%complete.user() if isAllowed(complete.userMask())>=150: senderString="" where = "recipient=%s and sent='0'" % repr(msg.split()[1].lower()) where += senderString print where settingsHandler.updateSetting("laterd","sent", "'2'", where=where) return ["PRIVMSG $C$ :Later successfully removed!"] except Exception as detail: return ["PRIVMSG $C$ :Later not removed"] else: anonymous = "0" secret_pfx = "secret::" if msg.startswith(secret_pfx): anonymous = "1" msg = msg[len(secret_pfx):] channels=[] while msg.split()[0][0]=="#": channels.append(msg.split()[0]) msg=' '.join(msg.split()[1:]) channel='|'.join(channels) recipients=list(set(msg.split()[0].lower().split(','))) recipients = [re.sub('[^0-9a-z-[\]*?]', '?', x) for x in recipients] sender=complete.user() senderMask=complete.userMask() timestamp=str(int(time.time())) message=' '.join(msg.split()[1:]) message = message.replace('$U$','$recipient$') for recipient in recipients: print recipient id=str(int(settingsHandler.readSetting("laterd", "COUNT(id)"))+1) settingsHandler.writeSetting("laterd",["id", "recipient","sender","senderMask","timestamp","message", "channel", "anonymous", "sent"],[id, recipient, sender, senderMask, timestamp, message, channel, anonymous, "0"]) settingsHandler.db.commit() return ["PRIVMSG $C$ :Ok, I'll tell "+', '.join(recipients[:-1])+(" and "+recipients[-1] if len(recipients)>1 else recipients[-1])+" that when they next speak!"] return ["PRIVMSG $C$ :"+msg]
def action(self, complete): msg = complete.message() returner = "" elevated = getLevel(complete.userMask()) >= isAllowed( complete.cmd()[0]) if msg == "": returner = "This is the %s dictionary. Run !%s -list for a list of known values!" % ( complete.cmd()[0], complete.cmd()[0]) elif msg.split()[0] == "-add" and elevated: settingsHandler.writeSetting( complete.cmd()[0], ["key", "value"], [msg.split()[1], ' '.join(msg.split()[2:])]) returner = "Key:Value pair added!" elif msg.split()[0] == "-delete" and elevated: settingsHandler.deleteSetting(complete.cmd()[0], "key", msg.split()[1]) returner = "Key removed!" elif msg.split()[0] == "-list": keypairs = [ x[0] for x in settingsHandler.readSettingRaw( complete.cmd()[0], "key") ] returner = ', '.join(keypairs) elif msg.split()[0] == "-random": keypairs = settingsHandler.readSettingRaw(complete.cmd()[0], "key, value") pairs = {} for keypair in keypairs: pairs[keypair[0].lower()] = keypair[1] import random keys = pairs.keys() random.shuffle(keys) returner = keys[0] + ": " + pairs[keys[0]] else: keypairs = settingsHandler.readSettingRaw(complete.cmd()[0], "key, value") pairs = {} for keypair in keypairs: pairs[keypair[0].lower()] = keypair[1] if unicode(msg.split()[0]).lower() in pairs.keys(): returner = pairs[unicode(msg.split()[0]).lower()] elif "default" not in pairs.keys(): returner = "No definition." matches = difflib.get_close_matches(msg.split()[0], pairs.keys(), 10, 0.1) if len(matches) > 0: returner += " Perhaps you meant: " + ', '.join( matches[:-1]) if len(matches) > 1: returner += " or " + matches[-1] else: returner += " No similar definitions" else: returner = pairs['default'] if returner == "": return [""] return ["PRIVMSG $C$ :" + returner]
def action(self, complete): msg=complete.message() mode=plugin=setting=set=where="" mode=msg.split()[0] returns="No such mode '%s'" % mode plugin=msg.split()[1] try: setting=msg.split()[2] except: setting="" try: set=' '.join(msg.split()[3:]) except: set="" if len(set.split())<3: where = '1==1' elif set.split()[-2].lower()=="where": where=set.split()[-1] set=' '.join(set.split()[:-2]) else: where="1==1" if isAllowed(complete.userMask())>=getLevel(complete.cmd()[0]): if mode=="update": settingsHandler.updateSetting(plugin, setting, set, where=where) returns="Setting updated, sir!" if mode=="delete": settingsHandler.deleteSetting(plugin, setting, set) returns="Setting removed, my lord!" if mode=="add": setting=setting.split('||') set=set.split('||') settingsHandler.writeSetting(plugin, setting, set) returns="Setting Set, Cap'n!" if mode=="drop-table": settingsHandler.dropTable(plugin) returns="Settings lost, comrade!" if mode=="list": columns=settingsHandler.readColumns(plugin) returns=', '.join(columns) if mode=="current": results=settingsHandler.readSetting(plugin, setting) results=[str(x[0]) if len(x)==1 and type(x)==tuple else x for x in results] if type(results)==list else str(results) results=', '.join(results) if type(results)==list else results returns=results if mode=="commit": settingsHandler.db.commit() returns="Committed!" if mode=="copy": settingsHandler.executeQuery("INSERT INTO '%s' SELECT * FROM '%s'"%(msg.split())) if mode=="query": results=settingsHandler.executeQuery(' '.join(msg.split()[1:])) if results!=[]: returns=str(results) else: returns="Sorry, you can't do this." return ["PRIVMSG $C$ :"+returns]
def action(self, complete): msg=complete.message() sender=complete.userMask() userAllowed=(isAllowed(sender)>=getLevel(complete.cmd()[0])) if readSetting(complete.cmd()[0],"userRequirement")=="elevated" else sender==readSetting(complete.cmd()[0],"username") if readSetting(complete.cmd()[0],"userRequirement")=="owner" else 1 if userAllowed: if msg=="": msg="QQ" return ["QUIT :"+msg] else: return ["KICK $C$ $U$ :Yeah, no."]
def action(self, complete): msg=complete.message() sender=complete.user() if isAllowed(complete.userMask())>=getLevel(complete.cmd()[0]): globalv.miscVars[2].append(msg) import random msg="LOWERING SHIELDS TO "+str(random.randint(0,100))+"%" return ["PRIVMSG $C$ :"+msg] else: return ["PRIVMSG $C$ :Don't be silly, only administrators can do that, $U$."]
def action(self, complete): if isAllowed(complete.userMask()) < 1: return [""] MCName = complete.message().split()[0] IRCName = complete.user() settingsHandler.writeSetting("stripMCBotNames", ["minecraft", "irc"], [MCName, IRCName]) return [ "PRIVMSG $C$ :Names linked - please reload stripMCBotNames for the changes to take effect" ]
def action(self, complete): if isAllowed(complete.userMask())>=getLevel(complete.cmd()[0]): url=complete.message() location=settingsHandler.readSetting(complete.cmd()[0],"location") wgetString="wget -N --directory-prefix=%s %s &"%(location, url) print wgetString os.system(wgetString) return ["PRIVMSG $C$ :Downloading %s to %s."%(url, location)] else: return ["PRIVMSG $C$ :Sorry, you need higher priviledges to download files!"]
def action(self, complete): name=complete.message() msg="There was an error in your input!" if isAllowed(complete.userMask())<getLevel(complete.cmd()[0]): return [""] if name.split()[0]=="list": return ["PRIVMSG $C$ :"+' '.join(globalv.loadedInputs.keys())] elif name.split()[0]=="clean": newDict={} for plugin in globalv.loadedInputs.keys(): if globalv.loadedInputs[plugin].isSet()==False: newDict[plugin]=globalv.loadedInputs[plugin] globalv.loadedInputs=newDict return ["PRIVMSG $C$ :ID list cleaned up manually"] elif name.split()[0]=="kickstart": globalv.input.startInputDaemons() return ["PRIVMSG $C$ :Kickstarted stalling plugins manually"] elif name.split()[0]=="reboot": definition=settingsHandler.readSetting("'core-input'","definition",where="input='%s'"%name.split()[1]) print "def" x=__import__(str(definition.split()[0])) reload(x) arguments=str(' '.join(definition.split()[1:])) arguments=shlex.split(arguments) globalv.loadedInputs[name.split()[1]]=globalv.input.addInputSource(x.asyncInput,tuple(arguments)) globalv.input.startInputDaemons() msg="Rebooting input plugin..." elif name.split()[0]=="add": name= ' '.join(name.split()[1:]) try: if name.split()[0] in globalv.loadedInputs.keys(): raise Exception("An input module with that ID already exists!") x=__import__(name.split()[1]) reload(x) arguments=shlex.split(' '.join(name.split()[2:])) globalv.loadedInputs[name.split()[0]]=globalv.input.addInputSource(x.asyncInput,tuple(arguments)) print arguments settingsHandler.writeSetting("'core-input'", ["input", "definition"], [name.split()[0], ' '.join(name.split()[1:])]) globalv.input.startInputDaemons() msg="Plugin loaded successfully!" except Exception as detail: msg="Load failure: "+str(detail) elif name.split()[0]=="send": plugin = name.split()[1] command = " ".join(name.split()[2:]) globalv.loadedInputs[plugin].put(command) msg = "Sent message to plugin" elif name.split()[0]=="autosend": name= ' '.join(name.split()[1:]) settingsHandler.writeSetting("'core-input'", ["input", "definition"], [name.split()[0], ' '.join(name.split()[1:])]) msg = "Plugin configuration added" elif name.split()[0]=="unautosend": settingsHandler.deleteSetting("'core-input'", "definition", ' '.join(name.split()[1:])) msg="Configuration removed!" return ["PRIVMSG $C$ :"+msg]
def action(self, complete): msg=complete.message() sender=complete.userMask() if isAllowed(sender)>=getLevel(complete.cmd()[0]): if msg!="": chan=msg if chan[0]!="#": chan="#"+chan msg="JOIN "+chan globalv.channels.append(chan) return [msg]
def action(self, complete): msg=complete.message() nick=complete.userMask() if isAllowed(nick)>=getLevel(complete.cmd()[0]): if msg.split()[1] in globalv.accessRights[msg.split()[0]]: globalv.accessRights[msg.split()[0]].remove(msg.split()[1]) msg="Ok, removed that restriction." else: msg="That user can already use that command!" else: msg="Sorry, only administrators can use this command!" return ["PRIVMSG $C$ :"+msg]
def action(self, complete): msg = complete.message() nick = complete.userMask() if isAllowed(nick) >= getLevel(complete.cmd()[0]): if msg.split()[1] in globalv.accessRights[msg.split()[0]]: globalv.accessRights[msg.split()[0]].remove(msg.split()[1]) msg = "Ok, removed that restriction." else: msg = "That user can already use that command!" else: msg = "Sorry, only administrators can use this command!" return ["PRIVMSG $C$ :" + msg]
def action(self, complete): msg = complete.message() if msg.split()[0] == "-list": users = settingsHandler.readSetting("autoidentifyd", "nickname, level") out = [] for name, level in users: if len(msg.split()) == 1: out.append(name + ":" + str(level)) elif msg.split()[1].lower() == name.lower(): out.append(name + ":" + str(level)) msg = ', '.join(out) elif len(msg.split()) == 1: users = settingsHandler.readSetting("autoidentifyd", "nickname, level") for name, level in users: if name == msg: return ["PRIVMSG $C$ :%s" % (level)] return ["PRIVMSG $C$ :0"] elif isAllowed(complete.userMask()) >= getLevel(complete.cmd()[0]): nick = msg.split()[0] level = msg.split()[1] if nick not in globalv.miscVars[0]: return ["PRIVMSG $C$ :That user does not exist."] if nick in [ x[0] for x in settingsHandler.readSetting( "autoidentifyd", "nickname") ]: settingsHandler.updateSetting("autoidentifyd", "level", str(level), where="nickname='%s'" % nick) msg = "Level updated" else: settingsHandler.writeSetting("autoidentifyd", ["nickname", "level"], [nick, level]) msg = "User Elevated" user = '******' + globalv.miscVars[0][nick] globalv.miscVars[2] = filter(lambda (x, y): x != user, globalv.miscVars[2]) globalv.miscVars[2].append((user, level)) print globalv.miscVars[2] else: msg = "Only elevated users can do this!" return ["PRIVMSG $C$ :" + msg]
def action(self, complete): if isAllowed(complete.userMask()) >= getLevel(complete.cmd()[0]): url = complete.message() location = settingsHandler.readSetting(complete.cmd()[0], "location") wgetString = "wget -N --directory-prefix=%s %s &" % (location, url) print wgetString os.system(wgetString) return ["PRIVMSG $C$ :Downloading %s to %s." % (url, location)] else: return [ "PRIVMSG $C$ :Sorry, you need higher priviledges to download files!" ]
def action(self, complete): msg=complete.message() if isAllowed(complete.userMask())>=getLevel(complete.cmd()[0]): kickMessage=' '.join(msg.split()[1:]) if kickMessage=="": kickMessage="Go away." toKick=["KICK $C$ "+msg.split()[0]+" :"+kickMessage] return toKick else: kickMessage=' '.join(msg.split()[1:]) if kickMessage=="": kickMessage="Go away." return ["PRIVMSG $C$ :ACTION kicks "+msg.split()[0]+" in the shin (%s)"%kickMessage]
def action(self, complete): msg=complete.message() sender=complete.channel() globalv.variables['lasttopic']=globalv.miscVars[4][complete.channel()][0] if isAllowed(complete.userMask())<getLevel(complete.cmd()[0]) and len(msg)!=0: return [""] if msg=="": return ["PRIVMSG $C$ :"+' '.join(globalv.miscVars[4][sender])] if msg.split()[0]=="add": return ["TOPIC $C$ :"+' '.join(globalv.miscVars[4][sender])+" | "+' '.join(msg.split()[1:])] elif msg.split()[0]=="remove": return ["TOPIC $C$ :"+' | '.join(' '.join(globalv.miscVars[4][sender]).split(' | ')[:-int(msg.split()[1])])] else: return["TOPIC $C$ :"+msg]
def action(self, complete): msg = complete.message() nick = complete.userMask() sender = complete.channel() if msg.split()[1] in globalv.loadedPlugins.keys(): if isAllowed(nick) >= getLevel(complete.cmd()[0]): if msg.split()[1] == "unrestrict": return ["PRIVMSG $C$ :Don't be silly."] globalv.accessRights[msg.split()[0]].append(msg.split()[1]) msg = "Ok, restricted that command for that user." else: msg = "Sorry, only administrators can use this command!" else: msg = "Plugin would not appear to exist" return ["PRIVMSG $C$ :" + msg]
def action(self, complete): msg=complete.message() nick=complete.userMask() sender=complete.channel() if msg.split()[1] in globalv.loadedPlugins.keys(): if isAllowed(nick)>=getLevel(complete.cmd()[0]): if msg.split()[1]=="unrestrict": return ["PRIVMSG $C$ :Don't be silly."] globalv.accessRights[msg.split()[0]].append(msg.split()[1]) msg="Ok, restricted that command for that user." else: msg="Sorry, only administrators can use this command!" else: msg="Plugin would not appear to exist" return ["PRIVMSG $C$ :"+msg]
def action(self, complete): msg = complete.message() sender = complete.userMask() userAllowed = ( isAllowed(sender) >= getLevel(complete.cmd()[0])) if readSetting( complete.cmd()[0], "userRequirement") == "elevated" else sender == readSetting( complete.cmd()[0], "username") if readSetting( complete.cmd()[0], "userRequirement") == "owner" else 1 if userAllowed: if msg == "": msg = "QQ" return ["QUIT :" + msg] else: return ["KICK $C$ $U$ :Yeah, no."]
def action(self, complete): msg=complete.message().split()[0] kickReason=' '.join(complete.message().split()[1:]) if kickReason=="": kickReason="Go Away." if isAllowed(complete.userMask())>=getLevel(complete.cmd()[0]): if msg in globalv.miscVars[0].keys(): hostmask=globalv.miscVars[0][msg] print hostmask toReturn=['MODE $C$ +b '+hostmask] if settingsHandler.readSetting(complete.cmd()[0], "kickAfterBan")=="True": toReturn.append("KICK $C$ "+msg+" :"+kickReason) return toReturn else: print "ID failure:",msg,"not in",globalv.miscVars[0][msg] return [""]
def action(self, complete): msg=complete.message() name=msg.split()[0] if isAllowed(complete.userMask())<getLevel(complete.cmd()[0]): return ["PRIVMSG $C$ :Sorry, only elevated users can do that!"] if name=="load" and complete[0].split()[0].split('!')[0]!=readSetting("core","username"): return ["PRIVMSG $C$ :Silly bugger, that would break the world!"] success=unload_plugin(name) if name in globalv.loadedAliases.keys(): del globalv.loadedAliases[name] if msg.split()[1:]==['silently']: return [""] if success: return ["PRIVMSG $C$ :Unload successful!"] else: return ["PRIVMSG $C$ :Plugin is not loaded!"]
def action(self, complete): msg = complete.message() amsg = msg if isAllowed(complete.userMask()) < getLevel(complete.cmd()[0]): return ["PRIVMSG $C$ :No."] if msg == "*": #settingsHandler.deleteSetting("coreIgnorance","1","1") settingsHandler.dropTable("coreIgnorance") settingsHandler.newTable("coreIgnorance", "ignorance", "nickname") return ["PRIVMSG $C$ :Unignored everything, my lord"] if msg in globalv.miscVars[0]: msg = globalv.miscVars[0][msg] try: if amsg in [ x[0] for x in settingsHandler.readSettingRaw( "coreIgnorance", "ignorance") ]: settingsHandler.deleteSetting("coreIgnorance", "ignorance", amsg) return [ "PRIVMSG $C$ :" + amsg + " successfully unignored, cap'n!" ] msg = ".*@" + msg.split('@')[1] if msg.find('@') > 0 else msg if msg in [ x[0] for x in settingsHandler.readSettingRaw( "coreIgnorance", "ignorance") ]: settingsHandler.deleteSetting("coreIgnorance", "ignorance", msg) return [ "PRIVMSG $C$ :" + amsg + " successfully unignored, cap'n!" ] else: matches = difflib.get_close_matches(msg, [ x[0] for x in settingsHandler.readSettingRaw( "coreIgnorance", "ignorance") ], 3, 0.4) matches = ["None"] if matches == [] else matches globalv.variables['ignored'] = matches[0] return [ "PRIVMSG $C$ :" + msg + " is not ignored, commander! Near matches: " + ', '.join(matches) + ". ~ignored~ set to nearest match." ] except Exception as detail: return ["PRIVMSG $C$ :" + msg + " not unignored: " + str(detail)] return ["PRIVMSG $C$ :" + amsg + " successfully unignored, cap'n!"]
def action(self, complete): msg = complete.message() name = msg.split()[0] if isAllowed(complete.userMask()) < getLevel(complete.cmd()[0]): return ["PRIVMSG $C$ :Sorry, only elevated users can do that!"] if name == "load" and complete[0].split()[0].split( '!')[0] != readSetting("core", "username"): return ["PRIVMSG $C$ :Silly bugger, that would break the world!"] success = unload_plugin(name) if name in globalv.loadedAliases.keys(): del globalv.loadedAliases[name] if msg.split()[1:] == ['silently']: return [""] if success: return ["PRIVMSG $C$ :Unload successful!"] else: return ["PRIVMSG $C$ :Plugin is not loaded!"]
def action(self, complete): name = complete.message().split()[0] if len(complete.message().split()) > 1: noKill = 1 else: noKill = 0 msg = "Successfully asked the plugin to stop" if isAllowed(complete.userMask()) < getLevel(complete.cmd()[0]): return ["PRIVMSG $C$ :Only elevated users can do that!"] try: globalv.loadedInputs[name.split()[0]].put("stop") del globalv.loadedInputs[name.split()[0]] if not noKill: settingsHandler.deleteSetting("'core-input'", "input", name) except Exception as detail: msg = "Unload failure: " + str(detail) return ["PRIVMSG $C$ :" + msg]
def action(self, complete): name=complete.message().split()[0] if len(complete.message().split())>1: noKill=1 else: noKill=0 msg="Successfully asked the plugin to stop" if isAllowed(complete.userMask())<getLevel(complete.cmd()[0]): return ["PRIVMSG $C$ :Only elevated users can do that!"] try: globalv.loadedInputs[name.split()[0]].put("stop") del globalv.loadedInputs[name.split()[0]] if not noKill: settingsHandler.deleteSetting("'core-input'","input",name) except Exception as detail: msg="Unload failure: "+str(detail) return ["PRIVMSG $C$ :"+msg]
def action(self, complete): msg=complete.message() channel=complete.channel() sender=complete.userMask() if isAllowed(sender)>=getLevel(complete.cmd()[0]): if msg!="": chan=msg if chan[0]!="#": chan="#"+chan msg="PART "+chan try: globalv.channels.remove(chan) except: pass else: msg="PART "+channel return [msg]
def action(self, complete): msg = complete.message() channel = complete.channel() sender = complete.userMask() if isAllowed(sender) >= getLevel(complete.cmd()[0]): if msg != "": chan = msg if chan[0] != "#": chan = "#" + chan msg = "PART " + chan try: globalv.channels.remove(chan) except: pass else: msg = "PART " + channel return [msg]
def action(self, complete): msg=complete.message() isElevated=(isAllowed(complete.userMask())>=getLevel(complete.cmd()[0])) self.__init_answers__(complete) hashDate = True hashUser = True if len(msg.split())>=1: cmd=msg.split()[0] msg=' '.join(msg.split()[1:]) if "-date" in msg.split(): hashUser = False if "-user" in msg.split(): hashDate = False else: cmd="" msg="" if cmd=="-add" and isElevated: settingsHandler.writeSetting("'"+complete.cmd()[0]+"'","answer",msg) toReturn="Added that answer" self.__init_answers__(complete) elif cmd=="-delete" and isElevated: settingsHandler.deleteSetting("'"+complete.cmd()[0]+"'","answer",msg) toReturn="Wiped that answer." self.__init_answers__(complete) elif cmd=="-wipe" and isElevated: settingsHandler.dropTable("'"+complete.cmd()[0]+"'") settingsHandler.newTable("'"+complete.cmd()[0]+"'","answer") toReturn="Answer table wiped!" self.__init_answers__(complete) elif cmd=="-dump": self.__init_answers__(complete) return ["PRIVMSG $C$ :[%s]"%', '.join(["'"+x+"'" for x in self.answers])] else: totalHash = 0 if hashDate: totalHash += hash(date.today()) if hashUser: totalHash += hash(complete.user()) answer = totalHash % len(self.answers) print answer, totalHash, self.answers toReturn=self.answers[answer] if complete.message()=="": toReturn=toReturn.replace("$1$","$U$") else: toReturn=toReturn.replace("$1$",complete.message()) return ["PRIVMSG $C$ :"+toReturn]
def action(self, complete): msg = complete.message().split()[0] kickReason = ' '.join(complete.message().split()[1:]) if kickReason == "": kickReason = "Go Away." if isAllowed(complete.userMask()) >= getLevel(complete.cmd()[0]): if msg in globalv.miscVars[0].keys(): hostmask = globalv.miscVars[0][msg] print hostmask toReturn = ['MODE $C$ +b ' + hostmask] if settingsHandler.readSetting(complete.cmd()[0], "kickAfterBan") == "True": toReturn.append("KICK $C$ " + msg + " :" + kickReason) return toReturn else: print "ID failure:", msg, "not in", globalv.miscVars[0][msg] return [""]
def action(self, complete): msg=complete.message() returner="" elevated = getLevel(complete.userMask()) >= isAllowed(complete.cmd()[0]) if msg=="": returner="This is the %s dictionary. Run !%s -list for a list of known values!"%(complete.cmd()[0], complete.cmd()[0]) elif msg.split()[0]=="-add" and elevated: settingsHandler.writeSetting(complete.cmd()[0],["key","value"], [msg.split()[1],' '.join(msg.split()[2:])]) returner="Key:Value pair added!" elif msg.split()[0]=="-delete" and elevated: settingsHandler.deleteSetting(complete.cmd()[0],"key",msg.split()[1]) returner="Key removed!" elif msg.split()[0]=="-list": keypairs=[x[0] for x in settingsHandler.readSettingRaw(complete.cmd()[0],"key")] returner=', '.join(keypairs) elif msg.split()[0]=="-random": keypairs=settingsHandler.readSettingRaw(complete.cmd()[0],"key, value") pairs={} for keypair in keypairs: pairs[keypair[0].lower()]=keypair[1] import random keys=pairs.keys() random.shuffle(keys) returner=keys[0]+": "+pairs[keys[0]] else: keypairs=settingsHandler.readSettingRaw(complete.cmd()[0],"key, value") pairs={} for keypair in keypairs: pairs[keypair[0].lower()]=keypair[1] if unicode(msg.split()[0]).lower() in pairs.keys(): returner=pairs[unicode(msg.split()[0]).lower()] elif "default" not in pairs.keys(): returner="No definition." matches=difflib.get_close_matches(msg.split()[0],pairs.keys(),10,0.1) if len(matches)>0: returner+=" Perhaps you meant: "+', '.join(matches[:-1]) if len(matches)>1: returner+=" or "+matches[-1] else: returner+=" No similar definitions" else: returner=pairs['default'] if returner=="": return [""] return ["PRIVMSG $C$ :"+returner]
def action(self, complete): msg=complete.message().split() if len(msg)>1: if isAllowed(complete.userMask())>=getLevel(complete.cmd()[0]): try: current = int(globalv.variables[msg[0]]) globalv.variables[msg[0]]=current + int(msg[1]) print globalv.variables with open(os.path.join("config","variables"),'w') as file: pickle.dump(globalv.variables,file,pickle.HIGHEST_PROTOCOL) except Exception as detail: return ["PRIVMSG $C$ :Variable setting failure with expression !var %s: %s"%(complete.message(), detail)] else: if msg[0] in globalv.variables.keys(): return ["PRIVMSG $C$ :%s"%globalv.variables[msg[0]]] else: return ["PRIVMSG $C$ :Undefined"] return [""]
def action(self, complete): msg=complete.message() if isAllowed(complete.userMask())>=getLevel(complete.cmd()[0]): trigger=msg.split()[0] command=' '.join(msg.split()[1:]) try: if trigger not in [x[0] for x in settingsHandler.readSettingRaw("'core-expansions'","trigger")]: settingsHandler.writeSetting("'core-expansions'",["trigger","command"],[trigger,command]) else: settingsHandler.updateSetting("'core-expansions'","command",command,where="trigger='%s'"%trigger) msg="%s will now substitute to the output of %s"%(trigger, command) except Exception as detail: msg="Failure: %s"%detail else: msg="Sorry, you need to be elevated to use this command!" return ["PRIVMSG $C$ :"+msg]
def action(self, complete): msg=complete.message() if msg.split()[0]=="-list": users=settingsHandler.readSetting("autoidentifyd","nickname, level") out=[] for name,level in users: if len(msg.split())==1: out.append(name+":"+str(level)) elif msg.split()[1].lower()==name.lower(): out.append(name+":"+str(level)) msg=', '.join(out) elif len(msg.split())==1: users=settingsHandler.readSetting("autoidentifyd","nickname, level") for name,level in users: if name==msg: return ["PRIVMSG $C$ :%s"%(level)] return ["PRIVMSG $C$ :0"] elif isAllowed(complete.userMask())>=getLevel(complete.cmd()[0]): nick = msg.split()[0] level = msg.split()[1] if nick not in globalv.miscVars[0]: return ["PRIVMSG $C$ :That user does not exist."] if nick in [x[0] for x in settingsHandler.readSetting("autoidentifyd","nickname")]: settingsHandler.updateSetting("autoidentifyd","level",str(level), where="nickname='%s'"%nick) msg="Level updated" else: settingsHandler.writeSetting("autoidentifyd",["nickname","level"], [nick, level]) msg="User Elevated" user = '******' + globalv.miscVars[0][nick] globalv.miscVars[2] = filter(lambda (x,y): x != user, globalv.miscVars[2]) globalv.miscVars[2].append((user, level)) print globalv.miscVars[2] else: msg="Only elevated users can do this!" return ["PRIVMSG $C$ :"+msg]
def action(self, complete): msg = complete.message() isElevated = (isAllowed(complete.userMask()) >= getLevel( complete.cmd()[0])) beRandom = True if len(self.answers) == 0: self.__init_answers__(complete, beRandom) if len(msg.split()) >= 1: cmd = msg.split()[0] msg = ' '.join(msg.split()[1:]) else: cmd = "" msg = "" if cmd == "-add" and isElevated: settingsHandler.writeSetting("'" + complete.cmd()[0] + "'", "answer", msg) toReturn = "Added that answer" self.__init_answers__(complete, beRandom) elif cmd == "-delete" and isElevated: settingsHandler.deleteSetting("'" + complete.cmd()[0] + "'", "answer", msg) toReturn = "Wiped that answer." self.__init_answers__(complete, beRandom) elif cmd == "-wipe" and isElevated: settingsHandler.dropTable("'" + complete.cmd()[0] + "'") settingsHandler.newTable("'" + complete.cmd()[0] + "'", "answer") toReturn = "Answer table wiped!" self.__init_answers__(complete, beRandom) elif cmd == "-reset" and isElevated: self.__init_answers__(complete, beRandom) toReturn = "Re-randomising list..." else: toReturn = self.answers.pop() inputs = ":%s PRIVMSG %s :!%s" % (complete.userMask(), complete.channel(), toReturn) input = formatInput(pluginArguments(inputs)) pluginOut = globalv.loadedPlugins[toReturn.split()[0]].action( input) return pluginOut return ["PRIVMSG $C$ :" + toReturn]
def action(self, complete): msg = complete.message() isElevated = (isAllowed(complete.userMask()) >= getLevel( complete.cmd()[0])) self.__init_answers__(complete) if len(msg.split()) >= 1: cmd = msg.split()[0] msg = ' '.join(msg.split()[1:]) else: cmd = "" msg = "" if cmd == "-add" and isElevated: settingsHandler.writeSetting("'" + complete.cmd()[0] + "'", "answer", msg) toReturn = "Added that answer" self.__init_answers__(complete) elif cmd == "-delete" and isElevated: settingsHandler.deleteSetting("'" + complete.cmd()[0] + "'", "answer", msg) toReturn = "Wiped that answer." self.__init_answers__(complete) elif cmd == "-wipe" and isElevated: settingsHandler.dropTable("'" + complete.cmd()[0] + "'") settingsHandler.newTable("'" + complete.cmd()[0] + "'", "answer") toReturn = "Answer table wiped!" self.__init_answers__(complete) elif cmd == "-dump": self.__init_answers__(complete) return [ "PRIVMSG $C$ :[%s]" % ', '.join(["'" + x + "'" for x in self.answers]) ] else: toReturn = self.answers.pop() if complete.message() == "": toReturn = toReturn.replace("$1$", "$U$") else: toReturn = toReturn.replace("$1$", complete.message()) return ["PRIVMSG $C$ :" + toReturn]
def action(self, complete): msg = complete.message() pluginBlacklist = ["special"] if len(msg.split()) == 1: if msg.split()[0] in globalv.aliasExtensions.keys(): if globalv.aliasExtensions[msg.split()[0]] == "": return ["PRIVMSG $C$ :Alias has no additional arguments"] return [ "PRIVMSG $C$ :!%s %s" % (globalv.basePlugin[msg.split()[0]], globalv.aliasExtensions[msg.split()[0]].strip()) ] else: return ["PRIVMSG $C$ : Command is not an alias!"] if msg.split()[0] in pluginBlacklist and not (isAllowed( complete.userMask()) >= getLevel(complete.cmd()[0])): msg = ["PRIVMSG $C$ :Restricted plugin!"] if msg.split()[0] not in globalv.loadedPlugins.keys(): try: load_alias(msg.split()[0], ' '.join(msg.split()[1:])) msg = ["PRIVMSG $C$ :Alias successful."] except: msg = [ "PRIVMSG $C$ :Alias unsuccessful. Are you sure %s is a valid plugin?" % msg.split()[1] ] else: msg = [] message = lambda x: msg.append("PRIVMSG $C$ :" + x) message("Alias unsuccessful. Syntax: " + globalv.commandCharacter + "alias [word] [command] [optional arguments]") message( "Optional Arguments can include $C$, which will expand to the channel name, $U$, which will expand to the username of the person who sends it." ) message( "You can also use $number$ style syntax, where number is a one or two digit number representing the word of the input to take. (As in, $2$ would extract \"hi\" from \"!command hey hi\". Additionally, a + or - after the number can be used to grab all words before or after that word." ) return msg
def action(self, complete): msg = complete.message() print globalv.basePlugin if (isAllowed(complete.userMask()) < getLevel(complete.cmd()[0])): return [ "PRIVMSG $C$ :You do not have the neccesary access rights to perform this operation" ] if (msg.split()[0] in globalv.loadedAliases.keys()): if (len(msg.split()) == 2): result = rename_alias(msg.split()[0], msg.split()[1]) if (result): return ["PRIVMSG $C$ :Alias renamed!"] else: return ["PRIVMSG $C$ :Alias could not be renamed!"] else: if (len(msg.split()) == 2): result = rename_plugin(msg.split()[0], msg.split()[1]) if (result): return ["PRIVMSG $C$ :Command renamed!"] else: return ["PRIVMSG $C$ :Command could not be renamed!"] return ["PRIVMSG $C$ :Invalid arguments"]