From 497f04442583dae3a0a241d3dc9d47b159fc16ea Mon Sep 17 00:00:00 2001 From: missing <4a656666official@gmail.com> Date: Fri, 17 Jun 2022 13:36:42 -0500 Subject: [PATCH] fix StrChunks and content limit shenanigans --- src/discord_irc.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/discord_irc.rs b/src/discord_irc.rs index bf2d300..5015f3b 100644 --- a/src/discord_irc.rs +++ b/src/discord_irc.rs @@ -46,7 +46,7 @@ impl<'a> Iterator for StrChunks<'a> { } }; - self.v = &self.v[self.v.len()..]; + self.v = &self.v[offset..]; Some(res) } @@ -79,7 +79,9 @@ async fn create_prefix(msg: &Message, is_reply: bool, http: impl CacheHttp) -> ( &nick[..second_char_offset], &nick[second_char_offset..] ); - let content_limit = 510 - prefix.len(); + // this 400 is basically just a guess. we cant send exactly 512 byte messages, because + // if we do then the server cant send them back without going over the 512 limit itself. + let content_limit = 400 - prefix.len(); (prefix, content_limit) }