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

Function collectMessages

bs/bs.ts:563–590  ·  view source on GitHub ↗
(
  client: any,
  peer: any,
  startId: number,
  desiredCount: number
)

Source from the content-addressed store, hash-verified

561}
562
563async function collectMessages(
564 client: any,
565 peer: any,
566 startId: number,
567 desiredCount: number
568) {
569 const messageIds: number[] = [];
570 const MAX_SEARCH_LIMIT = 500;
571 const maxSearch = Math.min(desiredCount * 3, MAX_SEARCH_LIMIT);
572 let currentId = startId;
573
574 while (messageIds.length < desiredCount && currentId < startId + maxSearch) {
575 try {
576 const fetched = await safeGetMessages(client, peer, {
577 ids: [currentId],
578 });
579 const candidate = Array.isArray(fetched) ? fetched[0] : fetched;
580 if (candidate && candidate.id) {
581 messageIds.push(candidate.id);
582 }
583 } catch (error) {
584 console.warn(`[bs] 获取消息 ${currentId} 失败`, error);
585 }
586 currentId += 1;
587 }
588
589 return { messageIds };
590}
591
592async function sendSourceFeedback(options: {
593 msg: Api.Message;

Callers 1

BsPluginClass · 0.70

Calls 1

warnMethod · 0.80

Tested by

no test coverage detected