Dice: apply the irc formatting outside of the !roll handler

This commit is contained in:
Brian S. Stephan 2012-03-30 17:54:06 -05:00
parent f5b367406b
commit 60b7a33f7b
1 changed files with 7 additions and 4 deletions

View File

@ -131,11 +131,11 @@ class Dice(Module):
total += mode * res
if repeat == 1:
if comment != None:
output = "%d %s 14(%s)" % (total, comment.strip(), curr_str)
output = "%d %s (%s)" % (total, comment.strip(), curr_str)
else:
output = "%d 14(%s)" % (total, curr_str)
output = "%d (%s)" % (total, curr_str)
else:
output += "%d 14(%s)" % (total, curr_str)
output += "%d (%s)" % (total, curr_str)
if i == repeat - 1:
if comment != None:
output += " (%s)" % (comment.strip())
@ -285,7 +285,10 @@ class Dice(Module):
match = re.search('!roll\s+(.*)$', what)
if match:
dicestr = match.group(1)
return self.reply(connection, event, nick + ": " + self.do_roll(dicestr))
reply = nick + ": " + self.do_roll(dicestr)
# irc format it
return self.reply(connection, event,
re.sub(r"(\d+)(.*?\s+)(\(.*?\))", r"\1\214\3", reply))
match = re.search('!ctech\s+(.*)$', what)
if match: