aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorGravatar jesopo2019-09-26 14:32:48 +0100
committerGravatar jesopo2019-09-26 14:32:48 +0100
commit17c899fb701a18965bd922af6dfe3722f9da1282 (patch)
tree350481cc824dabc48326e27e61c22069e61a1844 /modules
parentShow dice format error when regex doesn't match (diff)
signature
make dice count optional (default 1)
Diffstat (limited to 'modules')
-rw-r--r--modules/dice.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/dice.py b/modules/dice.py
index 4a587d72..16f3a550 100644
--- a/modules/dice.py
+++ b/modules/dice.py
@@ -4,7 +4,7 @@ import random, re
from src import ModuleManager, utils
ERROR_FORMAT = "Incorrect format! Format must be [number]d[number], e.g. 1d20"
-RE_DICE = re.compile("^([1-9]\d*)d([1-9]\d*)((?:[-+][1-9]\d{,2})*)$", re.I)
+RE_DICE = re.compile("^([1-9]\d*)?d([1-9]\d*)((?:[-+][1-9]\d{,2})*)$", re.I)
RE_MODIFIERS = re.compile("([-+]\d+)")
MAX_DICE = 6
@@ -19,7 +19,7 @@ class Module(ModuleManager.BaseModule):
match = RE_DICE.match(event["args_split"][0])
if match:
roll = match.group(0)
- dice_count = int(match.group(1))
+ dice_count = int(match.group(1) or "1")
side_count = int(match.group(2))
modifiers = RE_MODIFIERS.findall(match.group(3))