mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
MessageParser: Ignore chathistory batches
To be consistent with commands and PluginRegexp (snarfers)
This commit is contained in:
parent
fccb4f705b
commit
86b389618f
@ -163,6 +163,20 @@ class MessageParser(callbacks.Plugin, plugins.ChannelDBHandler):
|
|||||||
channel = msg.channel
|
channel = msg.channel
|
||||||
if not channel:
|
if not channel:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if 'batch' in msg.server_tags:
|
||||||
|
parent_batches = irc.state.getParentBatches(msg)
|
||||||
|
parent_batch_types = [batch.type for batch in parent_batches]
|
||||||
|
if 'chathistory' in parent_batch_types:
|
||||||
|
# Either sent automatically by the server upon join,
|
||||||
|
# or triggered by a plugin (why?!)
|
||||||
|
# Either way, replying to messages from the history would
|
||||||
|
# look weird, because they may have been sent a while ago,
|
||||||
|
# and we may have already answered them.
|
||||||
|
# (this is the same behavior as in Owner.doPrivmsg and
|
||||||
|
# PluginRegexp.doPrivmsg)
|
||||||
|
return
|
||||||
|
|
||||||
if self.registryValue('enable', channel, irc.network):
|
if self.registryValue('enable', channel, irc.network):
|
||||||
actions = []
|
actions = []
|
||||||
results = []
|
results = []
|
||||||
|
@ -116,10 +116,31 @@ class MessageParserTestCase(ChannelPluginTestCase):
|
|||||||
|
|
||||||
def testTrigger(self):
|
def testTrigger(self):
|
||||||
self.assertNotError('messageparser add "stuff" "echo i saw some stuff"')
|
self.assertNotError('messageparser add "stuff" "echo i saw some stuff"')
|
||||||
self.feedMsg('this message has some stuff in it')
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||||
|
prefix=self.prefix,
|
||||||
|
command='PRIVMSG',
|
||||||
|
args=(self.channel, 'this message has some stuff in it')))
|
||||||
m = self.getMsg(' ')
|
m = self.getMsg(' ')
|
||||||
self.assertTrue(str(m).startswith('PRIVMSG #test :i saw some stuff'))
|
self.assertTrue(str(m).startswith('PRIVMSG #test :i saw some stuff'))
|
||||||
|
|
||||||
|
def testIgnoreChathistory(self):
|
||||||
|
self.assertNotError('messageparser add "stuff" "echo i saw some stuff"')
|
||||||
|
|
||||||
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||||
|
command='BATCH',
|
||||||
|
args=('+123', 'chathistory', self.channel)))
|
||||||
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||||
|
server_tags={'batch': '123'},
|
||||||
|
prefix=self.prefix,
|
||||||
|
command='PRIVMSG',
|
||||||
|
args=(self.channel, 'this message has some stuff in it')))
|
||||||
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||||
|
command='BATCH',
|
||||||
|
args=('-123',)))
|
||||||
|
|
||||||
|
m = self.getMsg(' ')
|
||||||
|
self.assertFalse(m)
|
||||||
|
|
||||||
def testMaxTriggers(self):
|
def testMaxTriggers(self):
|
||||||
self.assertNotError('messageparser add "stuff" "echo i saw some stuff"')
|
self.assertNotError('messageparser add "stuff" "echo i saw some stuff"')
|
||||||
self.assertNotError('messageparser add "sbd" "echo i saw somebody"')
|
self.assertNotError('messageparser add "sbd" "echo i saw somebody"')
|
||||||
|
Loading…
Reference in New Issue
Block a user