def handle_privmsg(self, msg): if msg.text[0] == chr(1) and len(msg.text) > 2 and msg.text[-1] == chr(1): self.handle_ctcp(msg) return if msg.target != self.config.nick: if msg.text[0] == '!' and len(msg.text) > 1: split = msg.text[1:].split(' ', 1) command = split[0] text = '' if len(split) > 1: text = split[1] if config.settings['autoreload']: global commands_mtime new_mtime = os.stat('commands.py').st_mtime if new_mtime > commands_mtime: imp.reload(commands) commands_mtime = new_mtime handler = commands.handlers.get(command) if handler: handler(self, msg.target, msg.nick, command, text) else: commands.youtube(self, msg) commands.cpypt(self, msg)
def handle_privmsg(self, msg): if msg.text[0] == chr(1) and len( msg.text) > 2 and msg.text[-1] == chr(1): self.handle_ctcp(msg) return if msg.target != self.config.nick: if msg.text[0] == '!' and len(msg.text) > 1: split = msg.text[1:].split(' ', 1) command = split[0] text = '' if len(split) > 1: text = split[1] if config.settings['autoreload']: global commands_mtime new_mtime = os.stat('commands.py').st_mtime if new_mtime > commands_mtime: imp.reload(commands) commands_mtime = new_mtime handler = commands.handlers.get(command) if handler: handler(self, msg.target, msg.nick, command, text) else: commands.youtube(self, msg) commands.cpypt(self, msg)
def handle_privmsg(self, msg): if msg.text[0] == chr(1) and len(msg.text) > 2 and msg.text[-1] == chr(1): self.handle_ctcp(msg) return if msg.target != self.config.nick: if msg.text[0] == '!' and len(msg.text) > 1: split = msg.text[1:].split(' ', 1) command = split[0] text = '' if len(split) > 1: text = split[1] if config.settings['autoreload']: global commands_mtime new_mtime = os.stat('commands.py').st_mtime if new_mtime > commands_mtime: imp.reload(commands) commands_mtime = new_mtime handler = commands.handlers.get(command) if handler: handler(self, msg.target, msg.nick, command, text) elif msg.text.startswith('>>> '): commands.python_inline(self, msg) elif msg.text.startswith('>>>>'): if len(msg.text) == 4: commands.python_multiline(self, msg) del self.scripts[msg.nick] elif msg.text[4] == ' ': if len(self.scripts[msg.nick]) >= 16: bot.say(msg.target, '%s: script cannot be longer than 16 lines' % msg.nick) else: self.scripts[msg.nick].append(msg.text[5:]) else: commands.youtube(self, msg)
def execute(cn, inp, ctxnum): return { 'GOOGLE': commands.google(inp, ctxnum), 'YOUTUBE': commands.youtube(inp), }.get(cn)