make trigger work with regexes
This commit is contained in:
		
							parent
							
								
									4712e69336
								
							
						
					
					
						commit
						6fe2bb5fee
					
				| @ -17,6 +17,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
| """ | ||||
| 
 | ||||
| from ConfigParser import NoOptionError, NoSectionError | ||||
| import re | ||||
| 
 | ||||
| from extlib import irclib | ||||
| 
 | ||||
| @ -28,10 +29,14 @@ class Trigger(Module): | ||||
|     def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked): | ||||
|         """Look up input text in config, and respond with result if found.""" | ||||
| 
 | ||||
|         whats = what.split(' ') | ||||
|         try: | ||||
|             output = self.config.get(self.__class__.__name__, whats[0]) | ||||
|             return self.reply(connection, replypath, output) | ||||
|             trigger_list = self.config.options(self.__class__.__name__) | ||||
|             self.remove_metaoptions(trigger_list) | ||||
| 
 | ||||
|             for trigger in trigger_list: | ||||
|                 if re.search(trigger, what) is not None: | ||||
|                     output = self.config.get(self.__class__.__name__, trigger) | ||||
|                     return self.reply(connection, replypath, output) | ||||
|         except NoOptionError: pass | ||||
|         except NoSectionError: pass | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user