( client: TelegramClient, chatEntity: any )
| 275 | const rawIds = new Set<string>(); |
| 276 | try { |
| 277 | const sendAs = await client.invoke( |
| 278 | new Api.channels.GetSendAs({ |
| 279 | peer: chatEntity, |
| 280 | }) |
| 281 | ); |
| 282 | const peers = (sendAs as any).peers || []; |
| 283 | for (const item of peers) { |
| 284 | const peer = (item as any)?.peer; |
| 285 | const typedKey = peerToTypedKey(peer); |
| 286 | if (typedKey) { |
| 287 | typedKeys.add(typedKey); |
| 288 | } |
| 289 | const rawId = getPeerRawId(peer); |
| 290 | if (rawId) { |
| 291 | rawIds.add(rawId); |
| 292 | rawIds.add(normalizeIdToken(rawId)); |
| 293 | } |
| 294 | } |
| 295 | console.log( |
| 296 | `[DME] 获取发送身份成功: typed=${typedKeys.size}, raw=${rawIds.size}` |
| 297 | ); |
| 298 | } catch (error: any) { |
| 299 | console.log(`[DME] 获取发送身份失败,回退基础匹配: ${error?.message || error}`); |
| 300 | } |
| 301 | return { typedKeys, rawIds }; |
| 302 | } |
| 303 | |
| 304 | function isMyMessageByIdentity( |
| 305 | message: any, |
| 306 | myId: bigint, |
| 307 | sendAsTypedKeySet: Set<string>, |
| 308 | sendAsRawIdSet: Set<string> |
| 309 | ): boolean { |
| 310 | if (message.senderId?.toString?.() === myId.toString()) { |
| 311 | return true; |
| 312 | } |
no test coverage detected