UNPKG

rsshub

Version:
51 lines (49 loc) 1.98 kB
import "./esm-shims-CzJ_djXG.mjs"; import { t as config } from "./config-C37vj7VH.mjs"; import { t as ViewType } from "./types-D84BRIt4.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs"; import { t as cache_default } from "./cache-Bo__VnGm.mjs"; import { t as config_not_found_default } from "./config-not-found-Dyp3RlZZ.mjs"; //#region lib/routes/telegram/stickerpack.ts const route = { path: "/stickerpack/:name", categories: ["social-media"], view: ViewType.Pictures, example: "/telegram/stickerpack/DIYgod", parameters: { name: "Sticker Pack name, available in the sharing URL" }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, name: "Sticker Pack", maintainers: ["DIYgod"], handler }; async function handler(ctx) { if (!config.telegram || !config.telegram.token) throw new config_not_found_default("Telegram Sticker Pack RSS is disabled due to the lack of <a href=\"https://docs.rsshub.app/deploy/config#route-specific-configurations\">relevant config</a>"); const name = ctx.req.param("name"); const token = config.telegram.token; const response = await ofetch_default(`https://api.telegram.org/bot${token}/getStickerSet?name=${name}`); const list = response.result.stickers.map((item) => ({ title: item.emoji, description: item.file_id, guid: item.file_id })); const items = await Promise.all(list.map((item) => cache_default.tryGet(`telegram:stickerpack:${item.guid}`, async () => { item.description = `<img src="https://api.telegram.org/file/bot${token}/${(await ofetch_default(`https://api.telegram.org/bot${token}/getFile?file_id=${item.guid}`)).result.file_path}" />`; return item; }))); return { title: `${response.result.title} - Telegram Sticker Pack`, link: `https://t.me/addstickers/${name}`, item: items }; } //#endregion export { route };