dice: properly handle multiple-roll strings (d20; d20) in this post-

recursion world where we're supposed to return a string
This commit is contained in:
Brian S. Stephan 2010-08-28 14:04:29 -05:00
parent 713b1e560b
commit 88c83c1e45
1 changed files with 6 additions and 1 deletions

View File

@ -29,6 +29,7 @@ class Dice(Module):
overallroll = what
rolls = re.split(';\s*', overallroll)
reply = ""
for roll in rolls:
pattern = '^(?:(\d+)#)?(?:(\d+)/)?(\d+)?d(\d+)(?:(\+|\-)(\d+))?(?:\s+(.*))?'
regex = re.compile(pattern)
@ -89,7 +90,11 @@ class Dice(Module):
if t != times-1:
result += ', '
return self.reply(connection, replypath, result)
reply += result
if roll is not rolls[-1]:
reply += "; "
return self.reply(connection, replypath, reply)
# vi:tabstop=4:expandtab:autoindent
# kate: indent-mode python;indent-width 4;replace-tabs on;