Пример #1
0
def user_in(chan):
    if not chan.find("#") == 0:
        if chan in Config.options("Channels"):
            chan = Config.get("Channels", chan)
        else:
            raise LoadableError("Invalid channel")

    def wrapper(execute):
        execute._USER_IN = chan
        return execute

    return wrapper
Пример #2
0
def route(regex=None, access=0):

    if regex is None:
        param = re.compile(loadable.param, re.I)
    elif type(regex) is str:
        param = re.compile(r"\s*%s\s*$" % (regex, ), re.I)
    else:
        raise LoadableError("Invalid route regex")

    if access in Config.options("Access"):
        access = Config.getint("Access", access)
    elif type(access) is int:
        access = access
    else:
        raise LoadableError("Invalid access level")

    def wrapper(execute):
        execute._ROUTE = param
        execute._ACCESS = access
        return execute

    return wrapper
Пример #3
0
def channel(chan):
    if not chan.find("#") == 0:
        if chan in Config.options("Channels"):
            chan = Config.get("Channels", chan)
        elif chan == "PM":
            chan = Config.get("Connection", "nick")
        else:
            raise LoadableError("Invalid channel")

    def wrapper(execute):
        execute._CHANNEL = chan
        return execute

    return wrapper
Пример #4
0
    def __new__(cls):
        self = super(loadable, cls).__new__(cls)
        self.name = cls.__name__

        if cls.access in Config.options("Access"):
            self.access = Config.getint("Access", cls.access)
        elif type(cls.access) in (
                int,
                type(None),
        ):
            self.access = cls.access
        else:
            raise LoadableError("Invalid access level")

        return self