Help   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 17 3
B handle() 0 18 7
1
from time import sleep
2
from event import Event
3
class Help:
4
  def __init__(self, events=None, printer_handle=None, bot=None, say=None):
5
    self.events = events
6
    self.printer = printer_handle
7
    self.interests = ['__.help__']
8
    self.bot = bot
9
    self.say = say
10
11
    for event in events:
12
      if event._type in self.interests:
13
        event.subscribe(self)
14
15
    help = Event("__.help__")
16
    help.define(msg_definition="^\.help")
17
    help.subscribe(self)
18
    self.bot.register_event(help,self)
19
20
    self.help = ".help"
21
22
  def handle(self, event):
23
    try:
24
      my_modules = list()
25
      self.printer("PRIVMSG " + event.user + " :Help: \n")
26
      for m in self.bot.events_list:
27
        for s in m.subscribers:
28
          my_modules.append(s)
29
30
      modules_set = set(my_modules)
31
      line_list = list()
32
      for sm in modules_set:
33
        if hasattr(sm, "help") and sm.help is not None:
34
          line_list.append(sm.help)
35
36
      self.say(event.user, ", ".join(line_list))
37
      #self.printer("PRIVMSG " + event.user + " :" + ", ".join(line_list) + "\n")
38
    except:
39
      pass
40