September 8th 2010

irccat plugin for supybot

Like irccat but for when you are already running a Supybot instance.

import supybot

from twisted.internet import reactor, protocol
from twisted.protocols import basic

class IRCCatProtocol(basic.LineOnlyReceiver):
    delimiter = '\n'

    def lineReceived(self, text):
        irc = self.factory.irc
        for channel in irc.state.channels:
            irc.queueMsg(supybot.ircmsgs.notice(channel, text))

class IRCCat(supybot.callbacks.Plugin):
    def __init__(self, irc):
        super(IRCCat, self).__init__(irc)

        factory = protocol.Factory()
        factory.protocol = IRCCatProtocol
        factory.irc = irc

        self.server = reactor.listenTCP(12345, factory)

    def die(self):
        self.server.stopListening()

Class = IRCCat

You can then post messages with:

$ echo hai2u | nc -q0 hostname 12345



You can subscribe to new posts via email or RSS.