<commit_before>import logging
import lala.config as config

from lurklib.exceptions import _Exceptions
from lala.util import _BOT, command, msg, is_admin

@command("load")
def load(user, channel, text):
    if is_admin(user):
        try:
            _BOT.plugger.load_plugin(text.split()[1])
        except exceptions.NoSuchPlugin:
            msg(channel, "%s could not be found" % text[1])

@command("part")
def part(user, channel, text):
    if is_admin(user):
        try:
            logging.debug("Parting %s" % text.split()[1])
            _BOT.part(text.split()[1])
        except _Exceptions.NotInChannel, e:
            msg(channel, "Sorry, %s, I'm not in %s" % (user,
                text.split()[1]))

@command("join")
def join(user, channel, text):
    if is_admin(user):
        chan = text.split()[1]
        try:
            logging.debug("Joining %s" % chan)
            _BOT.join(chan)
        except _Exceptions.ChannelIsFull, e:
            msg(channel, "Sorry, %s is full." % chan)
        except _Exceptions.NoSuchChannel, e:
            msg(channel, "Sorry, %s doesn't exist." % chan)
        except _Exceptions.TooManyChannels, e:
            msg(channel, "Sorry, I'm already in enough channels.")
        except _Exceptions.InviteOnlyChan, e:
            msg(channel, "Sorry, invite only.")
        except _Exceptions.AlreadyInChannel, e:
            msg(channel, "I'm already there!")

@command("quit")
def quit(user, channel, text):
    if is_admin(user):
        logging.debug("Quitting")
        _BOT.quit("leaving")

@command("server")
def server(user, channel, text):
    """Shows the server the _BOT is connected to"""
    msg(user, _BOT.server)

@command("commands")
def commands(user, channel, text):
    """Prints all available callbacks"""
    msg(channel, "I know the following commands:")
    s = "!" + " !".join(_BOT._callbacks)
    msg(channel, s)

@command("addadmin")
def addadmin(user, channel, text):
    """Add a user to the list of admins"""
    admin = text.split()[1]
    if is_admin(user):
        if admin in config.get("admins"):
            msg(channel, "%s already is an admin" % admin)
        else:
            config.set("admins", "%s,%s" % (config.get("admins"), admin))
            msg(channel,
                        "%s has been added to the list of admins" % admin)

@command("admins")
def admins(user, channel, text):
    """Print the list of admins"""
    if is_admin(user):
        msg(channel, config.get("admins"))

@command("deladmin")
def deladmin(user, channel, text):
    """Remove a user from the list of admins"""
    admin = text.split()[1]
    if is_admin(user):
        if admin in config.get("admins"):
            admins = config.get("admins").split(",")
            admins.remove(admin)
            config.set("admins", ",".join(admins))
            msg(channel,
                        "%s has been removed from the list of admins" %
                        admin)
        else:
            msg(channel, "Sorry, %s is not even an admin" % admin)
<commit_msg>plugins/base: Add a help command<commit_after>import logging
import lala.config as config

from lurklib.exceptions import _Exceptions
from lala.util import _BOT, command, msg, is_admin

@command("load")
def load(user, channel, text):
    if is_admin(user):
        try:
            _BOT.plugger.load_plugin(text.split()[1])
        except exceptions.NoSuchPlugin:
            msg(channel, "%s could not be found" % text[1])

@command("part")
def part(user, channel, text):
    if is_admin(user):
        try:
            logging.debug("Parting %s" % text.split()[1])
            _BOT.part(text.split()[1])
        except _Exceptions.NotInChannel, e:
            msg(channel, "Sorry, %s, I'm not in %s" % (user,
                text.split()[1]))

@command("join")
def join(user, channel, text):
    if is_admin(user):
        chan = text.split()[1]
        try:
            logging.debug("Joining %s" % chan)
            _BOT.join(chan)
        except _Exceptions.ChannelIsFull, e:
            msg(channel, "Sorry, %s is full." % chan)
        except _Exceptions.NoSuchChannel, e:
            msg(channel, "Sorry, %s doesn't exist." % chan)
        except _Exceptions.TooManyChannels, e:
            msg(channel, "Sorry, I'm already in enough channels.")
        except _Exceptions.InviteOnlyChan, e:
            msg(channel, "Sorry, invite only.")
        except _Exceptions.AlreadyInChannel, e:
            msg(channel, "I'm already there!")

@command("quit")
def quit(user, channel, text):
    if is_admin(user):
        logging.debug("Quitting")
        _BOT.quit("leaving")

@command("server")
def server(user, channel, text):
    """Shows the server the _BOT is connected to"""
    msg(user, _BOT.server)

@command("commands")
def commands(user, channel, text):
    """Prints all available callbacks"""
    msg(channel, "I know the following commands:")
    s = "!" + " !".join(_BOT._callbacks)
    msg(channel, s)

@command("addadmin")
def addadmin(user, channel, text):
    """Add a user to the list of admins"""
    admin = text.split()[1]
    if is_admin(user):
        if admin in config.get("admins"):
            msg(channel, "%s already is an admin" % admin)
        else:
            config.set("admins", "%s,%s" % (config.get("admins"), admin))
            msg(channel,
                        "%s has been added to the list of admins" % admin)

@command("admins")
def admins(user, channel, text):
    """Print the list of admins"""
    if is_admin(user):
        msg(channel, config.get("admins"))

@command("deladmin")
def deladmin(user, channel, text):
    """Remove a user from the list of admins"""
    admin = text.split()[1]
    if is_admin(user):
        if admin in config.get("admins"):
            admins = config.get("admins").split(",")
            admins.remove(admin)
            config.set("admins", ",".join(admins))
            msg(channel,
                        "%s has been removed from the list of admins" %
                        admin)
        else:
            msg(channel, "Sorry, %s is not even an admin" % admin)

@command("help")
def help(user, channel, text):
    """Show the help for a command"""
    cmd = text.split()[1]
    try:
        func = _BOT._callbacks[cmd]
    except KeyError, e:
        msg(channel, "%s is not a command I know" % cmd)
        return
    else:
        if func.__doc__ is not None:
            msg(channel, "%s: %s" % (cmd, func.__doc__))
        else:
            msg(channel, "There is no help available for %s" % cmd)

{'fraction_non_alphanumeric': 0.14165519351384426, 'fraction_numerical': 0.002600581306409668, 'mean_word_length': 2.4302203567681007, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1736697', 'n_tokens_mistral': 2062, 'n_tokens_neox': 2015, 'n_words': 580}