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
|
from ConfigParser import NoOptionError, NoSectionError
|
||||||
|
import re
|
||||||
|
|
||||||
from extlib import irclib
|
from extlib import irclib
|
||||||
|
|
||||||
@ -28,10 +29,14 @@ class Trigger(Module):
|
|||||||
def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
||||||
"""Look up input text in config, and respond with result if found."""
|
"""Look up input text in config, and respond with result if found."""
|
||||||
|
|
||||||
whats = what.split(' ')
|
|
||||||
try:
|
try:
|
||||||
output = self.config.get(self.__class__.__name__, whats[0])
|
trigger_list = self.config.options(self.__class__.__name__)
|
||||||
return self.reply(connection, replypath, output)
|
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 NoOptionError: pass
|
||||||
except NoSectionError: pass
|
except NoSectionError: pass
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user