Skip to content

Commit 96b7f51

Browse files
committed
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)
1 parent 3ecb37d commit 96b7f51

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

plugins/Owner/plugin.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,9 @@ def doPrivmsg(self, irc, msg):
309309
# Either sent automatically by the server upon join,
310310
# or triggered by a plugin (why?!)
311311
# Either way, replying to commands from the history would
312-
# look weird, because it may have been sent a while ago,
313-
# and we may have already answered to it.
312+
# look weird, because they may have been sent a while ago,
313+
# and we may have already answered to them.
314+
# (this is the same behavior as in PluginRegexp.doPrivmsg)
314315
return
315316

316317
self._doPrivmsgs(irc, msg)

src/callbacks.py

+13
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,19 @@ def invalidCommand(self, irc, msg, tokens):
18041804
def doPrivmsg(self, irc, msg):
18051805
if msg.isError:
18061806
return
1807+
1808+
if 'batch' in msg.server_tags:
1809+
parent_batches = irc.state.getParentBatches(msg)
1810+
parent_batch_types = [batch.type for batch in parent_batches]
1811+
if 'chathistory' in parent_batch_types:
1812+
# Either sent automatically by the server upon join,
1813+
# or triggered by a plugin (why?!)
1814+
# Either way, replying to messages from the history would
1815+
# look weird, because they may have been sent a while ago,
1816+
# and we may have already answered them.
1817+
# (this is the same behavior as in Owner.doPrivmsg)
1818+
return
1819+
18071820
proxy = self.Proxy(irc, msg)
18081821
if not msg.addressed:
18091822
for (r, name) in self.unaddressedRes:

test/test_callbacks.py

+17
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,23 @@ def testReply(self):
10021002
args=(self.channel, 'foo <bar> baz')))
10031003
self.assertResponse(' ', 'hello')
10041004

1005+
def testIgnoreChathistory(self):
1006+
self.irc.feedMsg(ircmsgs.IrcMsg(
1007+
command='BATCH',
1008+
args=('+123', 'chathistory', self.channel)))
1009+
1010+
self.irc.feedMsg(ircmsgs.IrcMsg(
1011+
server_tags={'batch': '123'},
1012+
prefix=self.prefix,
1013+
command='PRIVMSG',
1014+
args=(self.channel, 'foo <bar> baz')))
1015+
1016+
self.irc.feedMsg(ircmsgs.IrcMsg(
1017+
command='BATCH',
1018+
args=('-123',)))
1019+
1020+
self.assertNoResponse(' ')
1021+
10051022
class RichReplyMethodsTestCase(PluginTestCase):
10061023
plugins = ('Config',)
10071024
class NoCapability(callbacks.Plugin):

0 commit comments

Comments
 (0)