Skip to content

Commit

Permalink
rss: cache telegram channel name
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed May 25, 2018
1 parent f0f15a9 commit c53795e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion routes/telegram/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,16 @@ module.exports = async (ctx) => {

const data = response.data.result.filter((item) => item.channel_post && item.channel_post.chat && item.channel_post.chat.username === username).reverse();

let title;
if (data[0]) {
title = `${data[0].channel_post.chat.title} - Telegram 频道`;
ctx.cache.set(`RSSHubTelegramChannelName${username}`, data[0].channel_post.chat.title, 30 * 24 * 60 * 60);
} else {
title = `${await ctx.cache.get(`RSSHubTelegramChannelName${username}`)} - Telegram 频道` || `未获取到信息: 请将 Telegram 机器人 @${botName} 设为频道管理员后发一条或以上有效消息完成配置`;
}

ctx.state.data = {
title: data[0] ? `${data[0].channel_post.chat.title} - Telegram 频道` : `未获取到信息: 请将 Telegram 机器人 @${botName} 设为频道管理员后发一条或以上有效消息完成配置`,
title: title,
link: `https://t.me/${username}`,
item: data.map((item) => {
item = item.channel_post;
Expand Down

0 comments on commit c53795e

Please sign in to comment.