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

Function buildCloudImage

cy/cy.ts:325–338  ·  view source on GitHub ↗
(client: any, target: any, limit: number)

Source from the content-addressed store, hash-verified

323}
324
325async function buildCloudImage(client: any, target: any, limit: number): Promise<{ png: Buffer; validMessages: number }> {
326 const messages = await fetchRecentMessages(client, target, limit);
327 const counts = new Map<string, number>();
328 let validMessages = 0;
329 for (const item of messages) {
330 const text = messageText(item);
331 if (!text || text.startsWith(mainPrefix)) continue;
332 validMessages++;
333 collectWords(text, counts);
334 }
335 const words = buildWordItems(counts);
336 if (!words.length) throw new Error("没有统计到足够的热词。");
337 return { png: renderWordCloud(words, limit, validMessages), validMessages };
338}
339
340async function sendCloudToTarget(client: any, target: any, limit: number, replyTo?: number): Promise<void> {
341 const { png } = await buildCloudImage(client, target, limit);

Callers 1

sendCloudToTargetFunction · 0.85

Calls 5

fetchRecentMessagesFunction · 0.85
collectWordsFunction · 0.85
buildWordItemsFunction · 0.85
renderWordCloudFunction · 0.85
messageTextFunction · 0.70

Tested by

no test coverage detected