3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-11 04:45:02 +00:00

Fix case embeds breaking with notes over 1024 chars in length

This commit is contained in:
Dragory 2020-07-29 22:48:49 +03:00
parent 3c90e5d4ab
commit ac714ea307
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
2 changed files with 22 additions and 7 deletions

View file

@ -633,9 +633,12 @@ export function chunkLines(str: string, maxChunkLength = 2000): string[] {
/**
* Chunks a long message to multiple smaller messages, retaining leading and trailing line breaks, open code blocks, etc.
*
* Default maxChunkLength is 1990, a bit under the message length limit of 2000, so we have space to add code block
* shenanigans to the start/end when needed. Take this into account when choosing a custom maxChunkLength as well.
*/
export function chunkMessageLines(str: string): string[] {
const chunks = chunkLines(str, 1990); // We don't split at exactly 2000 to be able to do the stuff below
export function chunkMessageLines(str: string, maxChunkLength = 1990): string[] {
const chunks = chunkLines(str, maxChunkLength);
let openCodeBlock = false;
return chunks.map(chunk => {