mirror of
http://aero2k.de/t/repos/urlbot-native.git
synced 2017-09-06 15:25:38 +02:00
patch command_dice to roll N dices
This commit is contained in:
28
plugins.py
28
plugins.py
@@ -267,8 +267,8 @@ def command_dice(args):
|
|||||||
if 'register' == args:
|
if 'register' == args:
|
||||||
return {
|
return {
|
||||||
'name': 'dice',
|
'name': 'dice',
|
||||||
'desc': 'rolls a dice',
|
'desc': 'rolls a dice, optional N times',
|
||||||
'args': ('argv0', 'reply_user'),
|
'args': ('argv0', 'argv1', 'reply_user'),
|
||||||
'ratelimit_class': RATE_INTERACTIVE
|
'ratelimit_class': RATE_INTERACTIVE
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,8 +283,30 @@ def command_dice(args):
|
|||||||
logger('plugin', 'sent random')
|
logger('plugin', 'sent random')
|
||||||
|
|
||||||
dice_char = ['◇', '⚀', '⚁', '⚂', '⚃', '⚄', '⚅']
|
dice_char = ['◇', '⚀', '⚁', '⚂', '⚃', '⚄', '⚅']
|
||||||
|
count = 0
|
||||||
|
msg = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
count = 1 if None is args['argv1'] else int(args['argv1'])
|
||||||
|
except ValueError as e:
|
||||||
return {
|
return {
|
||||||
'msg': 'rolling a dice for %s: %s (%d)' % (args['reply_user'], dice_char[rnd], rnd)
|
'msg': '%s: dice: error when parsing int(%s): %s' % (
|
||||||
|
args['reply_user'], args['argv1'], str(e)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if 0 >= count or 5 <= count:
|
||||||
|
return {
|
||||||
|
'msg': '%s: dice: invalid arguments (0 < N < 5)' % args['reply_user']
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = [
|
||||||
|
'rolling a dice for %s: %s (%d)' % (args['reply_user'], dice_char[rnd], rnd)
|
||||||
|
for i in range(count)
|
||||||
|
]
|
||||||
|
|
||||||
|
return {
|
||||||
|
'msg': msg[0] if 1 == count else msg
|
||||||
}
|
}
|
||||||
|
|
||||||
def command_uptime(args):
|
def command_uptime(args):
|
||||||
|
|||||||
Reference in New Issue
Block a user