fix a bug that was getting the trailing semicolon wrong, and do it better anyway.

This commit is contained in:
Brian S. Stephan 2010-09-05 10:44:59 -05:00
parent 053c3f0ae6
commit 27ff7e257d

View File

@ -29,9 +29,9 @@ class Dice(Module):
whats = what.split(' ') whats = what.split(' ')
if whats[0] == 'roll': if whats[0] == 'roll':
rolls = re.split(';\s*', ' '.join(whats[1:])) rollitrs = re.split(';\s*', ' '.join(whats[1:]))
reply = "" reply = ""
for roll in rolls: for count, roll in enumerate(rollitrs):
pattern = '^(?:(\d+)#)?(?:(\d+)/)?(\d+)?d(\d+)(?:(\+|\-)(\d+))?(?:\s+(.*))?' pattern = '^(?:(\d+)#)?(?:(\d+)/)?(\d+)?d(\d+)(?:(\+|\-)(\d+))?(?:\s+(.*))?'
regex = re.compile(pattern) regex = re.compile(pattern)
matches = regex.search(roll) matches = regex.search(roll)
@ -90,7 +90,7 @@ class Dice(Module):
result += ', ' result += ', '
reply += result reply += result
if roll is not rolls[-1]: if count is not len(rollitrs)-1:
reply += "; " reply += "; "
if reply is not "": if reply is not "":
return self.reply(connection, replypath, nick + ': ' + reply) return self.reply(connection, replypath, nick + ': ' + reply)