Source

twisted-meetup / shout.py

Full commit
import web
import ircbot

class Shout(web.Simple):

    def __init__(self, irc):
        self.irc = irc

    def change_status(self, username, status):
        self.users[username] = status
        self.irc.client.multicast_msg("User %s now has status %s" %
                                      (username, status))


def main():
    from twisted.python import log
    from twisted.internet import reactor
    from twisted.web import server
    import sys

    log.startLogging(sys.stdout)
    ircfactory = ircbot.IRCHelloBotFactory()
    resource = Shout(ircfactory)
    reactor.connectTCP(ircbot.HOST, ircbot.PORT, ircfactory)
    site = server.Site(resource)
    reactor.listenTCP(8080, site)
    reactor.run()

if __name__ == '__main__':
    main()