mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
Anonymous: Move "say $nick" functionality to new tell command
Allowing Anonymous.say to send a message to either a nick or an (implicit) channel through the use of first('nick', 'inChannel') changed the behavior of the command by making it impossible for 'inChannel' to take effect. This meant that any previous users of the command that expected "say some text" to send "some text" to the current channel would instead try to send "text" to the user "some". Depending on the value of conf.plugins.Anonymous.allowPrivateTarget, this would result in either an error or a strange message to a random user. Creating a new tell command solves this issue as Anonymous.channel now goes back to its simple 'inChannel' wrapper. Signed-off-by: James McCoy <vega.james@gmail.com>
This commit is contained in:
parent
3d993a0cab
commit
a629f51328
@ -1,6 +1,6 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2005, Daniel DiPaolo
|
# Copyright (c) 2005, Daniel DiPaolo
|
||||||
# Copyright (c) 2010, James McCoy
|
# Copyright (c) 2014, James McCoy
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -74,17 +74,30 @@ class Anonymous(callbacks.Plugin):
|
|||||||
Raise=True)
|
Raise=True)
|
||||||
|
|
||||||
def say(self, irc, msg, args, target, text):
|
def say(self, irc, msg, args, target, text):
|
||||||
"""<channel|nick> <text>
|
"""<channel> <text>
|
||||||
|
|
||||||
Sends <text> to <channel|nick>. Can only send to <nick> if
|
Sends <text> to <channel>. Can only send to <nick> if
|
||||||
supybot.plugins.Anonymous.allowPrivateTarget is True.
|
supybot.plugins.Anonymous.allowPrivateTarget is True.
|
||||||
"""
|
"""
|
||||||
self._preCheck(irc, msg, target, 'say')
|
self._preCheck(irc, msg, target, 'say')
|
||||||
self.log.info('Saying %q to %s due to %s.',
|
self.log.info('Saying %q in %s due to %s.',
|
||||||
text, target, msg.prefix)
|
text, target, msg.prefix)
|
||||||
irc.queueMsg(ircmsgs.privmsg(target, text))
|
irc.queueMsg(ircmsgs.privmsg(target, text))
|
||||||
irc.noReply()
|
irc.noReply()
|
||||||
say = wrap(say, [first('nick', 'inChannel'), 'text'])
|
say = wrap(say, ['inChannel', 'text'])
|
||||||
|
|
||||||
|
def tell(self, irc, msg, args, target, text):
|
||||||
|
"""<nick> <text>
|
||||||
|
|
||||||
|
Sends <text> to <nick>. Can only be used if
|
||||||
|
supybot.plugins.Anonymous.allowPrivateTarget is True.
|
||||||
|
"""
|
||||||
|
self._preCheck(irc, msg, target, 'tell')
|
||||||
|
self.log.info('Telling %q to %s due to %s.',
|
||||||
|
text, target, msg.prefix)
|
||||||
|
irc.queueMsg(ircmsgs.privmsg(target, text))
|
||||||
|
irc.noReply()
|
||||||
|
tell = wrap(tell, ['nick', 'text'])
|
||||||
|
|
||||||
def do(self, irc, msg, args, channel, text):
|
def do(self, irc, msg, args, channel, text):
|
||||||
"""<channel> <action>
|
"""<channel> <action>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2005, Daniel DiPaolo
|
# Copyright (c) 2005, Daniel DiPaolo
|
||||||
# Copyright (c) 2010, James McCoy
|
# Copyright (c) 2014, James McCoy
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -34,15 +34,23 @@ class AnonymousTestCase(ChannelPluginTestCase):
|
|||||||
plugins = ('Anonymous',)
|
plugins = ('Anonymous',)
|
||||||
def testSay(self):
|
def testSay(self):
|
||||||
self.assertError('anonymous say %s I love you!' % self.channel)
|
self.assertError('anonymous say %s I love you!' % self.channel)
|
||||||
self.assertError('anonymous say %s I love you!' % self.nick)
|
|
||||||
origreg = conf.supybot.plugins.Anonymous.requireRegistration()
|
origreg = conf.supybot.plugins.Anonymous.requireRegistration()
|
||||||
origpriv = conf.supybot.plugins.Anonymous.allowPrivateTarget()
|
|
||||||
try:
|
try:
|
||||||
conf.supybot.plugins.Anonymous.requireRegistration.setValue(False)
|
conf.supybot.plugins.Anonymous.requireRegistration.setValue(False)
|
||||||
m = self.assertNotError('anonymous say %s foo!' % self.channel)
|
m = self.assertNotError('anonymous say %s foo!' % self.channel)
|
||||||
self.failUnless(m.args[1] == 'foo!')
|
self.failUnless(m.args[1] == 'foo!')
|
||||||
|
finally:
|
||||||
|
conf.supybot.plugins.Anonymous.requireRegistration.setValue(origreg)
|
||||||
|
|
||||||
|
def testTell(self):
|
||||||
|
self.assertError('anonymous tell %s I love you!' % self.nick)
|
||||||
|
origreg = conf.supybot.plugins.Anonymous.requireRegistration()
|
||||||
|
origpriv = conf.supybot.plugins.Anonymous.allowPrivateTarget()
|
||||||
|
try:
|
||||||
|
conf.supybot.plugins.Anonymous.requireRegistration.setValue(False)
|
||||||
|
self.assertError('anonymous tell %s foo!' % self.channel)
|
||||||
conf.supybot.plugins.Anonymous.allowPrivateTarget.setValue(True)
|
conf.supybot.plugins.Anonymous.allowPrivateTarget.setValue(True)
|
||||||
m = self.assertNotError('anonymous say %s foo!' % self.nick)
|
m = self.assertNotError('anonymous tell %s foo!' % self.nick)
|
||||||
self.failUnless(m.args[1] == 'foo!')
|
self.failUnless(m.args[1] == 'foo!')
|
||||||
finally:
|
finally:
|
||||||
conf.supybot.plugins.Anonymous.requireRegistration.setValue(origreg)
|
conf.supybot.plugins.Anonymous.requireRegistration.setValue(origreg)
|
||||||
|
Loading…
Reference in New Issue
Block a user