From e6950657b8ad8cbf7d951c5747ac8897bb111bdb Mon Sep 17 00:00:00 2001 From: urlbot Date: Wed, 24 Sep 2014 21:35:51 +0200 Subject: [PATCH] enhanced random mode for the "dice" command --- eventlooper.py | 10 +++++++--- local_config.py.skel | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/eventlooper.py b/eventlooper.py index 11584b2..69c6e93 100755 --- a/eventlooper.py +++ b/eventlooper.py @@ -241,9 +241,13 @@ def parse_commands(data): elif 'source' in data: chat_write('My source code can be found at %s' % conf('src-url')) elif 'dice' in data: - rnd = random.randint(1, 6) - dice_char = [u'⚀', u'⚁', u'⚂', u'⚃', u'⚄', u'⚅'] - chat_write('rolling a dice for %s: %s (%d)' %(reply_user, dice_char[rnd-1], rnd)) + if reply_user in conf('enhanced-random-user'): + rnd = 0 # this might confuse users. good. + else: + rnd = random.randint(1, 6) + + dice_char = [u'◇', u'⚀', u'⚁', u'⚂', u'⚃', u'⚄', u'⚅'] + chat_write('rolling a dice for %s: %s (%d)' %(reply_user, dice_char[rnd], rnd)) elif 'uptime' in data: u = int(uptime + time.time()) plural_uptime = 's' diff --git a/local_config.py.skel b/local_config.py.skel index 87d6cd6..5dede38 100644 --- a/local_config.py.skel +++ b/local_config.py.skel @@ -7,6 +7,9 @@ if '__main__' == __name__: config = {} config['src-url'] = 'FIXME' +# the "dice" feature will use more efficient random data (0) for given users +config['enhanced-random-user'] = ( 'FIXME', 'FIXME' ) + def conf(val): if val in config.keys(): return config[val]