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 registry.Boolean(True, _("""Determines whether the
message parser is enabled. If enabled, will trigger on regexps message parser is enabled. If enabled, will trigger on regexps
added to the regexp db."""))) 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', conf.registerChannelValue(MessageParser, 'keepRankInfo',
registry.Boolean(True, _("""Determines whether we keep updating the usage registry.Boolean(True, _("""Determines whether we keep updating the usage
count for each regexp, for popularity ranking."""))) count for each regexp, for popularity ranking.""")))

View File

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