bofh.py 624 B

123456789101112131415161718192021222324
  1. import urllib2
  2. class Bofh:
  3. def __init__(self, events=None, printer_handle=None, bot=None, say=None):
  4. self.events = events
  5. self.printer = printer_handle
  6. self.interests = ['__.bofh__']
  7. self.bot = bot
  8. self.help = ".bofh"
  9. for event in events:
  10. if event._type in self.interests:
  11. event.subscribe(self)
  12. def handle(self, event):
  13. try:
  14. url = "http://zero9f9.com/api/bofh"
  15. response = urllib2.urlopen(url)
  16. text = response.read()
  17. bofhquote = text.splitlines()[2]
  18. self.printer("PRIVMSG " + event.channel + " :BOFH: " + bofhquote + '\n')
  19. except:
  20. pass