mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-25 20:41:18 -05:00
Owner: Ignore commands when they are in a chathistory batch.
This commit is contained in:
parent
2236c7552a
commit
63a97fc147
@ -297,11 +297,20 @@ class Owner(callbacks.Plugin):
|
|||||||
self._doPrivmsgs(irc, synthetic_msg)
|
self._doPrivmsgs(irc, synthetic_msg)
|
||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
if conf.supybot.protocols.irc.experimentalExtensions():
|
if 'batch' in msg.server_tags:
|
||||||
if 'batch' in msg.server_tags \
|
parent_batches = irc.state.getParentBatches(msg)
|
||||||
and any(batch.type =='draft/multiline'
|
parent_batch_types = [batch.type for batch in parent_batches]
|
||||||
for batch in irc.state.getParentBatches(msg)):
|
if 'draft/multiline' in parent_batch_types \
|
||||||
# We will handle the message in doBatch when the entire batch ends.
|
and conf.supybot.protocols.irc.experimentalExtensions():
|
||||||
|
# We will handle the message in doBatch when the entire
|
||||||
|
# batch ends.
|
||||||
|
return
|
||||||
|
if 'chathistory' in parent_batch_types:
|
||||||
|
# Either sent automatically by the server upon join,
|
||||||
|
# or triggered by a plugin (why?!)
|
||||||
|
# Either way, replying to commands from the history would
|
||||||
|
# look weird, because it may have been sent a while ago,
|
||||||
|
# and we may have already answered to it.
|
||||||
return
|
return
|
||||||
|
|
||||||
self._doPrivmsgs(irc, msg)
|
self._doPrivmsgs(irc, msg)
|
||||||
|
@ -186,6 +186,28 @@ class CommandsTestCase(PluginTestCase):
|
|||||||
command='BATCH',
|
command='BATCH',
|
||||||
args=('-123',)))
|
args=('-123',)))
|
||||||
|
|
||||||
|
def testIgnoreChathistory(self):
|
||||||
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||||
|
command='BATCH',
|
||||||
|
args=('+123', 'chathistory', self.irc.nick)))
|
||||||
|
|
||||||
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||||
|
server_tags={'batch': '123'},
|
||||||
|
prefix=self.prefix,
|
||||||
|
command='PRIVMSG',
|
||||||
|
args=(self.irc.nick, 'echo foo')))
|
||||||
|
|
||||||
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||||
|
command='BATCH',
|
||||||
|
args=('-123',)))
|
||||||
|
|
||||||
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||||
|
prefix=self.prefix,
|
||||||
|
command='PRIVMSG',
|
||||||
|
args=(self.irc.nick, 'echo bar')))
|
||||||
|
|
||||||
|
self.assertResponse('', 'bar')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user