Files
RSSHub/lib/v2/telegram/stickerpack.js
2022-04-07 22:34:33 +08:00

27 lines
880 B
JavaScript

const got = require('@/utils/got');
const config = require('@/config').value;
module.exports = async (ctx) => {
if (!config.telegram || !config.telegram.token) {
throw 'Telegram Sticker Pack RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>';
}
const name = ctx.params.name;
const response = await got({
method: 'get',
url: `https://api.telegram.org/bot${config.telegram.token}/getStickerSet?name=${name}`,
});
const data = response.data.result;
ctx.state.data = {
title: `${data.title} - Telegram Sticker Pack`,
link: `https://t.me/addstickers/${name}`,
item: data.stickers.map((item) => ({
title: item.emoji,
description: item.file_id,
guid: item.file_id,
})),
};
};