Esempio n. 1
0
    def lineReceived(self, data):
        """
        :type data: bytes
        """
        data = data.decode()

        logger.debug('Recieved "{data}" from {nick}',
                     nick=self._client.nick,
                     data=data)

        response = MessageHandler.handleline(data, self._client, self.factory.channels)
        if response:
            for data in response:
                self.send(data)
Esempio n. 2
0
    def lineReceived(self, data):
        """
        :type data: bytes
        """
        data = data.decode()

        logger.debug('Recieved "{data}" from {nick}',
                     nick=self._client.nick,
                     data=data)

        response = MessageHandler.handleline(data, self._client,
                                             self.factory.channels)
        if response:
            for data in response:
                self.send(data)
Esempio n. 3
0
def addhooks():
    """
    This is a temporary solution for hooking regexes up to various functions.
    It'll look pretty much like this in the future too, but it won't be right here,
    and it'll be built in such a way that you can easily make plugins.
    """

    MessageHandler.addhook('^PRIVMSG (?P<channel>[^\s]+) :(?P<message>.*)',
                           handle_privmsg)

    MessageHandler.addhook('^PING.*', handle_ping)
    MessageHandler.addhook('^PONG.*', handle_pong)

    MessageHandler.addhook('^NICK (?P<nick>.*)', handle_nick)

    MessageHandler.addhook(
        '^USER (?P<user>[^\s]+)'
        ' (?P<mode>[^\s]+)'
        ' (?P<host>[^\s]+)'
        ' :(?P<name>.*)', handle_user)

    MessageHandler.addhook('^JOIN (?P<channels>.*)', handle_join)
    MessageHandler.addhook('^PART (?P<channel>[^\s]+)( :(?P<message>.*))?',
                           handle_part)

    MessageHandler.addhook('^MODE (?P<nick>[^\s]+) (?P<mode>.*)', handle_mode)
Esempio n. 4
0
def addhooks():
    """
    This is a temporary solution for hooking regexes up to various functions.
    It'll look pretty much like this in the future too, but it won't be right here,
    and it'll be built in such a way that you can easily make plugins.
    """

    MessageHandler.addhook('^PRIVMSG (?P<channel>[^\s]+) :(?P<message>.*)', handle_privmsg)

    MessageHandler.addhook('^PING.*', handle_ping)
    MessageHandler.addhook('^PONG.*', handle_pong)

    MessageHandler.addhook('^NICK (?P<nick>.*)',
                           handle_nick)

    MessageHandler.addhook('^USER (?P<user>[^\s]+)'
                           ' (?P<mode>[^\s]+)'
                           ' (?P<host>[^\s]+)'
                           ' :(?P<name>.*)',
                           handle_user)

    MessageHandler.addhook('^JOIN (?P<channels>.*)', handle_join)
    MessageHandler.addhook('^PART (?P<channel>[^\s]+)( :(?P<message>.*))?', handle_part)

    MessageHandler.addhook('^MODE (?P<nick>[^\s]+) (?P<mode>.*)', handle_mode)