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

Function splitLongText

admin_board/admin_board.ts:148–179  ·  view source on GitHub ↗
(text: string, maxLength = MAX_MESSAGE_LENGTH)

Source from the content-addressed store, hash-verified

146 current = next;
147 continue;
148 }
149
150 if (current) {
151 chunks.push(current);
152 current = "";
153 }
154
155 if (line.length <= maxLength) {
156 current = line;
157 continue;
158 }
159
160 for (let index = 0; index < line.length; index += maxLength) {
161 chunks.push(line.slice(index, index + maxLength));
162 }
163 }
164
165 if (current) chunks.push(current);
166 return chunks;
167}
168
169async function sendLongResult(msg: Api.Message, text: string): Promise<void> {
170 const chunks = splitLongText(text);
171 await msg.edit({
172 text: chunks[0],
173 parseMode: "html",
174 linkPreview: false,
175 });
176
177 for (let index = 1; index < chunks.length; index++) {
178 await msg.reply({
179 message: `📋 <b>续 ${index}/${chunks.length - 1}</b>\n\n${chunks[index]}`,
180 parseMode: "html",
181 linkPreview: false,
182 });

Callers 1

sendLongResultFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected