예제 #1
0
def list_module(modules, module):
    if module:
        response = None  # TODO
    else:
        response = split_response(modules, "Modules: {};")

    return response
예제 #2
0
def list_module(bot, module):
    if module:
        pass
    else:
        response = split_response(bot.modules, "Modules: {};")

    return response
예제 #3
0
파일: chat.py 프로젝트: Motoko11/desubot
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)
예제 #4
0
파일: help.py 프로젝트: Motoko11/motobot
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)
예제 #5
0
파일: help.py 프로젝트: Motoko11/motobot
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)
예제 #6
0
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
예제 #7
0
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
예제 #8
0
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
예제 #9
0
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
예제 #10
0
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)
예제 #11
0
파일: ignore.py 프로젝트: Motoko11/motobot
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
예제 #12
0
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
예제 #13
0
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
예제 #14
0
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)
예제 #15
0
파일: last.py 프로젝트: Motoko11/desubot
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
예제 #16
0
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)
예제 #17
0
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
예제 #18
0
파일: encode.py 프로젝트: Motoko11/desubot
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
예제 #19
0
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
예제 #20
0
def show_channels(database):
    channels = map(lambda x: x.split(' ', 1)[0], database.get(set()))
    return split_response(channels, "I am currently in: {}")
예제 #21
0
def show_channels(database):
    channels = map(lambda x: x.split(' ', 1)[0], get_channels(database))
    return split_response(channels, "I am currently in: {}")