(parm)
| 160 | if (message.replyMessage) { |
| 161 | if (!message.replyMessage.chatId) { |
| 162 | message.replyMessage.chatId = message.from.id || 0; |
| 163 | } |
| 164 | if (!message.replyMessage.entities) { |
| 165 | message.replyMessage.entities = []; |
| 166 | } |
| 167 | if (!message.replyMessage.from) { |
| 168 | message.replyMessage.from = { |
| 169 | name: message.replyMessage.name, |
| 170 | photo: {}, |
| 171 | }; |
| 172 | } else if (!message.replyMessage.from.photo) { |
| 173 | message.replyMessage.from.photo = {}; |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | // ── TeleBox: collect custom emoji buffers for the vendor ────────────── |
| 179 | // The vendor resolves custom emoji images through loadCustomEmojis(), which |
| 180 | // either reads buffers from a plain object (PATH 1: no callApi) or fetches |
| 181 | // from Telegram via a bot token (PATH 2: Telegraf instance). TeleBox runs |
| 182 | // as a userbot — it has no bot token, so PATH 2 always fails. Instead we |
| 183 | // pre-download every custom emoji buffer in hydrateCustomEmojiBuffers(), |
| 184 | // attach them to message entities/emoji_status, and pack them into a plain |
| 185 | // object map here. This map is then passed as the 8th (telegram) argument |
| 186 | // to quoteGenerate.generate() so PATH 1 works and every custom emoji |
| 187 | // (status + inline) renders correctly. |
| 188 | function collectCustomEmojiBuffers(messages) { |
| 189 | const map = {}; |
| 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; |
nothing calls this directly
no test coverage detected