make trigger work with regexes

This commit is contained in:
Brian S. Stephan 2010-08-01 12:22:59 -05:00
parent 4712e69336
commit 6fe2bb5fee
1 changed files with 8 additions and 3 deletions

View File

@ -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