Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unified Event System #12

Open
Kudu opened this issue Aug 1, 2012 · 0 comments
Open

Unified Event System #12

Kudu opened this issue Aug 1, 2012 · 0 comments
Labels

Comments

@Kudu
Copy link
Contributor

Kudu commented Aug 1, 2012

I suggest adding a unified event system to BBot. The interface could be something like this:

class Module(object):
    def on(self, *args):
    """
    .. :py:method:: on(events, handler)
                    on(events, selector, handler)

        Attach an event handler function to one or more events, optionally limited by a selector.
        An event could be an IRC command name (like ``"NICK"``), an IRC command numeric string (like ``400``) or an abstract event (like ``"LEAVE"``).
        The selection passes if the "main data" (such as the text for a message) is either equal to the selector or if ``selector.match(data)`` is ``True``.
        When an event is matched and the selection passes, the handler is called with a Message object as its argument.

        :param events: the events to handle
        :param selector: the selectors
        :param handler: the handler function
        :type handler: :py:class:`~types.FunctionType`
    """

I apologize in advance if the reST isn't very good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant