Example #1
0
def admincommands(m):
    """Provide a list of admin-only commands."""

    #-     !admincommands
    #-
    #- ```irc
    #- < GorillaWarfare> !admincommands
    #- < GorillaBot> My available admin commands are join, part, quit, setcommand,
    #-               and unset. See http://molly.github.io/GorillaBot for documentation.
    #- ```
    #-
    #- Say the available admin-only commands. This does not display command aliases.

    commands = [
        key for key in list(m.bot.admin_commands.keys())
        if not m.bot.admin_commands[key][1]
    ]
    commands.sort()
    if len(commands) == 0:
        m.bot.private_message(
            m.location, "I have no available admin commands. See "
            "http://molly.github.io/GorillaBot for documentation.")
    elif len(commands) == 1:
        m.bot.private_message(
            m.location, "My available admin command is {0}. See "
            "http://molly.github.io/GorillaBot for "
            "documentation.".format(commands[0]))
    else:
        m.bot.private_message(
            m.location, "My available admin commands are {0}. See "
            "http://molly.github.io/GorillaBot for "
            "documentation.".format(humanize_list(commands)))
def flirt(m):
    """Flirts with the specified user or channel in general."""

    #-     !flirt [user ...]
    #-
    #- ```irc
    #- < GorillaWarfare> !flirt
    #- < GorillaBot> I'm a fermata... hold me.
    #- < GorillaWarfare> !flirt user
    #- < GorillaBot> user: If you were a booger I'd rearrange the alphabet so you fell from heaven!
    #- ```
    #-
    #- Flirts at the user or the channel.

    match = re.match(r':!(?:\w+) ?(\w+)?(?: and | |, )?((?!and)\w+)?(?:,? and |, | )?((?!and)\w+)?',
                     m.body)
    users = [x for x in match.groups() if x] if match else []
    if users == []:
        m.bot.private_message(m.location, get_line(m, "flirt.txt"))
    else:
        bot_nick = m.bot.configuration["nick"]
        for user in users:
            if user.lower() == bot_nick.lower():
                users.remove(user)
                users.append(m.bot.parse_hostmask(m.sender)["nick"])
        if users != []:
            m.bot.private_message(m.location, humanize_list(users) + ": " +
                                  get_line(m, "flirt.txt"))
Example #3
0
def commands(m):
    """Provide a list of commands available to all users."""

    #-     !commands
    #-
    #- ```irc
    #- < GorillaWarfare> !commands
    #- < GorillaBot> My available commands are admincommands, adminlist, commands, hug,
    #-               link, spotify, and xkcd. See http://molly.github.io/GorillaBot
    #-               for documentation.
    #- ```
    #-
    #- Say the available all-user commands. This does not display command aliases.

    commands = [
        key for key in list(m.bot.commands.keys())
        if not m.bot.commands[key][1]
    ]
    commands.sort()
    if len(commands) == 0:
        m.bot.private_message(
            m.location, "I have no available commands. See "
            "http://molly.github.io/GorillaBot for documentation.")
    elif len(commands) == 1:
        m.bot.private_message(
            m.location, "My available command is {0}. See "
            "http://molly.github.io/GorillaBot for "
            "documentation.".format(commands[0]))
    else:
        m.bot.private_message(
            m.location, "My available commands are {0}. See "
            "http://molly.github.io/GorillaBot for "
            "documentation.".format(humanize_list(commands)))
Example #4
0
def admincommands(m):
    """Provide a list of admin-only commands."""

    #-     !admincommands
    #-
    #- ```irc
    #- < GorillaWarfare> !admincommands
    #- < GorillaBot> My available admin commands are join, part, quit, setcommand,
    #-               and unset. See http://molly.github.io/GorillaBot for documentation.
    #- ```
    #-
    #- Say the available admin-only commands. This does not display command aliases.

    commands = [key for key in m.bot.admin_commands.keys() if not m.bot.admin_commands[key][1]]
    commands.sort()
    if len(commands) == 0:
        m.bot.private_message(m.location, "I have no available admin commands. See "
                                          "http://molly.github.io/GorillaBot for documentation.")
    elif len(commands) == 1:
        m.bot.private_message(m.location, "My available admin command is {0}. See "
                                          "http://molly.github.io/GorillaBot for "
                                          "documentation.".format(commands[0]))
    else:
        m.bot.private_message(m.location, "My available admin commands are {0}. See "
                                          "http://molly.github.io/GorillaBot for "
                                          "documentation.".format(
            humanize_list(commands)))
def hug(m):
    """Hugs the specified user or channel in general."""

    #-     !hug [user ...]
    #-
    #- ```irc
    #- < GorillaWarfare> !hug
    #- * GorillaBot distributes tackle-glomps evenly among the channel
    #- < GorillaWarfare> !hug user
    #- * GorillaBot tackles user
    #- ```
    #-
    #- Hugs the user or the channel.

    if m.is_pm:
        _hug_back(m)
    else:
        match = re.match(
            r':!(?:\w+) ?(\w+)?(?: and | |, )?((?!and)\w+)?(?:,? and |, | )?((?!and)\w+)?', m.body)
        users = [x for x in match.groups() if x] if match else []
        if users == []:
            m.bot.action(m.location, "distributes {0} evenly among the channel"
                         .format(get_line(m, "hugs.txt")))
        else:
            bot_nick = m.bot.configuration["nick"]
            for user in users:
                if user.lower() == bot_nick.lower():
                    _hug_back(m)
                    users.remove(user)
            if users != []:
                m.bot.action(m.location, "{0} {1}".format(get_line(m, "hugs.txt"),
                                                          humanize_list(users)))
