return Action(msg=answer)
+class Dice20(Worker):
+ binding_keys = ['nick.d20.#']
+ description = "rolls a 20 faced dice, optionally up to 5 times"
+ usage = "bot: d20 <times>"
+
+ def __init__(self, actionqueue):
+ super(Dice20, self).__init__(actionqueue=actionqueue)
+
+ def parse_body(self, msg):
+ words = get_words(msg)
+ nick = get_nick_from_message(msg)
+ num_dice = 1
+ if len(words) > 1 and int(words[1]):
+ num_dice = int(words[1])
+ if not (0 < num_dice < 6):
+ return Action(msg="invalid argument (only up to 5 dices at once)")
+
+ dices = []
+ for dice in range(num_dice):
+ if nick in config.conf_get('plugins.dice.enhanced-random-user'):
+ rnd = 0
+ else:
+ rnd = random.randint(1, 20)
+ dices.append(" {}".format(rnd))
+
+ answer = 'rolling %s for %s:' % (
+ 'a dice' if 1 == num_dice else '%d dices' % num_dice, nick
+ ) + ' '.join(dices)
+ return Action(msg=answer)
+
+
class Ping(Worker):
binding_keys = ["nick.ping"]
description = "pong"