def list_module(modules, module): if module: response = None # TODO else: response = split_response(modules, "Modules: {};") return response
def list_module(bot, module): if module: pass else: response = split_response(bot.modules, "Modules: {};") return response
def listchat_command(bot, context, message, args): chats = context.session.get({}) if chats: response = split_response("I'm chatting with {} on {}".format(nick, chan) for chan, nick in chats.keys()) else: response = "I'm not chatting with anyone anywhere." return response, Notice(context.nick)
def get_command_help(bot, command): has_help = False for docstring in filter_plugins(bot.plugins, command): if docstring is not None: has_help = True yield split_response(docstring.split(), separator=' ') if not has_help: yield "There is no help entry for the command: {}.".format(command)
def show_disabled_modules(database, channel): disabled_channel_modules = database.get({}).get(channel.lower(), []) if disabled_channel_modules: response = split_response( disabled_channel_modules, "Disabled modules in {}: {};".format(channel, '{}')) else: response = "I have no modules disabled in {}.".format(channel) return response
def show_masks(database): masks = database.get([]) if masks: response = split_response(masks, "Admin masks: {};") else: response = "I don't have any admin masks." return response
def show_ignores(database, channel): ignores = database.get(set()) if ignores: response = split_response(ignores, "I am currently ignoring: {}.") else: response = "I am not ignoring anyone." return response
def show_ignores(database, channel): ignores = get_ignores(database) if ignores: response = split_response(ignores, "I am currently ignoring: {}.") else: response = "I am not ignoring anyone." return response
def listchat_command(bot, context, message, args): chats = context.session.get({}) if chats: response = split_response( "I'm chatting with {} on {}".format(nick, chan) for chan, nick in chats.keys()) else: response = "I'm not chatting with anyone anywhere." return response, Notice(context.nick)
def show_ignores(database, channel): channel_ignores = database.get({}).get(channel, set()) if channel_ignores: response = split_response( channel_ignores, "I am currently ignoring: {} on {}".format('{}', channel)) else: response = "I am not ignoring anyone on {}.".format(channel) return response
def show_triggers(database): patterns = get_patterns(database) if not patterns: responses = "There are no patterns currently saved." else: triggers = map(lambda x: x[0].pattern, patterns) responses = split_response(triggers, "Triggers: {};") return responses
def show_ignores(database, channel): channel_ignores = database.get({}).get(channel, []) if channel_ignores: response = split_response( channel_ignores, "I am currently ignoring: {} on {}".format('{}', channel)) else: response = "I am not ignoring anyone on {}.".format(channel) return response
def commands_command(bot, context, message, args): userlevel = bot.request('USERLEVEL', context.channel, context.nick) groups = defaultdict(lambda: []) for command, func in filter_plugins(bot.request('GET_PLUGINS', context.channel), userlevel): groups[func].append(command) commands = map(format_group, sorted(groups.values())) response = split_response(commands, "Bot Commands: {};") return response, Notice(context.nick)
def last_command(bot, context, message, args): global lines response = None try: n = int(args[1]) l = lines[context.channel][-n:] response = split_response(format_lines(l), separator=' ') except (ValueError, IndexError): response = ("Error: Must supply integer argument.", Notice(context.nick)) return response
def commands_command(bot, context, message, args): userlevel = bot.request('USERLEVEL', context.channel, context.nick) groups = defaultdict(lambda: []) for command, func in filter_plugins( bot.request('GET_PLUGINS', context.channel), userlevel): groups[func].append(command) commands = map(format_group, sorted(groups.values())) response = split_response(commands, "Bot Commands: {};") return response, Notice(context.nick)
def hash_command(bot, context, message, args): """ Hash a message. Usage: hash <algorithm> [message]; Pass 'list' or 'show' for a list of algorithms. """ try: if args[1] in ('list', 'show'): response = split_response(algorithms_available, "I support the following hashing algorithms: {}.") else: hash = new(args[1], bytes(' '.join(args[2:]), encoding)) response = hash.hexdigest() except ValueError: response = "Error: Unsupported hashing algorithm.", Notice(context.nick) except IndexError: response = "Error: Please provide a hashing algorithm to use.", Notice(context.nick) return response
def hash_command(bot, context, message, args): """ Hash a message. Usage: hash <algorithm> [message]; Pass 'list' or 'show' for a list of algorithms. """ try: if args[1] in ('list', 'show'): response = split_response( algorithms_available, "I support the following hashing algorithms: {}.") else: hash = new(args[1], bytes(' '.join(args[2:]), encoding)) response = hash.hexdigest() except ValueError: response = "Error: Unsupported hashing algorithm.", Notice( context.nick) except IndexError: response = "Error: Please provide a hashing algorithm to use.", Notice( context.nick) return response
def show_channels(database): channels = map(lambda x: x.split(' ', 1)[0], database.get(set())) return split_response(channels, "I am currently in: {}")
def show_channels(database): channels = map(lambda x: x.split(' ', 1)[0], get_channels(database)) return split_response(channels, "I am currently in: {}")