Example #6
0
def commands(m):
    """Provide a list of commands available to all users."""

    #-     !commands
    #-
    #- ```irc
    #- < GorillaWarfare> !commands
    #- < GorillaBot> My available commands are admincommands, adminlist, commands, hug,
    #-               link, spotify, and xkcd. See http://molly.github.io/GorillaBot
    #-               for documentation.
    #- ```
    #-
    #- Say the available all-user commands. This does not display command aliases.

    commands = [key for key in m.bot.commands.keys() if not m.bot.commands[key][1]]
    commands.sort()
    if len(commands) == 0:
        m.bot.private_message(m.location, "I have no available commands. See "
                                          "http://molly.github.io/GorillaBot for documentation.")
    elif len(commands) == 1:
        m.bot.private_message(m.location, "My available command is {0}. See "
                                          "http://molly.github.io/GorillaBot for "
                                          "documentation.".format(commands[0]))
    else:
        m.bot.private_message(m.location, "My available commands are {0}. See "
                                          "http://molly.github.io/GorillaBot for "
                                          "documentation.".format(
            humanize_list(commands)))
Example #7
0
def adminlist(m):
    """Provide a list of current bot admins."""
    cursor = m.bot.db_conn.cursor()
    cursor.execute('''SELECT nick FROM users WHERE botop = 1''')
    data = cursor.fetchall()
    cursor.close()
    ops = [x[0] for x in data]
    if ops:
        if len(ops) == 1:
            m.bot.private_message(m.location, "My bot admin is " + ops[0] + ".")
        else:
            m.bot.private_message(m.location, "My bot admins are " + humanize_list(ops))
    else:
        nick = m.bot.get_config("nick")
        m.bot.private_message(m.location, "{0} has no master. {0} is a free bot.".format(nick))
Example #8
0
def commands(m):
    """Provide a list of commands available to all users."""
    commands = [key for key in m.bot.commands.keys() if not m.bot.commands[key][1]]
    commands.sort()
    if len(commands) == 0:
        m.bot.private_message(m.location, "I have no available commands. See "
                                          "http://molly.github.io/GorillaBot for documentation.")
    elif len(commands) == 1:
        m.bot.private_message(m.location, "My available command is {0}. See "
                                          "http://molly.github.io/GorillaBot for "
                                          "documentation.".format(commands[0]))
    else:
        m.bot.private_message(m.location,
                              "My available commands are {0}. See "
                              "http://molly.github.io/GorillaBot for documentation."
                              .format(humanize_list(commands)))
Example #9
0
def hug(m):
    """Hugs the specified user or channel in general."""
    if m.is_pm:
        _hug_back(m)
    else:
        match = re.match(
            r':!(?:\w+) ?(\w+)?(?: and | |, )?((?!and)\w+)?(?:,? and |, | )?((?!and)\w+)?', m.body)
        users = [x for x in match.groups() if x] if match else []
        if users == []:
            m.bot.action(m.location, "distributes {0} evenly among the channel".format(_get_hug(m)))
        else:
            bot_nick = m.bot.get_config('nick')
            for user in users:
                if user.lower() == bot_nick.lower():
                    _hug_back(m)
                    users.remove(user)
            if users != []:
                m.bot.action(m.location, "{0} {1}".format(_get_hug(m), humanize_list(users)))
Example #10
0
def adminlist(m):
    """Provide a list of current bot admins."""

    #-     !adminlist
    #-
    #- ```irc
    #- < GorillaWarfare> !adminlist
    #- < GorillaBot> My bot admin is GorillaWarfare.
    #- ```
    #-
    #- Say the current bot operators.

    ops = list(m.bot.configuration["botops"].keys())
    if ops:
        if len(ops) == 1:
            m.bot.private_message(m.location, "My bot admin is " + ops[0] + ".")
        else:
            m.bot.private_message(m.location, "My bot admins are " + humanize_list(ops))
    else:
        nick = m.bot.configuration["nick"]
        m.bot.private_message(m.location, "{0} has no master. {0} is a free bot.".format(nick))
Example #11
0
def adminlist(m):
    """Provide a list of current bot admins."""

    #-     !adminlist
    #-
    #- ```irc
    #- < GorillaWarfare> !adminlist
    #- < GorillaBot> My bot admin is GorillaWarfare.
    #- ```
    #-
    #- Say the current bot operators.

    ops = list(m.bot.configuration["botops"].keys())
    if ops:
        if len(ops) == 1:
            m.bot.private_message(m.location,
                                  "My bot admin is " + ops[0] + ".")
        else:
            m.bot.private_message(m.location,
                                  "My bot admins are " + humanize_list(ops))
    else:
        nick = m.bot.configuration["nick"]
        m.bot.private_message(
            m.location, "{0} has no master. {0} is a free bot.".format(nick))