Bonk.handle()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
from event import Event
2
import random 
3
4
class Bonk:
5
    def __init__(self, events=None, printer_handle=None, bot=None, say=None):
6
        self.events = events
7
        self.printer = printer_handle
8
        self.interests = ['__.bonk__']
9
        self.bot = bot
10
        self.say = say
11
12
        bonk = Event("__.bonk__")
13
        bonk.define(msg_definition="^\.bonk ")
14
        bonk.subscribe(self)
15
        self.bot.register_event(bonk, self)
16
17
        self.help = ".bonk <bonkee>" 
18
19
    def get_bonked(self, bonkee=''):
20
        """Randomly selects and returns a string with a bonk action directed toward a given bonkee."""
21
        bonk_actions = ['drops a Titan on %s',
22
                       'hadoukens %s',
23
                       'slaps %s around with a large trout',
24
                       'slaps %s around wiiIIITTTTHHH.....A HERRING!',
25
                       'bitch slaps %s',
26
                       'feeds %s a knuckle sandwich',
27
                       'sucker punches %s',
28
                       'drops an ACME anvil on %s',
29
                       'forces %s to exit the building through the window',
30
                       'forces %s to watch all the TSD Productions',
31
                       'roundhouse kicks %s',
32
                       'bonks %s',
33
                       'gently caresses %s',
34
                       'falcon punches %s',
35
                       'pulls a Mike Tyson on %s\'s ear',
36
                       'charges up his lazer and fries %s',
37
                       'introduces %s to his fist',
38
                       'boinks %s',
39
                       'immolates %s',
40
                       'throws %s into the fires of Mount Doom',
41
                       'ties %s to the railroad tracks, curls his mustache, and grins evilly',
42
                       'shoryukens %s',
43
                       'goes medieval on %s',
44
                       'spoils the endings to popular fiction for %s',
45
                       'beats %s in Halo 1v1',
46
                       'ruins %s',
47
                       'reks %s',
48
                       'tramples %s under foot',
49
                       'unleashes his wrath upon %s',
50
                       'goes all ninja assassin on %s',
51
                       'beats %s down with the flag and teabags the body',
52
                       'takes %s\'s mother out for a nice dinner and then never calls her back',
53
                       'rockets %s from across the map',
54
                       'telefrags %s',
55
                       'throws a Dorito into %s\'s jugular from the shadows',
56
                       'wub-wubs %s'
57
                       ]
58
        bonk_action = random.choice(bonk_actions) % bonkee
59
        return "\001ACTION " + bonk_action 
60
61
    def handle(self, event):
62
        _z = event.msg.split(None, 1)
63
        if len(_z) == 1:
64
            self.printer("PRIVMSG " + event.channel + " :You must specify who you want me to bonk!\n")
65
            return
66
        else:
67
            self.printer("PRIVMSG " + event.channel + " :" + self.get_bonked(_z[1]) + "\001\n")
68
69