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

Method onCmd

fbi/fbi.ts:219–236  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

217
218 /** scan public groups one-by-one with random delay, fill chatCache */
219 private async buildCache() {
220 try {
221 const cl = await getGlobalClient();
222 if (!cl) return;
223
224 const limit = this.configDb.data.cacheLimit;
225 // paginated getDialogs — respect cacheLimit > 100
226 const all: any[] = [];
227 let offsetId = 0;
228 let offsetDate = 0;
229 let offsetPeer: any = new Api.InputPeerEmpty();
230 while (all.length < limit) {
231 const page = (await cl.getDialogs({ offsetId, offsetDate, offsetPeer, limit: 100 })) as any[];
232 if (!page.length) break;
233 for (const d of page) {
234 if (d.isGroup || d.isChat) all.push(d);
235 if (all.length >= limit) break;
236 }
237 if (page.length < 100) break; // last page
238 const last = page[page.length - 1];
239 offsetId = last.dialog?.topMessage?.id ?? 0;

Callers

nothing calls this directly

Calls 7

doCsMethod · 0.95
doSvMethod · 0.95
doDsMethod · 0.95
doSsvMethod · 0.95
doCacheMethod · 0.95
htmlEscFunction · 0.85
editMethod · 0.45

Tested by

no test coverage detected