From 63f7dab32de88b4bdf6621739b9fcf1f15c19fb1 Mon Sep 17 00:00:00 2001 From: bunizao <102936102+bunizao@users.noreply.github.com> Date: Mon, 12 Jan 2026 04:28:58 +0800 Subject: [PATCH] refactor: simplify custom emoji image retrieval by removing caching logic and using direct URL construction --- src/lib/telegram/index.js | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/src/lib/telegram/index.js b/src/lib/telegram/index.js index 89528e9..44c3e29 100644 --- a/src/lib/telegram/index.js +++ b/src/lib/telegram/index.js @@ -24,31 +24,12 @@ function normalizeEmoji(emoji) { return emojiMap[emoji] || emoji } -const customEmojiCache = new LRUCache({ - ttl: 1000 * 60 * 60 * 24, // 24 hours - max: 500, -}) - async function getCustomEmojiImage(emojiId, staticProxy = '') { if (!emojiId) return null - const cached = customEmojiCache.get(emojiId) - if (cached?.thumb) { - return `${staticProxy}${cached.thumb}` - } - try { - const data = await $fetch(`https://t.me/i/emoji/${emojiId}.json`) - if (data) { - customEmojiCache.set(emojiId, data) - if (data.thumb) { - return `${staticProxy}${data.thumb}` - } - } - } - catch (error) { - console.error('Failed to load custom emoji metadata', emojiId, error) - } - return null + const imageUrl = `https://t.me/i/emoji/${emojiId}.webp` + const proxy = staticProxy || '/static/' + return `${proxy}${imageUrl}` } async function hydrateTgEmoji($, content, { staticProxy } = {}) {