Commits

Yury Yurevich committed e576516

Integrate web and ircbot.

  • Participants
  • Parent commits 5b2b961

Comments (0)

Files changed (1)

+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()