mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-25 20:41:18 -05:00
Add config value supybot.reply.mores.instant.whenPrivate
This allows overriding supybot.reply.mores.instant for private messages, where it is usually more tolerable to send multiple lines. However, this still defaults to 1, in order to not be abusable by default.
This commit is contained in:
parent
04e0bd4271
commit
b075a94396
@ -769,6 +769,9 @@ class ReplyIrcProxy(RichReplyMethods):
|
|||||||
else:
|
else:
|
||||||
sendMsg = self.replyIrc.queueMsg
|
sendMsg = self.replyIrc.queueMsg
|
||||||
|
|
||||||
|
public = bool(self.msg.channel)
|
||||||
|
private = kwargs.get('private', False) or not public
|
||||||
|
|
||||||
if isinstance(self.replyIrc, self.__class__):
|
if isinstance(self.replyIrc, self.__class__):
|
||||||
s = s[:conf.supybot.reply.maximumLength()]
|
s = s[:conf.supybot.reply.maximumLength()]
|
||||||
return self.replyIrc.reply(s,
|
return self.replyIrc.reply(s,
|
||||||
@ -813,8 +816,14 @@ class ReplyIrcProxy(RichReplyMethods):
|
|||||||
# (which is used like a stack)
|
# (which is used like a stack)
|
||||||
chunks.reverse()
|
chunks.reverse()
|
||||||
|
|
||||||
instant = conf.get(conf.supybot.reply.mores.instant,
|
instant = 0
|
||||||
channel=target, network=self.replyIrc.network)
|
if private:
|
||||||
|
# if zero, falls back to supybot.reply.mores.instant
|
||||||
|
instant = conf.get(conf.supybot.reply.mores.instant.whenPrivate,
|
||||||
|
network=self.replyIrc.network)
|
||||||
|
if instant <= 0:
|
||||||
|
instant = conf.get(conf.supybot.reply.mores.instant,
|
||||||
|
channel=target, network=self.replyIrc.network)
|
||||||
|
|
||||||
# Big complex loop ahead, with lots of cases and opportunities for
|
# Big complex loop ahead, with lots of cases and opportunities for
|
||||||
# off-by-one errors. Here is the meaning of each of the variables
|
# off-by-one errors. Here is the meaning of each of the variables
|
||||||
@ -912,8 +921,6 @@ class ReplyIrcProxy(RichReplyMethods):
|
|||||||
if '!' in prefix and '@' in prefix:
|
if '!' in prefix and '@' in prefix:
|
||||||
mask = prefix.split('!', 1)[1]
|
mask = prefix.split('!', 1)[1]
|
||||||
self._mores[mask] = msgs
|
self._mores[mask] = msgs
|
||||||
public = bool(self.msg.channel)
|
|
||||||
private = kwargs.get('private', False) or not public
|
|
||||||
self._mores[msg.nick] = (private, msgs)
|
self._mores[msg.nick] = (private, msgs)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@ -547,6 +547,13 @@ registerChannelValue(supybot.reply.mores, 'instant',
|
|||||||
they are formed). Defaults to 1, which means that a more command will be
|
they are formed). Defaults to 1, which means that a more command will be
|
||||||
required for all but the first chunk.""")))
|
required for all but the first chunk.""")))
|
||||||
|
|
||||||
|
# XXX: User value.
|
||||||
|
registerNetworkValue(supybot.reply.mores.instant, 'whenPrivate',
|
||||||
|
registry.NonNegativeInteger(0, _("""Determines how many mores will be sent
|
||||||
|
instantly (i.e., without the use of the more command, immediately when
|
||||||
|
they are formed) when sending messages in private. Defaults to 0, which means
|
||||||
|
that it defaults to the generic supybot.reply.mores.instant value.""")))
|
||||||
|
|
||||||
registerChannelValue(supybot.reply, 'oneToOne',
|
registerChannelValue(supybot.reply, 'oneToOne',
|
||||||
registry.Boolean(True, _("""Determines whether the bot will send
|
registry.Boolean(True, _("""Determines whether the bot will send
|
||||||
multi-message replies in a single message. This defaults to True
|
multi-message replies in a single message. This defaults to True
|
||||||
|
@ -547,6 +547,13 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
|||||||
"'" + "foo " * 110 + " \x02(2 more messages)\x02")
|
"'" + "foo " * 110 + " \x02(2 more messages)\x02")
|
||||||
self.assertNoResponse(" ", timeout=0.1)
|
self.assertNoResponse(" ", timeout=0.1)
|
||||||
|
|
||||||
|
# not in private -> no effect
|
||||||
|
with conf.supybot.reply.mores.instant.inPrivate.context(2):
|
||||||
|
self.assertResponse(
|
||||||
|
"eval 'foo '*300",
|
||||||
|
"'" + "foo " * 110 + " \x02(2 more messages)\x02")
|
||||||
|
self.assertNoResponse(" ", timeout=0.1)
|
||||||
|
|
||||||
with conf.supybot.reply.mores.instant.context(2):
|
with conf.supybot.reply.mores.instant.context(2):
|
||||||
self.assertResponse(
|
self.assertResponse(
|
||||||
"eval 'foo '*300",
|
"eval 'foo '*300",
|
||||||
@ -568,6 +575,55 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
|||||||
" " + "foo " * 79 + "'")
|
" " + "foo " * 79 + "'")
|
||||||
self.assertNoResponse(" ", timeout=0.1)
|
self.assertNoResponse(" ", timeout=0.1)
|
||||||
|
|
||||||
|
def testReplyInstantInPrivate(self):
|
||||||
|
self.assertNoResponse(' ')
|
||||||
|
self.assertResponse(
|
||||||
|
"eval irc.reply('foo '*300, private=True)",
|
||||||
|
"foo " * 113 + "\x02(2 more messages)\x02")
|
||||||
|
self.assertResponse(" ", "None")
|
||||||
|
|
||||||
|
with conf.supybot.reply.mores.instant.whenPrivate.context(2):
|
||||||
|
self.assertResponse(
|
||||||
|
"eval irc.reply('foo '*300, private=True)",
|
||||||
|
"foo " * 112 + "foo")
|
||||||
|
self.assertResponse(
|
||||||
|
" ",
|
||||||
|
" foo" * 112 + " \x02(1 more message)\x02")
|
||||||
|
self.assertResponse(" ", "None")
|
||||||
|
|
||||||
|
with conf.supybot.reply.mores.instant.whenPrivate.context(2):
|
||||||
|
with conf.supybot.reply.mores.instant.context(3): # ignored
|
||||||
|
self.assertResponse(
|
||||||
|
"eval irc.reply('foo '*300, private=True)",
|
||||||
|
"foo " * 112 + "foo")
|
||||||
|
self.assertResponse(
|
||||||
|
" ",
|
||||||
|
" foo" * 112 + " \x02(1 more message)\x02")
|
||||||
|
self.assertResponse(" ", "None")
|
||||||
|
|
||||||
|
# fall back because supybot.reply.mores.instant.inPrivate is 0
|
||||||
|
with conf.supybot.reply.mores.instant.context(2):
|
||||||
|
self.assertResponse(
|
||||||
|
"eval irc.reply('foo '*300, private=True)",
|
||||||
|
"foo " * 112 + "foo")
|
||||||
|
self.assertResponse(
|
||||||
|
" ",
|
||||||
|
" foo" * 112 + " \x02(1 more message)\x02")
|
||||||
|
self.assertResponse(" ", "None")
|
||||||
|
|
||||||
|
# fall back because supybot.reply.mores.instant.inPrivate is 0
|
||||||
|
with conf.supybot.reply.mores.instant.context(3):
|
||||||
|
self.assertResponse(
|
||||||
|
"eval irc.reply('foo '*300, private=True)",
|
||||||
|
"foo " * 112 + "foo")
|
||||||
|
self.assertResponse(
|
||||||
|
" ",
|
||||||
|
" foo" * 112 + " ")
|
||||||
|
self.assertResponse(
|
||||||
|
" ",
|
||||||
|
"foo " * 75)
|
||||||
|
self.assertResponse(" ", "None")
|
||||||
|
|
||||||
def testReplyPrivate(self):
|
def testReplyPrivate(self):
|
||||||
# Send from a very long nick, which should be taken into account when
|
# Send from a very long nick, which should be taken into account when
|
||||||
# computing the reply overhead.
|
# computing the reply overhead.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user