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

Function getGroupedMessageIds

ai/ai.ts:824–844  ·  view source on GitHub ↗
(msg: Api.Message)

Source from the content-addressed store, hash-verified

822
823const getGroupedMessageIds = async (msg: Api.Message): Promise<number[]> => {
824 if (!msg?.client) return [];
825 const rawGroupedId = (msg as any).groupedId;
826 const groupedId = rawGroupedId ? rawGroupedId.toString() : undefined;
827 if (!groupedId) return [];
828
829 const peer = msg.chatId || msg.peerId;
830 const ids: number[] = [];
831
832 for await (const m of msg.client.iterMessages(peer, { limit: 50 })) {
833 if (!(m instanceof Api.Message)) continue;
834 const g = (m as any).groupedId;
835 if (!g) continue;
836 if (g.toString() !== groupedId) continue;
837 ids.push(Number(m.id));
838 }
839
840 if (!ids.includes(Number(msg.id))) ids.push(Number(msg.id));
841
842 return Array.from(new Set(ids)).sort((a, b) => a - b);
843};
844
845const deleteMessageOrGroup = async (msg: Api.Message): Promise<void> => {
846 try {
847 if (!msg?.client) return;

Callers 1

deleteMessageOrGroupFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected