Completed
Push — master ( d5373c...d83d47 )
by Matt
01:01
created

Bofh.__init__()   A

Complexity

Conditions 3

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 3
dl 0
loc 11
rs 9.4285
1
import urllib2
2
from event import Event
3
try:
4
  from basemodule import BaseModule
5
except ImportError:
6
  from modules.basemodule import BaseModule
7
class Bofh(BaseModule):
8
  def post_init(self):
9
    b_event = Event("__.bofh__")
10
11
    b_event.define(msg_definition="^\.bofh")
12
    b_event.subscribe(self)
13
14
    self.bot.register_event(b_event, self)
15
16
  def handle(self, event):
17
    try:
18
      url = "http://zero9f9.com/api/bofh"
19
      response = urllib2.urlopen(url)
20
      text = response.read()
21
      bofhquote = text.splitlines()[2]
22
      self.say(event.channel, "BOFH: " + bofhquote)
23
    except:
24
      pass
25