| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| import logging |
| import random |
| from kitnirc.modular import Module |
| from kitnirc.user import User |
|
|
| |
| |
| _log = logging.getLogger(__name__) |
|
|
|
|
| |
| class Roulette(Module): |
| """A basic KitnIRC module responding to !r with some fun.""" |
| def start(self, *args, **kwargs): |
| super(Roulette, self).start(*args, **kwargs) |
| self.gun_max_load = 6 |
| self.gun_bullet_slot = random.randint(1, self.gun_max_load) |
| self.gun_current_slot = 0 |
|
|
| |
| @Module.handle("PRIVMSG") |
| def bang(self, client, actor, recipient, message): |
|
|
| message = message.strip() |
| if "!r" in message: |
| _log.info("Responding to %r in %r", actor, recipient) |
|
|
| self.gun_current_slot = self.gun_current_slot + 1 |
| if self.gun_current_slot == self.gun_max_load: |
| client.reply(recipient, actor, "im not gonna kill you this time... another try?") |
| self.gun_bullet_slot = random.randint(1, self.gun_max_load) |
| self.gun_current_slot = 0 |
| if self.gun_current_slot == self.gun_bullet_slot: |
| if not isinstance(actor, User): |
| actor = User(actor) |
| client.msg(recipient, '*BANG*. {0} is lying on the floor'.format(actor.nick)) |
| self.gun_bullet_slot = random.randint(1, self.gun_max_load) |
| self.gun_current_slot = 0 |
| else: |
| client.msg(recipient, '*click* (slot {0})'.format(self.gun_current_slot)) |
| |
| return True |
|
|
|
|
| |
| module = Roulette |
|
|