MessageParser: Add support for notices.

This commit is contained in:
Valentin Lorentz 2013-07-19 18:29:50 +00:00
parent 2a8b8e78a0
commit 7479849767
2 changed files with 12 additions and 3 deletions

View File

@ -57,6 +57,9 @@ conf.registerChannelValue(MessageParser, 'enable',
registry.Boolean(True, _("""Determines whether the
message parser is enabled. If enabled, will trigger on regexps
added to the regexp db.""")))
conf.registerChannelValue(MessageParser, 'enableForNotices',
registry.Boolean(False, _("""Determines whether the message parser
is enabled for NOTICE messages too.""")))
conf.registerChannelValue(MessageParser, 'keepRankInfo',
registry.Boolean(True, _("""Determines whether we keep updating the usage
count for each regexp, for popularity ranking.""")))

View File

@ -146,13 +146,11 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
else:
return True
def doPrivmsg(self, irc, msg):
def do_privmsg_notice(self, irc, msg):
channel = msg.args[0]
if not irc.isChannel(channel):
return
if self.registryValue('enable', channel):
if callbacks.addressed(irc.nick, msg): #message is direct command
return
actions = []
results = []
for channel in set(map(plugins.getChannel, (channel, 'global'))):
@ -182,6 +180,14 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
for action in actions:
self._runCommandFunction(irc, msg, action)
def doPrivmsg(self, irc, msg):
if not callbacks.addressed(irc.nick, msg): #message is not direct command
self.do_privmsg_notice(irc, msg)
def doNotice(self, irc, msg):
if self.registryValue('enableForNotices', msg.args[0]):
self.do_privmsg_notice(irc, msg)
@internationalizeDocstring
def add(self, irc, msg, args, channel, regexp, action):
"""[<channel>|global] <regexp> <action>