mirror of
http://aero2k.de/t/repos/urlbot-native.git
synced 2017-09-06 15:25:38 +02:00
command_dice: fix random() calls, compress output to single line
This commit is contained in:
31
plugins.py
31
plugins.py
@@ -275,16 +275,7 @@ def command_dice(args):
|
|||||||
if 'dice' != args['argv0']:
|
if 'dice' != args['argv0']:
|
||||||
return
|
return
|
||||||
|
|
||||||
if args['reply_user'] in conf('enhanced-random-user'):
|
|
||||||
rnd = 0 # this might confuse users. good.
|
|
||||||
logger('plugin', 'sent random (enhanced)')
|
|
||||||
else:
|
|
||||||
rnd = random.randint(1, 6)
|
|
||||||
logger('plugin', 'sent random')
|
|
||||||
|
|
||||||
dice_char = ['◇', '⚀', '⚁', '⚂', '⚃', '⚄', '⚅']
|
|
||||||
count = 0
|
count = 0
|
||||||
msg = None
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
count = 1 if None is args['argv1'] else int(args['argv1'])
|
count = 1 if None is args['argv1'] else int(args['argv1'])
|
||||||
@@ -300,13 +291,25 @@ def command_dice(args):
|
|||||||
'msg': '%s: dice: invalid arguments (0 < N < 5)' % args['reply_user']
|
'msg': '%s: dice: invalid arguments (0 < N < 5)' % args['reply_user']
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = [
|
dice_char = ['◇', '⚀', '⚁', '⚂', '⚃', '⚄', '⚅']
|
||||||
'rolling a dice for %s: %s (%d)' % (args['reply_user'], dice_char[rnd], rnd)
|
|
||||||
for i in range(count)
|
msg = 'rolling %s for %s:' % (
|
||||||
]
|
'a dice' if 1 == count else '%d dices' % count, args['reply_user']
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in range(count):
|
||||||
|
rnd = 0
|
||||||
|
if args['reply_user'] in conf('enhanced-random-user'):
|
||||||
|
rnd = 0 # this might confuse users. good.
|
||||||
|
logger('plugin', 'sent random (enhanced)')
|
||||||
|
else:
|
||||||
|
rnd = random.randint(1, 6)
|
||||||
|
logger('plugin', 'sent random')
|
||||||
|
|
||||||
|
msg += ' %s (%d)' % (dice_char[rnd], rnd)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'msg': msg[0] if 1 == count else msg
|
'msg': msg
|
||||||
}
|
}
|
||||||
|
|
||||||
def command_uptime(args):
|
def command_uptime(args):
|
||||||
|
|||||||
Reference in New Issue
Block a user