def action(self, complete): msg=complete.message() votes=int(settingsHandler.readSetting(complete.cmd()[0], "votes")) plugin=settingsHandler.readSetting(complete.cmd()[0], "plugin") user=complete.userMask().split('!')[1] if msg.lower() in self.Voted.keys(): if user in self.Voted[msg.lower()]: return ["PRIVMSG $C$ :You have already voted!"] else: self.Voted[msg.lower()].append(user) numRequired=votes-len(self.Voted[msg.lower()]) if numRequired>0: if msg!="": msg=" "+msg if numRequired!=1: s="s" else: s="" return ["PRIVMSG $C$ :Voted to %s%s. %s more vote%s required."%(plugin,msg,numRequired,s)] else: self.Voted[msg.lower()]=[user] numRequired=votes-len(self.Voted[msg.lower()]) if msg!="": msg=" "+msg if numRequired!=1: s="s" else: s="" return ["PRIVMSG $C$ :Voted to %s%s. %s more vote%s required."%(plugin,msg,numRequired,s)] if len(self.Voted[msg.lower()])>=votes: input=":%s!%s PRIVMSG %s :!%s %s"%(globalv.nickname,globalv.miscVars[0][globalv.nickname],complete.channel(),plugin, msg) inputObj=formatInput(pluginArguments(input)) output=globalv.loadedPlugins[plugin.split()[0]].action(inputObj) self.Voted[msg.lower()]=[] return output
def action(self, complete): reload(braceParser) parseBraces = braceParser.parseBraces try: msg = parseBraces(complete.fullMessage()) except Exception as detail: return ["PRIVMSG $C$ :Parse Failure: " + str(detail)] conditionState = True toReturn = [] for condition in msg[0]: try: calcInput = ":%s PRIVMSG %s :!%s %s" % (complete.userMask(), complete.channel(), "calculate", condition) inputObj = formatInput(pluginArguments(calcInput)) output = ':'.join(globalv.loadedPlugins["calculate"].action( inputObj)[0].split(':')[1:]) if output == "False": conditionState = False break except Exception as detail: return [ "PRIVMSG $C$ :Conditional execution failure in %s" % condition, "PRIVMSG $C$ :Reason:%s" % str(detail) ] if conditionState == True: commandList = msg[1][0].split(';') elif len(msg[1]) > 1: commandList = msg[1][1].split(';') else: commandList = [] for command in commandList: try: plugin = command.split()[0] args = ' '.join(command.split()[1:]) input = ":%s PRIVMSG %s :!%s %s" % ( complete.userMask(), complete.channel(), plugin, args) inputObj = formatInput(pluginArguments(input)) toReturn += [ x.replace('\x00', '').encode('utf-8') for x in globalv.loadedPlugins[plugin.split()[0]].action(inputObj) ] except Exception as detail: return [ "PRIVMSG $C$ :!if failure in command %s" % command, "PRIVMSG $C$ :Reason:%s" % str(detail) ] return toReturn
def action(self, complete): msg = complete.message() votes = int(settingsHandler.readSetting(complete.cmd()[0], "votes")) plugin = settingsHandler.readSetting(complete.cmd()[0], "plugin") user = complete.userMask().split('!')[1] if msg.lower() in self.Voted.keys(): if user in self.Voted[msg.lower()]: return ["PRIVMSG $C$ :You have already voted!"] else: self.Voted[msg.lower()].append(user) numRequired = votes - len(self.Voted[msg.lower()]) if numRequired > 0: if msg != "": msg = " " + msg if numRequired != 1: s = "s" else: s = "" return [ "PRIVMSG $C$ :Voted to %s%s. %s more vote%s required." % (plugin, msg, numRequired, s) ] else: self.Voted[msg.lower()] = [user] numRequired = votes - len(self.Voted[msg.lower()]) if msg != "": msg = " " + msg if numRequired != 1: s = "s" else: s = "" return [ "PRIVMSG $C$ :Voted to %s%s. %s more vote%s required." % (plugin, msg, numRequired, s) ] if len(self.Voted[msg.lower()]) >= votes: input = ":%s!%s PRIVMSG %s :!%s %s" % ( globalv.nickname, globalv.miscVars[0][globalv.nickname], complete.channel(), plugin, msg) inputObj = formatInput(pluginArguments(input)) output = globalv.loadedPlugins[plugin.split()[0]].action(inputObj) self.Voted[msg.lower()] = [] return output
def action(self, complete): reload(braceParser) parseBraces=braceParser.parseBraces try: msg=parseBraces(complete.fullMessage()) except Exception as detail: return ["PRIVMSG $C$ :Parse Failure: "+str(detail)] conditionState=True toReturn=[] for condition in msg[0]: try: calcInput=":%s PRIVMSG %s :!%s %s"%(complete.userMask(),complete.channel(),"calculate", condition) inputObj=formatInput(pluginArguments(calcInput)) output=':'.join(globalv.loadedPlugins["calculate"].action(inputObj)[0].split(':')[1:]) if output=="False": conditionState=False break except Exception as detail: return ["PRIVMSG $C$ :Conditional execution failure in %s"%condition,"PRIVMSG $C$ :Reason:%s"%str(detail)] if conditionState==True: commandList=msg[1][0].split(';') elif len(msg[1])>1: commandList=msg[1][1].split(';') else: commandList=[] for command in commandList: try: plugin=command.split()[0] args=' '.join(command.split()[1:]) input=":%s PRIVMSG %s :!%s %s"%(complete.userMask(),complete.channel(),plugin, args) inputObj=formatInput(pluginArguments(input)) toReturn+=[x.replace('\x00','').encode('utf-8') for x in globalv.loadedPlugins[plugin.split()[0]].action(inputObj)] except Exception as detail: return ["PRIVMSG $C$ :!if failure in command %s"%command,"PRIVMSG $C$ :Reason:%s"%str(detail)] return toReturn