Jury.post_init()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
dl 0
loc 7
rs 9.4285
c 1
b 0
f 0
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