/modules/pick.py
https://bitbucket.org/yrjo/bonobot · Python · 17 lines · 12 code · 3 blank · 2 comment · 3 complexity · aa09c820f98475eb7a7eaaef02b70515 MD5 · raw file
- #!/usr/bin/env python3
- # -*- coding: utf8 -*-
- from random import choice
-
- class Pick():
- def __init__(self, bot):
- self.bot = bot
-
- def on_channel_message(self, umask, target, msg):
- if msg.startswith('!pick '):
- items = msg.split(' ')[1:]
-
- if len(items) < 2:
- self.bot.say(target, "{nick}: COME ON!".format(nick=umask.nick))
- else:
- self.bot.say(target, "{nick}: {choice}".format(nick=umask.nick,\
- choice=choice(items)))