mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 21:29:24 +01:00
Fix for bug with instant mores; also change supybot.reply.truncate to supybot.reply.mores (i.e., it's not just a group now, it's a boolean).
This commit is contained in:
parent
a1b7b670fb
commit
0408beb0fb
@ -160,6 +160,7 @@ def reply(msg, s, prefixName=None, private=None,
|
|||||||
notice=None, to=None, action=None, error=False):
|
notice=None, to=None, action=None, error=False):
|
||||||
msg.tag('repliedTo')
|
msg.tag('repliedTo')
|
||||||
# Ok, let's make the target:
|
# Ok, let's make the target:
|
||||||
|
# XXX This isn't entirely right. Consider to=#foo, private=True.
|
||||||
target = ircutils.replyTo(msg)
|
target = ircutils.replyTo(msg)
|
||||||
if ircutils.isChannel(target):
|
if ircutils.isChannel(target):
|
||||||
channel = target
|
channel = target
|
||||||
@ -781,13 +782,12 @@ class IrcObjectProxy(RichReplyMethods):
|
|||||||
self.to = self.to or to
|
self.to = self.to or to
|
||||||
# action=True implies noLengthCheck=True and prefixName=False
|
# action=True implies noLengthCheck=True and prefixName=False
|
||||||
self.noLengthCheck=noLengthCheck or self.noLengthCheck or self.action
|
self.noLengthCheck=noLengthCheck or self.noLengthCheck or self.action
|
||||||
|
target = self.private and self.to or self.msg.args[0]
|
||||||
s = ircutils.safeArgument(s)
|
s = ircutils.safeArgument(s)
|
||||||
if self.finalEvaled:
|
if self.finalEvaled:
|
||||||
try:
|
try:
|
||||||
if not isinstance(self.irc, irclib.Irc):
|
if not isinstance(self.irc, irclib.Irc):
|
||||||
s = s[:conf.supybot.reply.maximumLength()]
|
s = s[:conf.supybot.reply.maximumLength()]
|
||||||
if conf.get(conf.supybot.reply.truncate, self.msg.args[0]):
|
|
||||||
s = s[:512]
|
|
||||||
return self.irc.reply(s, to=self.to,
|
return self.irc.reply(s, to=self.to,
|
||||||
notice=self.notice,
|
notice=self.notice,
|
||||||
action=self.action,
|
action=self.action,
|
||||||
@ -806,13 +806,15 @@ class IrcObjectProxy(RichReplyMethods):
|
|||||||
return m
|
return m
|
||||||
else:
|
else:
|
||||||
allowedLength = 450 - len(self.irc.prefix)
|
allowedLength = 450 - len(self.irc.prefix)
|
||||||
maximumMores = conf.supybot.reply.mores.maximum()
|
maximumMores = conf.get(conf.supybot.reply.mores.maximum,
|
||||||
|
target)
|
||||||
maximumLength = allowedLength * maximumMores
|
maximumLength = allowedLength * maximumMores
|
||||||
if len(s) > maximumLength:
|
if len(s) > maximumLength:
|
||||||
log.warning('Truncating to %s bytes from %s bytes.',
|
log.warning('Truncating to %s bytes from %s bytes.',
|
||||||
maximumLength, len(s))
|
maximumLength, len(s))
|
||||||
s = s[:maximumLength]
|
s = s[:maximumLength]
|
||||||
if len(s) < allowedLength or conf.supybot.reply.truncate():
|
if len(s) < allowedLength or \
|
||||||
|
not conf.get(conf.supybot.reply.mores, target):
|
||||||
# In case we're truncating, we add 20 to allowedLength,
|
# In case we're truncating, we add 20 to allowedLength,
|
||||||
# because our allowedLength is shortened for the
|
# because our allowedLength is shortened for the
|
||||||
# "(XX more messages)" trailer.
|
# "(XX more messages)" trailer.
|
||||||
@ -829,7 +831,7 @@ class IrcObjectProxy(RichReplyMethods):
|
|||||||
return m
|
return m
|
||||||
msgs = ircutils.wrap(s, allowedLength-30) # -30 is for nick:
|
msgs = ircutils.wrap(s, allowedLength-30) # -30 is for nick:
|
||||||
msgs.reverse()
|
msgs.reverse()
|
||||||
instant = conf.supybot.reply.mores.instant()
|
instant = conf.get(conf.supybot.reply.mores.instant,target)
|
||||||
while instant > 1 and msgs:
|
while instant > 1 and msgs:
|
||||||
instant -= 1
|
instant -= 1
|
||||||
response = msgs.pop()
|
response = msgs.pop()
|
||||||
@ -838,7 +840,11 @@ class IrcObjectProxy(RichReplyMethods):
|
|||||||
private=self.private,
|
private=self.private,
|
||||||
prefixName=self.prefixName)
|
prefixName=self.prefixName)
|
||||||
self.irc.queueMsg(m)
|
self.irc.queueMsg(m)
|
||||||
return m
|
# XXX We should somehow allow these to be returned, but
|
||||||
|
# until someone complains, we'll be fine :) We
|
||||||
|
# can't return from here, though, for obvious
|
||||||
|
# reasons.
|
||||||
|
# return m
|
||||||
if not msgs:
|
if not msgs:
|
||||||
return
|
return
|
||||||
response = msgs.pop()
|
response = msgs.pop()
|
||||||
|
@ -277,12 +277,11 @@ registerGlobalValue(supybot.reply, 'maximumLength',
|
|||||||
bot's reply -- no reply will be passed through the bot with a length
|
bot's reply -- no reply will be passed through the bot with a length
|
||||||
greater than this."""))
|
greater than this."""))
|
||||||
|
|
||||||
registerChannelValue(supybot.reply, 'truncate',
|
registerChannelValue(supybot.reply, 'mores',
|
||||||
registry.Boolean(False, """Determines whether the bot will simply truncate
|
registry.Boolean(True, """Determines whether the bot will break up long
|
||||||
messages instead of breaking up long messages and using the 'more' command
|
messages into chunks and allow users to use the 'more' command to get the
|
||||||
to get the remaining chunks."""))
|
remaining chunks."""))
|
||||||
|
|
||||||
registerGroup(supybot.reply, 'mores')
|
|
||||||
registerChannelValue(supybot.reply.mores, 'maximum',
|
registerChannelValue(supybot.reply.mores, 'maximum',
|
||||||
registry.PositiveInteger(50, """Determines what the maximum number of
|
registry.PositiveInteger(50, """Determines what the maximum number of
|
||||||
chunks (for use with the 'more' command) will be."""))
|
chunks (for use with the 'more' command) will be."""))
|
||||||
|
Loading…
Reference in New Issue
Block a user