Dice: break out the !roll handler
This commit is contained in:
		
							parent
							
								
									1aa7a542f2
								
							
						
					
					
						commit
						f5b367406b
					
				| @ -264,15 +264,28 @@ class Dice(Module): | ||||
|         global output | ||||
|         return output | ||||
| 
 | ||||
|     def do_roll(self, dicestr): | ||||
|         """ | ||||
|         Roll some dice and get the result (with broken out rolls). | ||||
| 
 | ||||
|         Keyword arguments: | ||||
|         dicestr - format: | ||||
|         N#X/YdS+M label | ||||
|             N#: do the following roll N times (optional) | ||||
|             X/: take the top X rolls of the Y times rolled (optional) | ||||
|             Y : roll the die specified Y times (optional, defaults to 1) | ||||
|             dS: roll a S-sided die | ||||
|             +M: add M to the result (-M for subtraction) (optional) | ||||
|         """ | ||||
|         self.build() | ||||
|         yacc.parse(dicestr) | ||||
|         return self.get_result() | ||||
| 
 | ||||
|     def do(self, connection, event, nick, userhost, what, admin_unlocked): | ||||
|         match = re.search('!roll\s+(.*)$', what) | ||||
|         if match: | ||||
|             dicestr = match.group(1) | ||||
|             self.build() | ||||
|             yacc.parse(dicestr) | ||||
|             reply = self.get_result() | ||||
|             if reply is not "": | ||||
|                 return self.reply(connection, event, nick + ': ' + reply) | ||||
|             return self.reply(connection, event, nick + ": " + self.do_roll(dicestr)) | ||||
| 
 | ||||
|         match = re.search('!ctech\s+(.*)$', what) | ||||
|         if match: | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user