mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-03-29 10:56:57 +01:00
Updated IrcObjectProxyRegexp.reply to match the interface of IrcObjectProxy.reply.
This commit is contained in:
parent
23453eff6a
commit
12d707a90f
@ -91,10 +91,10 @@ def canonicalName(command):
|
|||||||
"""
|
"""
|
||||||
return command.translate(string.ascii, '\t -_').lower()
|
return command.translate(string.ascii, '\t -_').lower()
|
||||||
|
|
||||||
def reply(msg, s, prefixName=True):
|
def reply(msg, s, prefixName=True, private=False):
|
||||||
"""Makes a reply to msg with the payload s"""
|
"""Makes a reply to msg with the payload s"""
|
||||||
s = ircutils.safeArgument(s)
|
s = ircutils.safeArgument(s)
|
||||||
if ircutils.isChannel(msg.args[0]):
|
if ircutils.isChannel(msg.args[0]) and not private:
|
||||||
if prefixName:
|
if prefixName:
|
||||||
m = ircmsgs.privmsg(msg.args[0], '%s: %s' % (msg.nick, s))
|
m = ircmsgs.privmsg(msg.args[0], '%s: %s' % (msg.nick, s))
|
||||||
else:
|
else:
|
||||||
@ -383,7 +383,8 @@ class IrcObjectProxy:
|
|||||||
self.noLengthCheck |= noLengthCheck
|
self.noLengthCheck |= noLengthCheck
|
||||||
if self.finalEvaled:
|
if self.finalEvaled:
|
||||||
if isinstance(self.irc, self.__class__):
|
if isinstance(self.irc, self.__class__):
|
||||||
self.irc.reply(msg, s, self.noLengthCheck, self.prefixName)
|
self.irc.reply(msg, s, self.noLengthCheck, self.prefixName,
|
||||||
|
self.action, self.private)
|
||||||
elif self.noLengthCheck:
|
elif self.noLengthCheck:
|
||||||
self.irc.queueMsg(reply(msg, s, self.prefixName))
|
self.irc.queueMsg(reply(msg, s, self.prefixName))
|
||||||
elif self.action:
|
elif self.action:
|
||||||
@ -406,7 +407,7 @@ class IrcObjectProxy:
|
|||||||
# " (more)" to the end, so that's 7 more characters.
|
# " (more)" to the end, so that's 7 more characters.
|
||||||
# 512 - 51 == 461.
|
# 512 - 51 == 461.
|
||||||
s = ircutils.safeArgument(s)
|
s = ircutils.safeArgument(s)
|
||||||
allowedLength = 459 - len(self.irc.prefix)
|
allowedLength = 450 - len(self.irc.prefix)
|
||||||
msgs = textwrap.wrap(s, allowedLength-30) # -30 is for "nick:"
|
msgs = textwrap.wrap(s, allowedLength-30) # -30 is for "nick:"
|
||||||
msgs.reverse()
|
msgs.reverse()
|
||||||
response = msgs.pop()
|
response = msgs.pop()
|
||||||
@ -617,8 +618,12 @@ class IrcObjectProxyRegexp:
|
|||||||
def error(self, msg, s):
|
def error(self, msg, s):
|
||||||
self.reply(msg, 'Error: ' + s)
|
self.reply(msg, 'Error: ' + s)
|
||||||
|
|
||||||
def reply(self, msg, s):
|
def reply(self, msg, s, prefixName=True, action=False, private=False,):
|
||||||
self.irc.queueMsg(reply(msg, s))
|
if action:
|
||||||
|
self.irc.queueMsg(ircmsgs.action(ircutils.replyTo(msg), s))
|
||||||
|
else:
|
||||||
|
self.irc.queueMsg(reply(msg, s, private=private,
|
||||||
|
prefixName=prefixName))
|
||||||
|
|
||||||
def __getattr__(self, attr):
|
def __getattr__(self, attr):
|
||||||
return getattr(self.irc, attr)
|
return getattr(self.irc, attr)
|
||||||
|
@ -130,11 +130,16 @@ class FunctionsTestCase(unittest.TestCase):
|
|||||||
prefix = 'foo!bar@baz'
|
prefix = 'foo!bar@baz'
|
||||||
channelMsg = ircmsgs.privmsg('#foo', 'bar baz', prefix=prefix)
|
channelMsg = ircmsgs.privmsg('#foo', 'bar baz', prefix=prefix)
|
||||||
nonChannelMsg = ircmsgs.privmsg('supybot', 'bar baz', prefix=prefix)
|
nonChannelMsg = ircmsgs.privmsg('supybot', 'bar baz', prefix=prefix)
|
||||||
|
self.assertEqual(ircmsgs.privmsg(nonChannelMsg.nick, 'foo'),
|
||||||
|
callbacks.reply(channelMsg, 'foo', private=True))
|
||||||
self.assertEqual(ircmsgs.privmsg(nonChannelMsg.nick, 'foo'),
|
self.assertEqual(ircmsgs.privmsg(nonChannelMsg.nick, 'foo'),
|
||||||
callbacks.reply(nonChannelMsg, 'foo'))
|
callbacks.reply(nonChannelMsg, 'foo'))
|
||||||
self.assertEqual(ircmsgs.privmsg(channelMsg.args[0],
|
self.assertEqual(ircmsgs.privmsg(channelMsg.args[0],
|
||||||
'%s: foo' % channelMsg.nick),
|
'%s: foo' % channelMsg.nick),
|
||||||
callbacks.reply(channelMsg, 'foo'))
|
callbacks.reply(channelMsg, 'foo'))
|
||||||
|
self.assertEqual(ircmsgs.privmsg(channelMsg.args[0],
|
||||||
|
'foo'),
|
||||||
|
callbacks.reply(channelMsg, 'foo', prefixName=False))
|
||||||
|
|
||||||
def testGetCommands(self):
|
def testGetCommands(self):
|
||||||
self.assertEqual(callbacks.getCommands(['foo']), ['foo'])
|
self.assertEqual(callbacks.getCommands(['foo']), ['foo'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user