Original TruncateBytes extension method wasn't working right, seemed to include an extra character which would put us over the limit. Replaced it and new method seems to be working as expected albeit not as nice looking.

This commit is contained in:
barelyprofessional
2025-02-09 16:23:35 +08:00
parent f0fc79c142
commit 42e6589e2a
2 changed files with 14 additions and 7 deletions

View File

@@ -302,8 +302,6 @@ public class ChatBot
if (lengthLimitBehavior == LengthLimitBehavior.TruncateExactly)
{
// ReSharper disable once ReplaceSubstringWithRangeIndexer
// The range indexer is a fucking piece of shit that does not work.
// TrimEnd in case you end up truncating on a space (happened during testing) as Sneedchat will trim it
messageTracker.Message = messageTracker.Message.TruncateBytes(lengthLimit).TrimEnd();
}
@@ -311,6 +309,7 @@ public class ChatBot
messageTracker.Status = SentMessageTrackerStatus.WaitingForResponse;
messageTracker.SentAt = DateTimeOffset.UtcNow;
_logger.Debug($"Message is {messageTracker.Message.Utf8LengthBytes()} bytes");
_sentMessages.Add(messageTracker);
await KfClient.SendMessageInstantAsync(messageTracker.Message);
return messageTracker;