MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / splitMessage

Function splitMessage

oxost/oxost.ts:20–35  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

18 const parts: string[] = [];
19 let currentPart = "";
20 const lines = text.split("\n");
21 for (const line of lines) {
22 if (currentPart.length + line.length + 1 > MAX_MESSAGE_LENGTH) {
23 parts.push(currentPart);
24 currentPart = line;
25 } else {
26 currentPart += (currentPart ? "\n" : "") + line;
27 }
28 }
29 if (currentPart) parts.push(currentPart);
30 return parts;
31}
32async function sendLongMessage(msg: Api.Message, text: string) {
33 const parts = splitMessage(text);
34 if (parts.length === 1) {
35 await msg.edit({ text: parts[0], parseMode: "html" });
36 } else {
37 await msg.edit({ text: parts[0] + "\n\n📄 (1/" + parts.length + ")", parseMode: "html" });
38 for (let i = 1; i < parts.length; i++) {

Callers 1

sendLongMessageFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected