mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-21 08:01:00 +01:00
callbacks: Ignore chathistory batches in PluginRegexp
This is consistent with what we already do with commands; and generally makes sense, as we don't want to re-send titles and others when cycling on UnrealIRCd (which includes a chathistory batch when joining when chmode +H is set, despite umode +B)
This commit is contained in:
parent
3ecb37de10
commit
96b7f51e71
@ -309,8 +309,9 @@ class Owner(callbacks.Plugin):
|
|||||||
# Either sent automatically by the server upon join,
|
# Either sent automatically by the server upon join,
|
||||||
# or triggered by a plugin (why?!)
|
# or triggered by a plugin (why?!)
|
||||||
# Either way, replying to commands from the history would
|
# Either way, replying to commands from the history would
|
||||||
# look weird, because it may have been sent a while ago,
|
# look weird, because they may have been sent a while ago,
|
||||||
# and we may have already answered to it.
|
# and we may have already answered to them.
|
||||||
|
# (this is the same behavior as in PluginRegexp.doPrivmsg)
|
||||||
return
|
return
|
||||||
|
|
||||||
self._doPrivmsgs(irc, msg)
|
self._doPrivmsgs(irc, msg)
|
||||||
|
@ -1804,6 +1804,19 @@ class PluginRegexp(Plugin):
|
|||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
if msg.isError:
|
if msg.isError:
|
||||||
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)
|
||||||
|
return
|
||||||
|
|
||||||
proxy = self.Proxy(irc, msg)
|
proxy = self.Proxy(irc, msg)
|
||||||
if not msg.addressed:
|
if not msg.addressed:
|
||||||
for (r, name) in self.unaddressedRes:
|
for (r, name) in self.unaddressedRes:
|
||||||
|
@ -1002,6 +1002,23 @@ class PluginRegexpTestCase(ChannelPluginTestCase):
|
|||||||
args=(self.channel, 'foo <bar> baz')))
|
args=(self.channel, 'foo <bar> baz')))
|
||||||
self.assertResponse(' ', 'hello')
|
self.assertResponse(' ', 'hello')
|
||||||
|
|
||||||
|
def testIgnoreChathistory(self):
|
||||||
|
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, 'foo <bar> baz')))
|
||||||
|
|
||||||
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||||
|
command='BATCH',
|
||||||
|
args=('-123',)))
|
||||||
|
|
||||||
|
self.assertNoResponse(' ')
|
||||||
|
|
||||||
class RichReplyMethodsTestCase(PluginTestCase):
|
class RichReplyMethodsTestCase(PluginTestCase):
|
||||||
plugins = ('Config',)
|
plugins = ('Config',)
|
||||||
class NoCapability(callbacks.Plugin):
|
class NoCapability(callbacks.Plugin):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user