/modules/pick.py

https://bitbucket.org/yrjo/bonobot · Python · 17 lines · 12 code · 3 blank · 2 comment · 3 complexity · aa09c820f98475eb7a7eaaef02b70515 MD5 · raw file

  1. #!/usr/bin/env python3
  2. # -*- coding: utf8 -*-
  3. from random import choice
  4. class Pick():
  5. def __init__(self, bot):
  6. self.bot = bot
  7. def on_channel_message(self, umask, target, msg):
  8. if msg.startswith('!pick '):
  9. items = msg.split(' ')[1:]
  10. if len(items) < 2:
  11. self.bot.say(target, "{nick}: COME ON!".format(nick=umask.nick))
  12. else:
  13. self.bot.say(target, "{nick}: {choice}".format(nick=umask.nick,\
  14. choice=choice(items)))