def action(self, complete): msg = complete.message() output = msg.split('>')[-1] if output == msg or len(output.split()) != 1: output = "$C$" else: msg = msg.split('>')[0] commandlist = msg.split('&&') returns = [] for msg in commandlist: msg = msg.replace('\|', '__PIPE__') commands = msg.split('|') commands = map(lambda x: x.replace('__PIPE__', '|'), commands) pluginOutput = "" for command in commands: plugin = command.split()[0] args = ' '.join(command.split()[1:]) if globalv.loadedPlugins[plugin].__append_seperator__( ) == True: args += "::" args += pluginOutput arguments = pluginArguments(complete.complete()) # print "======", arguments.complete() firstBit = arguments.complete().split(' :')[0] if isinstance(args, unicode): args = args.encode('utf-8') arguments.setComplete(firstBit + " :" + globalv.commandCharacter + plugin + " " + args) arguments = formatInput(arguments) pluginOutput = globalv.loadedPlugins[plugin].action(arguments) # print pluginOutput if pluginOutput != [""]: starter = pluginOutput[0].split(' :')[0] # print starter if starter.split()[0] == "PRIVMSG": content = "" pluginOutput = [x for x in pluginOutput if x != ""] for i, line in enumerate(pluginOutput): content += ' :'.join(line.split(' :')[1:]) + ( " | " if i != len(pluginOutput) - 1 else "") # print content pluginOutput = starter + (' :' + content if content != "" else "") pluginOutput = ' :'.join( pluginOutput.split(' :') [1:]) if command != commands[-1] else pluginOutput # print pluginOutput else: pluginOutput = "" if type(pluginOutput) != list: pluginOutput = pluginOutput.replace('$C$', output) else: pluginOutput = [x.replace('$C$', output) for x in pluginOutput] outputstr = formatOutput(pluginOutput, complete) if outputstr != "": #returns.append(outputstr) returns += outputstr return returns
def action(self, complete): commands = shlex.split(complete.message()) commands = [c.replace("\x00","") for c in commands] #Working around a unicode bug in shlex commandString = commands[0] commands = commands[1:15] commandString = commandString.split(' ',1) outputList=[] for command in commands: if len(commandString)>1: argumentsToRun = self.expand(commandString[1], command) else: argumentsToRun = command commandToRun = commandString[0] print "Running command", commandToRun, "with arguments", argumentsToRun print "Constructing plugin object" arguments = pluginArguments(complete.complete()) firstBit=arguments.complete().split(':')[1] arguments.setComplete(":"+firstBit+":"+globalv.commandCharacter+commandToRun+" "+argumentsToRun) print "Pre-formatting plugin object:", arguments.complete() arguments=formatInput(arguments) print "Running command" pluginOutput=globalv.loadedPlugins[commandToRun].action(arguments) print "Formatting output" output = formatOutput(pluginOutput, complete) print "Decoding output" output = [o for o in output] print "Success! Adding output to output list",output outputList+=output return outputList
def action(self, complete): user = complete.user() if complete.type() != "JOIN": return [""] returns = [] messages = settingsHandler.readSettingRaw("greetd", "channel,greet") if complete.channel().lower() in [ message[0].lower() for message in messages ]: greetPlugin = settingsHandler.readSetting("greetd", "greet", where="channel='%s'" % complete.channel()) senderMask = complete.userMask() arguments = pluginArguments( str(':' + senderMask + " PRIVMSG " + complete.channel() + " :!" + greetPlugin + " " + complete.user())) arguments = formatInput(arguments) print[arguments.complete()] arguments.argument = str(arguments.argument) message = globalv.loadedPlugins[greetPlugin].action(arguments) print message message = formatOutput(message, arguments) returns += message return returns
def action(self, complete): commands = shlex.split(complete.message()) commands = [c.replace("\x00", "") for c in commands] #Working around a unicode bug in shlex commandString = commands[0] commands = commands[1:15] commandString = commandString.split(' ', 1) outputList = [] for command in commands: if len(commandString) > 1: argumentsToRun = self.expand(commandString[1], command) else: argumentsToRun = command commandToRun = commandString[0] print "Running command", commandToRun, "with arguments", argumentsToRun print "Constructing plugin object" arguments = pluginArguments(complete.complete()) firstBit = arguments.complete().split(':')[1] arguments.setComplete(":" + firstBit + ":" + globalv.commandCharacter + commandToRun + " " + argumentsToRun) print "Pre-formatting plugin object:", arguments.complete() arguments = formatInput(arguments) print "Running command" pluginOutput = globalv.loadedPlugins[commandToRun].action( arguments) print "Formatting output" output = formatOutput(pluginOutput, complete) print "Decoding output" output = [o for o in output] print "Success! Adding output to output list", output outputList += output return outputList
def action(self, complete): msg=complete.message() output=msg.split('>')[-1] if output==msg or len(output.split())!=1: output="$C$" else: msg=msg.split('>')[0] commandlist=msg.split('&&') returns=[] for msg in commandlist: msg=msg.replace('\|','__PIPE__') commands=msg.split('|') commands=map(lambda x: x.replace('__PIPE__','|'), commands) pluginOutput="" for command in commands: plugin=command.split()[0] args=' '.join(command.split()[1:]) if globalv.loadedPlugins[plugin].__append_seperator__()==True: args+="::" args+=pluginOutput arguments=pluginArguments(complete.complete()) # print "======", arguments.complete() firstBit=arguments.complete().split(' :')[0] if isinstance(args, unicode): args = args.encode('utf-8') arguments.setComplete(firstBit+" :"+globalv.commandCharacter+plugin+" "+args) arguments=formatInput(arguments) pluginOutput=globalv.loadedPlugins[plugin].action(arguments) # print pluginOutput if pluginOutput!=[""]: starter=pluginOutput[0].split(' :')[0] # print starter if starter.split()[0]=="PRIVMSG": content="" pluginOutput=[x for x in pluginOutput if x!=""] for i,line in enumerate(pluginOutput): content+=' :'.join(line.split(' :')[1:])+(" | " if i!=len(pluginOutput)-1 else "") # print content pluginOutput=starter+(' :'+content if content!="" else "") pluginOutput=' :'.join(pluginOutput.split(' :')[1:]) if command!=commands[-1] else pluginOutput # print pluginOutput else: pluginOutput="" if type(pluginOutput)!=list: pluginOutput=pluginOutput.replace('$C$', output) else: pluginOutput=[x.replace('$C$', output) for x in pluginOutput] outputstr=formatOutput(pluginOutput,complete) if outputstr!="": #returns.append(outputstr) returns+=outputstr return returns
def action(self, complete): user=complete.user() if complete.type()!="JOIN": return [""] returns=[] messages=settingsHandler.readSettingRaw("greetd","channel,greet") if complete.channel().lower() in [message[0].lower() for message in messages]: greetPlugin=settingsHandler.readSetting("greetd","greet",where="channel='%s'"%complete.channel()) senderMask=complete.userMask() arguments=pluginArguments(str(':'+senderMask+" PRIVMSG "+complete.channel()+" :!"+greetPlugin+" "+complete.user())) arguments=formatInput(arguments) print [arguments.complete()] arguments.argument = str(arguments.argument) message=globalv.loadedPlugins[greetPlugin].action(arguments) print message message = formatOutput(message, arguments) returns+=message return returns
def action(self, args): complete=args.complete()[1:].split(':',1) if len(complete[0].split())>2: msg=args.message() laterMessages = self.getLater(args.user()) msg=[] if args.channel!=globalv.nickname: if laterMessages!="": if laterMessages[1].split()[0] in globalv.loadedPlugins.keys(): toSend=pluginArguments(":"+laterMessages[0]+" PRIVMSG $C$ :"+globalv.commandCharacter+laterMessages[1]) output=globalv.loadedPlugins[laterMessages[1].split()[0]].action(toSend) print output,'###' msg+=(formatOutput(output,args)) else: msg+=(["PRIVMSG $C$ :Hey, "+args.user()+": "+laterMessages[0].split('!')[0]+" said "+laterMessages[1]]) self.remLater(args.user()) msg+=["PRIVMSG $C$ :(From "+laterMessages[0].split('!')[0]+" to "+args.user()+")"] return msg return [""]
def __init__(self,outputQueue, inputQueue): running = True self.Queue=outputQueue urlQueue = Queue.Queue() globalv.communication["urlFollowQueue"] = urlQueue while running: while not inputQueue.empty(): data = inputQueue.get() if data == "stop": running = False newData = urlQueue.get() complete, outputFunction = newData try: returnData = formatOutput(outputFunction(complete), complete)[0] if returnData!="": outputQueue.put("#%s\r\n"%returnData) except: print "urlFollowd failued:",complete.complete() del globalv.communication["urlFollowQueue"]
def __init__(self, outputQueue, inputQueue): running = True self.Queue = outputQueue urlQueue = Queue.Queue() globalv.communication["urlFollowQueue"] = urlQueue while running: while not inputQueue.empty(): data = inputQueue.get() if data == "stop": running = False newData = urlQueue.get() complete, outputFunction = newData try: returnData = formatOutput(outputFunction(complete), complete)[0] if returnData != "": outputQueue.put("#%s\r\n" % returnData) except: print "urlFollowd failued:", complete.complete() del globalv.communication["urlFollowQueue"]
def parse(msg): arguments=pluginArguments(msg) global load_plugin global unload_plugin global isAllowed global isBanned global load_alias global save_alias if not isBanned(arguments): if arguments.cmd()[0]=="reimportGlobalVariables" and arguments.user()==owner: reload(globalv) reload(pluginHandler) reload(aliasHandler) reload(securityHandler) load_plugin=pluginHandler.load_plugin unload_plugin=pluginHandler.unload_plugin isAllowed=securityHandler.isAllowed isBanned=securityHandler.isBanned load_alias=aliasHandler.load_alias save_alias=aliasHandler.save_alias load_plugin("load") message("Reloaded globalv variables. You may encounter some slight turbulence as we update.",arguments.channel()) elif arguments.cmd()[0] in globalv.loadedPlugins.keys(): if arguments.cmd()[0] not in globalv.accessRights[arguments.user()]: try: arguments=formatInput(arguments) output=globalv.loadedPlugins[arguments.cmd()[0]].action(arguments) output=formatOutput(output,arguments) if type(output)==list: output=[x for x in output if x!=""] send(output) except Exception as detail: print arguments.cmd()[0], "failed:",str(detail) traceback.print_tb(sys.exc_info()[2]) else: output=globalv.loadedPlugins[arguments.cmd[0]].disallowed(formatInput(arguments)) send(formatOutput(lines,arguments)) else: verboseAutoComplete = True if settingsHandler.readSetting("coreSettings", "verboseAutoComplete")=="True" else False command=arguments.cmd()[0] nearMatches=difflib.get_close_matches(command, globalv.loadedPlugins.keys(), 6, 0.5) nearestMatch=difflib.get_close_matches(command, globalv.loadedPlugins.keys(),1,0.6) commandExists = os.path.exists(os.path.join("plugins","command",command+".py")) returns=[] if nearMatches==[]: if not commandExists: if not verboseAutoComplete: return returns=["PRIVMSG $C$ :No such command!"] else: returns=["PRIVMSG $C$ :Command not loaded!"] elif nearestMatch==[]: if not commandExists: if not verboseAutoComplete: return returns=["PRIVMSG $C$ :No such command! Did you mean: %s"%', '.join(nearMatches)] else: returns=["PRIVMSG $C$ :Command not loaded! Did you mean: %s"%', '.join(nearMatches)] else: newArguments=arguments.complete()[1:] constructArguments=newArguments.split(' :',1) commands=constructArguments[1].split() commands[0]=globalv.commandCharacter+nearestMatch[0] constructArguments[1]=' '.join(commands) newArguments=':'+' :'.join(constructArguments) parse(newArguments) if (arguments.cmd()[0].lower()!=nearestMatch[0].lower()): if len(nearMatches)>1: returns=["PRIVMSG $C$ :(Command name auto-corrected from %s to %s [Other possibilities were: %s])"%(arguments.cmd()[0], nearestMatch[0], ', '.join(nearMatches[1:]))] else: returns=["PRIVMSG $C$ :(Command name auto-corrected from %s to %s)"%(arguments.cmd()[0], nearestMatch[0])] send(formatOutput(returns, arguments))
print data for datum in data.split('\r\n')[0:-1]: if datum[:1]!="#": for plugin in globalv.loadedPreprocess.keys(): try: datum=globalv.loadedPreprocess[plugin].action(pluginArguments(datum)) except Exception as detail: print plugin, "failed:",detail traceback.print_tb(sys.exc_info()[2]) if datum=="": break arguments=pluginArguments(datum) for plugin in sorted(globalv.loadedRealtime.keys()): try: output=globalv.loadedRealtime[plugin].action(arguments) send(formatOutput(output,arguments)) except Exception as detail: print plugin, "failed:",str(detail) traceback.print_tb(sys.exc_info()[2]) if datum.split()[0]=="ERROR": sys.exit(0) if datum.split()[0]=="PING": send("PONG "+datum.split(':')[1]) if len(datum.split())>1: if datum.split()[1]==NickInUse: send("NICK SomebodyStole"+nickname+str(random.randint(0,50))) if datum.split()[1]==motdEnd: okToSend=True send("NICKSERV IDENTIFY "+password) for channel in globalv.channels: send("JOIN "+channel)