def start(self, *args): if self.sender == self.bot.bot_master: self.run(args) else: messages.send_message( self.bot, self.sender + ", I only listen to my master.", self.sender)
def run(self, args): params = args[0][0] if len(params) == 0: messages.send_message( self.bot, self.sender + ", '!join' takes a required parameter -- <channel> ", self.sender) else: if len(params) > 1: channel = params[1] try: joined = self.join(channel) if joined: messages.print_message("Joined " + channel, messages.MessageType.SUCCESS) messages.send_message(self.bot, "Joined " + channel, self.sender) except Exception as error: messages.print_message(str(error), messages.MessageType.EXCEPTION) messages.send_message(self.bot, str(error), self.sender) else: messages.send_message( self.bot, self.sender + ", '!join' takes a required parameter -- <channel> ", self.sender)
def run(self, *args): params = args[0][0][0] if len(params) == 0: messages.send_message( self.bot, self.sender + ", '!torch' takes a required parameter -- <processName> ", self.sender) else: if len(params) > 1: process = params[1] self.torch(process) else: messages.send_message( self.bot, self.sender + ", '!torch' takes a required parameter - <processName>", self.sender)
def start(self): try: if logging.Logger.verbosity_level >= logging.Verbosity.DEFAULT: messages.print_message( "Running '" + self.plugin + "' for %s" % self.sender, messages.MessageType.NOTICE) self.start_plugin(self.plugin, self.args) except Exception as exception: if self.channel is not None: messages.send_message( self.bot, "That plugin cannot be activated at the moment.", self.channel) else: messages.send_message( self.bot, "That plugin cannot be activated at the moment.", self.sender)
def process_command(bundle): # Check if we have an acceptable nick. if len(bundle.sender) < 32: # Parse our command. args = bundle.contents.split(" ") c = args[0] # Restart the bot if the master says so. if c.lower() == "!!restart": if bundle.sender == bundle.bot.bot_master: utils.restart_program() # Continue loading the plugin. command = bundle.bot.commands.get(c, null) if command != null: if isinstance(command, str): # Reply to the user or channel if bundle.channel is not None: messages.send_message(bundle.bot, command, bundle.channel) else: messages.send_message(bundle.bot, command, bundle.sender) else: # Create a new loader instance and run the plugin with args. try: name = args[0].strip(bundle.bot.prefix).lower() args[0] = bundle.sender plugin = utils.Loader(bundle.bot, name, bundle.sender, bundle.channel, args) command.loader = plugin command.sender = bundle.sender command.channel = bundle.channel plugin.start() except Exception as error: messages.send_message(bundle.bot, str(error), bundle.sender) if logging.Logger.verbosity_level > logging.Logger.NONE: messages.print_message(str(error), messages.MessageType.EXCEPTION, True)
def run(self, *args): params = args[0][0][0] if len(params) == 0: messages.send_message( self.bot, self.sender + ", '!kick' takes a required parameter -- <username> ", self.sender) else: if len(params) > 1: try: username = params[1] self.bot.irc.send( utils.encode("KICK " + self.channel + " " + username + "\n")) except: messages.send_message( self.bot, self.sender + ", I can't kick anybody.", self.sender) else: messages.send_message( self.bot, self.sender + ", '!kick' takes a required parameter - <username>", self.sender)
def torch(self, name): if name: try: import subprocess, signal, os p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE) out, err = p.communicate() processes = out.splitlines() count = 0 for process in processes: if str(process).find(name) != -1: count += 1 try: pid = int(process.split(None, 1)[0]) messages.send_message( self.bot, "\x02Process\x02: " + str(process), self.sender) messages.send_message(self.bot, "\x02PID\x02: " + str(pid), self.sender) os.kill(pid, signal.SIGKILL) messages.send_message( self.bot, "\x0309Process " + str(pid) + " has been terminated.\n", self.sender) except Exception as error: messages.send_message(self.bot, str(error), self.sender) if count == 0: messages.send_message( self.bot, "No processes could be found containing the name: \"" + name + "\"", self.sender) except Exception as error: messages.send_message(self.bot, str(error), self.sender) else: messages.send_message( self.bot, self.sender + ", '!torch' does not allow null names.", self.sender)
def start(self, *args): if len(args) == 0: messages.send_message( self.bot, self.sender + ", ''!leave' takes a required parameter -- <channel>", self.sender) else: params = args[0][0] channel = params[1] if len(params) > 0: if self.sender == self.bot.bot_master: try: messages.send_message( self.bot, "Attempting to leave: " + channel, self.sender) self.bot.irc.send( utils.encode("PART " + channel + "\n")) messages.send_message(self.bot, "Left " + channel, self.sender) except Exception as error: messages.send_message(self.bot, "Unable to leave: " + channel, self.sender) else: messages.send_message( self.bot, self.sender + ", I only listen to my master.", self.sender) else: messages.send_message( self.bot, self.sender + ", ''!leave' takes a required parameter -- <channel>", self.sender)