From 44f5de01ff9de385330b0edb5444b49a6223d5a4 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 1 Oct 2019 14:35:48 -0400 Subject: [PATCH 01/11] test osd update --- sopel_modules/SpiceBot/osd.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/sopel_modules/SpiceBot/osd.py b/sopel_modules/SpiceBot/osd.py index ca892f2..e665e62 100644 --- a/sopel_modules/SpiceBot/osd.py +++ b/sopel_modules/SpiceBot/osd.py @@ -77,7 +77,7 @@ class ToolsOSD: 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 @@ -89,23 +89,38 @@ class ToolsOSD: sendable message length """ - available_bytes = 512 - reserved_irc_bytes = 15 - available_bytes -= reserved_irc_bytes + # available_bytes = 512 + # reserved_irc_bytes = 15 + # available_bytes -= reserved_irc_bytes try: hostmaskbytes = len((bot.users.get(bot.nick).hostmask).encode('utf-8')) except AttributeError: - hostmaskbytes = len((bot.nick).encode('utf-8')) + 12 + 63 - available_bytes -= hostmaskbytes + hostmaskbytes = (len((bot.nick).encode('utf-8')) # Bot's NICKLEN + + 1 # (! separator) + + 1 # (for the optional ~ in user) + + 9 # max username length (was 12) + + 1 # (@ separator) + + 63 # has a maximum length of 63 characters. + ) + # available_bytes -= hostmaskbytes + # find the maximum target group length, and use the max groupbytes = [] for recipients_part in recipientgroups: groupbytes.append(len((recipients_part).encode('utf-8'))) 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): """Get a sendable ``text`` message list. @@ -198,7 +213,7 @@ class SopelOSD: text_method = 'PRIVMSG' 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) if max_messages >= 1: From 5d15de9367bfbb79f96333dd58fbb739d11f95db Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 1 Oct 2019 14:36:57 -0400 Subject: [PATCH 02/11] tilde might be more than one byte --- sopel_modules/SpiceBot/osd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/osd.py b/sopel_modules/SpiceBot/osd.py index e665e62..2b86ad7 100644 --- a/sopel_modules/SpiceBot/osd.py +++ b/sopel_modules/SpiceBot/osd.py @@ -97,7 +97,7 @@ class ToolsOSD: except AttributeError: hostmaskbytes = (len((bot.nick).encode('utf-8')) # Bot's NICKLEN + 1 # (! separator) - + 1 # (for the optional ~ in user) + + len('~') # (for the optional ~ in user) + 9 # max username length (was 12) + 1 # (@ separator) + 63 # has a maximum length of 63 characters. From 1315a77d2afe31c4fc8da17788c387c1ed96f6e2 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 1 Oct 2019 14:41:39 -0400 Subject: [PATCH 03/11] test --- sopel_modules/SpiceBot/osd.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sopel_modules/SpiceBot/osd.py b/sopel_modules/SpiceBot/osd.py index 2b86ad7..5abe0b0 100644 --- a/sopel_modules/SpiceBot/osd.py +++ b/sopel_modules/SpiceBot/osd.py @@ -120,6 +120,7 @@ class ToolsOSD: - len('\r\n') ) + bot.say("length of " + text_method + " to " + str(recipientgroups) + " is " + str(allowedLength)) return allowedLength def get_sendable_message_list(messages, max_length=400): From f91a088817b3186aaae0bb031b9bf1272a2d6d0f Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 1 Oct 2019 14:41:55 -0400 Subject: [PATCH 04/11] test --- sopel_modules/SpiceBot/osd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/osd.py b/sopel_modules/SpiceBot/osd.py index 5abe0b0..ab0b866 100644 --- a/sopel_modules/SpiceBot/osd.py +++ b/sopel_modules/SpiceBot/osd.py @@ -120,7 +120,7 @@ class ToolsOSD: - len('\r\n') ) - bot.say("length of " + text_method + " to " + str(recipientgroups) + " is " + str(allowedLength)) + bot.say("length of " + text_method + " to " + str(recipientgroups) + " is " + str(allowedLength), "#deathbybandaid") return allowedLength def get_sendable_message_list(messages, max_length=400): From dea7db931f5c7fcb9b8c2b1d38eb79aa434585db Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 1 Oct 2019 14:44:01 -0400 Subject: [PATCH 05/11] test --- sopel_modules/SpiceBot/osd.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sopel_modules/SpiceBot/osd.py b/sopel_modules/SpiceBot/osd.py index ab0b866..35deb47 100644 --- a/sopel_modules/SpiceBot/osd.py +++ b/sopel_modules/SpiceBot/osd.py @@ -89,6 +89,9 @@ class ToolsOSD: sendable message length """ + if text_method == 'ACTION': + text_method = 'PRIVMSG' + # available_bytes = 512 # reserved_irc_bytes = 15 # available_bytes -= reserved_irc_bytes From ee083621d6dd7da6efd257ba5c8912a8366adde4 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 1 Oct 2019 14:46:21 -0400 Subject: [PATCH 06/11] test --- sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py index 58a65d6..2e50bdb 100644 --- a/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py +++ b/sopel_modules/SpiceBot_Core_Processing/StartupMonologue.py @@ -10,7 +10,7 @@ import sopel_modules.SpiceBot as SpiceBot import time -@sopel.module.event(SpiceBot.events.BOT_CONNECTED) +@sopel.module.event(SpiceBot.events.BOT_CHANNELS) @sopel.module.rule('.*') def bot_startup_monologue_start(bot, trigger): # Startup From 72ce8f42cb3d91ad4b92af4b55aadfa0bf4a3d33 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 1 Oct 2019 14:47:38 -0400 Subject: [PATCH 07/11] finished with osd --- sopel_modules/SpiceBot/osd.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sopel_modules/SpiceBot/osd.py b/sopel_modules/SpiceBot/osd.py index 35deb47..84fcca3 100644 --- a/sopel_modules/SpiceBot/osd.py +++ b/sopel_modules/SpiceBot/osd.py @@ -123,7 +123,6 @@ class ToolsOSD: - len('\r\n') ) - bot.say("length of " + text_method + " to " + str(recipientgroups) + " is " + str(allowedLength), "#deathbybandaid") return allowedLength def get_sendable_message_list(messages, max_length=400): From 348b8f2fdb05486cec771954b38e9458c926f7dc Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 1 Oct 2019 15:17:48 -0400 Subject: [PATCH 08/11] real test --- sopel_modules/SpiceBot/osd.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sopel_modules/SpiceBot/osd.py b/sopel_modules/SpiceBot/osd.py index 84fcca3..a9ee288 100644 --- a/sopel_modules/SpiceBot/osd.py +++ b/sopel_modules/SpiceBot/osd.py @@ -92,12 +92,16 @@ class ToolsOSD: if text_method == 'ACTION': text_method = 'PRIVMSG' - # available_bytes = 512 - # reserved_irc_bytes = 15 - # available_bytes -= reserved_irc_bytes + available_bytes = 512 + reserved_irc_bytes = 15 + available_bytes -= reserved_irc_bytes try: hostmaskbytes = len((bot.users.get(bot.nick).hostmask).encode('utf-8')) + available_bytes -= hostmaskbytes except AttributeError: + # hostmaskbytes = len((bot.nick).encode('utf-8')) + 12 + 63 + hostmaskbytes = len((bot.nick).encode('utf-8')) + 12 + 63 + available_bytes -= hostmaskbytes hostmaskbytes = (len((bot.nick).encode('utf-8')) # Bot's NICKLEN + 1 # (! separator) + len('~') # (for the optional ~ in user) @@ -113,7 +117,7 @@ class ToolsOSD: groupbytes.append(len((recipients_part).encode('utf-8'))) max_recipients_bytes = max(groupbytes) - # available_bytes -= max_recipients_bytes + available_bytes -= max_recipients_bytes allowedLength = (512 - len(':') - hostmaskbytes @@ -123,6 +127,8 @@ class ToolsOSD: - len('\r\n') ) + bot.say("old length of " + text_method + " to " + str(recipientgroups) + " is " + str(allowedLength), "#deathbybandaid") + bot.say("new length of " + text_method + " to " + str(recipientgroups) + " is " + str(available_bytes), "#deathbybandaid") return allowedLength def get_sendable_message_list(messages, max_length=400): From 50f3e170c31a0a8e046e67375696921031bcc99a Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 1 Oct 2019 15:19:19 -0400 Subject: [PATCH 09/11] test --- sopel_modules/SpiceBot/osd.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/sopel_modules/SpiceBot/osd.py b/sopel_modules/SpiceBot/osd.py index a9ee288..c81ba8a 100644 --- a/sopel_modules/SpiceBot/osd.py +++ b/sopel_modules/SpiceBot/osd.py @@ -92,16 +92,13 @@ class ToolsOSD: if text_method == 'ACTION': text_method = 'PRIVMSG' - available_bytes = 512 - reserved_irc_bytes = 15 - available_bytes -= reserved_irc_bytes + # available_bytes = 512 + # reserved_irc_bytes = 15 + # available_bytes -= reserved_irc_bytes try: hostmaskbytes = len((bot.users.get(bot.nick).hostmask).encode('utf-8')) - available_bytes -= hostmaskbytes except AttributeError: # hostmaskbytes = len((bot.nick).encode('utf-8')) + 12 + 63 - hostmaskbytes = len((bot.nick).encode('utf-8')) + 12 + 63 - available_bytes -= hostmaskbytes hostmaskbytes = (len((bot.nick).encode('utf-8')) # Bot's NICKLEN + 1 # (! separator) + len('~') # (for the optional ~ in user) @@ -117,7 +114,7 @@ class ToolsOSD: groupbytes.append(len((recipients_part).encode('utf-8'))) max_recipients_bytes = max(groupbytes) - available_bytes -= max_recipients_bytes + # available_bytes -= max_recipients_bytes allowedLength = (512 - len(':') - hostmaskbytes @@ -127,8 +124,6 @@ class ToolsOSD: - len('\r\n') ) - bot.say("old length of " + text_method + " to " + str(recipientgroups) + " is " + str(allowedLength), "#deathbybandaid") - bot.say("new length of " + text_method + " to " + str(recipientgroups) + " is " + str(available_bytes), "#deathbybandaid") return allowedLength def get_sendable_message_list(messages, max_length=400): From 857a06b5561ab62b54d16997bc1721873cdaa8ce Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 1 Oct 2019 15:33:02 -0400 Subject: [PATCH 10/11] remove commetn --- sopel_modules/SpiceBot/osd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/osd.py b/sopel_modules/SpiceBot/osd.py index c81ba8a..e76b3c8 100644 --- a/sopel_modules/SpiceBot/osd.py +++ b/sopel_modules/SpiceBot/osd.py @@ -102,7 +102,7 @@ class ToolsOSD: hostmaskbytes = (len((bot.nick).encode('utf-8')) # Bot's NICKLEN + 1 # (! separator) + len('~') # (for the optional ~ in user) - + 9 # max username length (was 12) + + 9 # max username length + 1 # (@ separator) + 63 # has a maximum length of 63 characters. ) From edd4490cd16cb2782a866afbb8e5e5c22fd29f57 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 1 Oct 2019 15:54:14 -0400 Subject: [PATCH 11/11] extra bites required by action --- sopel_modules/SpiceBot/osd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot/osd.py b/sopel_modules/SpiceBot/osd.py index e76b3c8..99e2ae8 100644 --- a/sopel_modules/SpiceBot/osd.py +++ b/sopel_modules/SpiceBot/osd.py @@ -90,7 +90,7 @@ class ToolsOSD: """ if text_method == 'ACTION': - text_method = 'PRIVMSG' + text_method = "\x01ACTION \x01" # available_bytes = 512 # reserved_irc_bytes = 15