From 32aaf97c3441d7d21363050aa5ee11a04f73a2ed Mon Sep 17 00:00:00 2001 From: Patrick Hurst Date: Tue, 17 Aug 2010 13:02:59 -0400 Subject: [PATCH] allow empty descriptions for dice rolls --- plugins/dice.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/dice.py b/plugins/dice.py index 0119116..70c4ef6 100644 --- a/plugins/dice.py +++ b/plugins/dice.py @@ -44,7 +44,7 @@ def dice(inp): except AttributeError: pass # we got called via hook.command, inp is already the roll if desc == None: (inp, desc) = valid_diceroll_re.match(inp).groups() - desc = desc.strip() + spec = whitespace_re.sub('', inp) if not valid_diceroll_re.match(spec): return "Invalid diceroll" @@ -69,4 +69,7 @@ def dice(inp): except OverflowError: return "Thanks for overflowing a float, jerk >:[" - return "%s: %d (%s=%s)" % (desc, sum(rolls)+bias, inp, str(rolls).strip("[]")) + if desc: + return "%s: %d (%s=%s)" % (desc.strip(), sum(rolls)+bias, inp, str(rolls).strip("[]")) + else: + return "%d (%s=%s)" % (sum(rolls)+bias, inp, str(rolls).strip("[]"))