123456789101112131415161718 |
- import dice
- from command_system import RollbotResponse, as_plugin
- @as_plugin
- def roll(db, message):
- argstr = message.raw_args
- try:
- rolls = []
- for roll_exp in argstr.split(","):
- roll = dice.roll(roll_exp)
- if not isinstance(roll, int):
- roll = int(roll)
- rolls.append(str(roll))
- return RollbotResponse(message, txt="Rolled {}, got: {}".format(argstr, ", ".join(rolls)))
- except Exception as _:
- return RollbotResponse(message, txt="Sorry - dice expression appears malformed. Add more ()'s")
|