Jury   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 15
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A post_init() 0 7 1
A handle() 0 6 3
1
from event import Event
2
import random
3
try:
4
  from basemodule import BaseModule
5
except ImportError:
6
  from modules.basemodule import BaseModule
7
class Jury(BaseModule):
8
  def post_init(self):
9
    jury = Event("__.jury__")
10
    jury.define(msg_definition="^\.jury")
11
    jury.subscribe(self)
12
13
    # register ourself to our new jury event
14
    self.bot.register_event(jury, self)
15
    
16
  def handle(self, event):
17
    if event.msg.startswith(".jury"):
18
      votes = 0
19
      for i in range(12):
20
        votes = votes + int(random.choice("01"))
21
      self.say(event.channel, "Twelve jurors, " + str(votes) + " yeas and " + str((12-votes)) + " nays.")
22