(peer: Api.TypePeer, msgId: number, reactions: (string | BigInteger)[], big: boolean)
| 554 | return { id, entity, display: displayParts.join(" ").trim() }; |
| 555 | } |
| 556 | |
| 557 | private async parseReactions(msg: Api.Message, text: string): Promise<(string | BigInteger)[]> { |
| 558 | await this.initializeSelf(); // Ensures isPremium is set |
| 559 | const validReactions: (string | BigInteger)[] = []; |
| 560 | const customEmojiMap = new Map<number, BigInteger>(); |
| 561 | const customEmojiIndices = new Set<number>(); |
| 562 | if (this.isPremium) { |
| 563 | const customEmojiEntities = (msg.entities || []).filter( |
| 564 | (e): e is Api.MessageEntityCustomEmoji => e instanceof Api.MessageEntityCustomEmoji |
| 565 | ); |
| 566 | for (const entity of customEmojiEntities) { |
| 567 | customEmojiMap.set(entity.offset, entity.documentId); |
| 568 | for (let i = 0; i < entity.length; i++) { |
| 569 | customEmojiIndices.add(entity.offset + i); |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | const textOffsetInMessage = msg.message.indexOf(text); |
| 574 | if (textOffsetInMessage === -1) return []; |
| 575 | let currentIndex = 0; |
| 576 | for (const char of text) { |
| 577 | const fullMessageOffset = textOffsetInMessage + currentIndex; |
| 578 | if (customEmojiMap.has(fullMessageOffset)) { |
| 579 | validReactions.push(customEmojiMap.get(fullMessageOffset)!); |
no outgoing calls
no test coverage detected