mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-22 18:39:31 +01:00
QuoteGrabs: Add support for +draft/reply to point to the message to grab.
This commit is contained in:
parent
a54db1034f
commit
6f4e3a2dbd
@ -287,7 +287,13 @@ class QuoteGrabs(callbacks.Plugin):
|
||||
raise callbacks.ArgumentError
|
||||
if ircutils.nickEqual(nick, msg.nick):
|
||||
irc.error(_('You can\'t quote grab yourself.'), Raise=True)
|
||||
if conf.supybot.protocols.irc.experimentalExtensions():
|
||||
msgid = msg.server_tags.get('+draft/reply')
|
||||
else:
|
||||
msgid = None
|
||||
for m in reversed(irc.state.history):
|
||||
if msgid and m.server_tags.get('msgid') != msgid:
|
||||
continue
|
||||
if m.command == 'PRIVMSG' and ircutils.nickEqual(m.nick, nick) \
|
||||
and ircutils.strEqual(m.args[0], chan):
|
||||
# TODO: strip statusmsg prefix for comparison? Must be careful
|
||||
|
@ -51,6 +51,41 @@ class QuoteGrabsTestCase(ChannelPluginTestCase):
|
||||
self.assertNotError('grab foo')
|
||||
self.assertResponse('quote foo', '* foo moos')
|
||||
|
||||
def testQuoteGrabReplyDisabled(self):
|
||||
testPrefix = 'foo!bar@baz'
|
||||
prefixChar = conf.supybot.reply.whenAddressedBy.chars()[0]
|
||||
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||
server_tags={'msgid': 'aaaa'}, prefix=testPrefix,
|
||||
command='PRIVMSG', args=(self.channel, 'something')))
|
||||
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||
server_tags={'msgid': 'bbbb'}, prefix=testPrefix,
|
||||
command='PRIVMSG', args=(self.channel, 'something else')))
|
||||
|
||||
# supybot.protocols.irc.experimentalExtensions is not enabled, so
|
||||
# +draft/reply is ignored.
|
||||
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||
server_tags={'+draft/reply': 'aaaa'}, prefix=self.prefix,
|
||||
command='PRIVMSG', args=(self.channel, prefixChar+'grab foo')))
|
||||
self.assertResponse(' ', 'The operation succeeded.')
|
||||
self.assertResponse('quote foo', '<foo> something else')
|
||||
|
||||
def testQuoteGrabReply(self):
|
||||
testPrefix = 'foo!bar@baz'
|
||||
prefixChar = conf.supybot.reply.whenAddressedBy.chars()[0]
|
||||
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||
server_tags={'msgid': 'aaaa'}, prefix=testPrefix,
|
||||
command='PRIVMSG', args=(self.channel, 'something')))
|
||||
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||
server_tags={'msgid': 'bbbb'}, prefix=testPrefix,
|
||||
command='PRIVMSG', args=(self.channel, 'something else')))
|
||||
|
||||
with conf.supybot.protocols.irc.experimentalExtensions.context(True):
|
||||
self.irc.feedMsg(ircmsgs.IrcMsg(
|
||||
server_tags={'+draft/reply': 'aaaa'}, prefix=self.prefix,
|
||||
command='PRIVMSG', args=(self.channel, prefixChar+'grab foo')))
|
||||
self.assertResponse(' ', 'The operation succeeded.')
|
||||
self.assertResponse('quote foo', '<foo> something')
|
||||
|
||||
def testUngrab(self):
|
||||
testPrefix = 'foo!bar@baz'
|
||||
# nothing yet
|
||||
|
Loading…
Reference in New Issue
Block a user