()
| 190 | const add = (entity, id) => { |
| 191 | if (!entity || !entity.customEmojiBuffer) return; |
| 192 | const key = String(id ?? entity.custom_emoji_id ?? entity.customEmojiId ?? ""); |
| 193 | if (!key || map[key]) return; |
| 194 | map[key] = entity.customEmojiBuffer; |
| 195 | }; |
| 196 | |
| 197 | const scan = (msg) => { |
| 198 | if (!msg) return; |
| 199 | // Sender emoji status |
| 200 | const status = msg.from?.emoji_status || msg.emoji_status; |
| 201 | if (status?.customEmojiBuffer && status?.custom_emoji_id) { |
| 202 | add(status, status.custom_emoji_id); |
| 203 | } |
| 204 | // Inline custom emoji entities (text + caption) |
| 205 | for (const list of [msg.entities, msg.caption_entities]) { |
| 206 | if (!Array.isArray(list)) continue; |
| 207 | for (const e of list) { |
| 208 | if (e.customEmojiBuffer) { |
| 209 | add(e, e.custom_emoji_id || e.customEmojiId); |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | // Nested: reply & forward |
| 214 | scan(msg.replyMessage); |
| 215 | if (msg.forward) scan(msg.forward); |
| 216 | }; |
| 217 | |
| 218 | for (const msg of messages) scan(msg); |
| 219 | return map; |
| 220 | } |
no test coverage detected