| 197 | if (typeof id === "object") { |
| 198 | // 尝试获取 userId、channelId 或 value |
| 199 | const val = id.userId || id.channelId || id.chatId || id.value || id; |
| 200 | return normalizeId(val); |
| 201 | } |
| 202 | return String(id); |
| 203 | } |
| 204 | |
| 205 | async function collectMessages( |
| 206 | chatPeerId: any, // msg.peerId |
| 207 | filterSenderId: string | null, // senderId 用于过滤(数字形式的 userId) |
| 208 | limit: { type: "count"; value: number } | { type: "time"; seconds: number } | { type: "today" } |
| 209 | ): Promise<MessageData[]> { |
| 210 | const client = await getGlobalClient(); |
| 211 | if (!client) throw new Error("客户端未初始化"); |
| 212 | |
| 213 | const messages: MessageData[] = []; |