allow empty descriptions for dice rolls

This commit is contained in:
Patrick Hurst 2010-08-17 13:02:59 -04:00
parent b70c703af5
commit 32aaf97c34
1 changed files with 5 additions and 2 deletions

View File

@ -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("[]"))