mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
test osd update
This commit is contained in:
parent
92dab6b4cd
commit
44f5de01ff
@ -77,7 +77,7 @@ class ToolsOSD:
|
|||||||
|
|
||||||
return recipientgroups
|
return recipientgroups
|
||||||
|
|
||||||
def get_available_message_bytes(bot, recipientgroups):
|
def get_available_message_bytes(bot, recipientgroups, text_method):
|
||||||
"""
|
"""
|
||||||
Get total available bytes for sending a message line
|
Get total available bytes for sending a message line
|
||||||
|
|
||||||
@ -89,23 +89,38 @@ class ToolsOSD:
|
|||||||
sendable message length
|
sendable message length
|
||||||
"""
|
"""
|
||||||
|
|
||||||
available_bytes = 512
|
# available_bytes = 512
|
||||||
reserved_irc_bytes = 15
|
# reserved_irc_bytes = 15
|
||||||
available_bytes -= reserved_irc_bytes
|
# available_bytes -= reserved_irc_bytes
|
||||||
try:
|
try:
|
||||||
hostmaskbytes = len((bot.users.get(bot.nick).hostmask).encode('utf-8'))
|
hostmaskbytes = len((bot.users.get(bot.nick).hostmask).encode('utf-8'))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
hostmaskbytes = len((bot.nick).encode('utf-8')) + 12 + 63
|
hostmaskbytes = (len((bot.nick).encode('utf-8')) # Bot's NICKLEN
|
||||||
available_bytes -= hostmaskbytes
|
+ 1 # (! separator)
|
||||||
|
+ 1 # (for the optional ~ in user)
|
||||||
|
+ 9 # max username length (was 12)
|
||||||
|
+ 1 # (@ separator)
|
||||||
|
+ 63 # <hostname> has a maximum length of 63 characters.
|
||||||
|
)
|
||||||
|
# available_bytes -= hostmaskbytes
|
||||||
|
|
||||||
|
# find the maximum target group length, and use the max
|
||||||
groupbytes = []
|
groupbytes = []
|
||||||
for recipients_part in recipientgroups:
|
for recipients_part in recipientgroups:
|
||||||
groupbytes.append(len((recipients_part).encode('utf-8')))
|
groupbytes.append(len((recipients_part).encode('utf-8')))
|
||||||
|
|
||||||
max_recipients_bytes = max(groupbytes)
|
max_recipients_bytes = max(groupbytes)
|
||||||
available_bytes -= max_recipients_bytes
|
# available_bytes -= max_recipients_bytes
|
||||||
|
|
||||||
return available_bytes
|
allowedLength = (512
|
||||||
|
- len(':') - hostmaskbytes
|
||||||
|
- len(' ' + text_method + ' ')
|
||||||
|
- max_recipients_bytes
|
||||||
|
- len(' :')
|
||||||
|
- len('\r\n')
|
||||||
|
)
|
||||||
|
|
||||||
|
return allowedLength
|
||||||
|
|
||||||
def get_sendable_message_list(messages, max_length=400):
|
def get_sendable_message_list(messages, max_length=400):
|
||||||
"""Get a sendable ``text`` message list.
|
"""Get a sendable ``text`` message list.
|
||||||
@ -198,7 +213,7 @@ class SopelOSD:
|
|||||||
text_method = 'PRIVMSG'
|
text_method = 'PRIVMSG'
|
||||||
|
|
||||||
recipientgroups = tools.get_message_recipientgroups(self, recipients, text_method)
|
recipientgroups = tools.get_message_recipientgroups(self, recipients, text_method)
|
||||||
available_bytes = tools.get_available_message_bytes(self, recipientgroups)
|
available_bytes = tools.get_available_message_bytes(self, recipientgroups, text_method)
|
||||||
messages_list = tools.get_sendable_message_list(messages, available_bytes)
|
messages_list = tools.get_sendable_message_list(messages, available_bytes)
|
||||||
|
|
||||||
if max_messages >= 1:
|
if max_messages >= 1:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user