irccat plugin for supybot

By Chris Lamb

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

Chris Lamb is a freelance software developer and the current Debian Project Leader. You can read other posts by me, see software I have written or read more about me. You can also follow me @lolamby.


Tags: Hacks

Planets: ALUG UWCS WUGLUG Debian

Wednesday 8th September 2010


One comment

Comments are closed.