PageRenderTime 884ms CodeModel.GetById 682ms app.highlight 3ms RepoModel.GetById 198ms app.codeStats 0ms

/modules/pick.py

https://bitbucket.org/yrjo/bonobot
Python | 17 lines | 12 code | 3 blank | 2 comment | 2 complexity | aa09c820f98475eb7a7eaaef02b70515 MD5 | raw file
 1#!/usr/bin/env python3

 2# -*- coding: utf8 -*-

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