diff --git a/docs/social-media.md b/docs/social-media.md
index dbb9bd1345..d47d1a212e 100644
--- a/docs/social-media.md
+++ b/docs/social-media.md
@@ -640,7 +640,7 @@ pageClass: routes
-### 公众号(Telegrame 频道来源)
+### 公众号(Telegram 频道来源)
diff --git a/lib/routes/tencent/wechat/tgchannel.js b/lib/routes/tencent/wechat/tgchannel.js
index ae0ee27b64..e30186bbb3 100644
--- a/lib/routes/tencent/wechat/tgchannel.js
+++ b/lib/routes/tencent/wechat/tgchannel.js
@@ -6,25 +6,52 @@ module.exports = async (ctx) => {
const { data } = await axios.get(`https://t.me/s/${id}`);
const $ = cheerio.load(data);
- const list = $('.tgme_widget_message_wrap');
+ const list = $('.tgme_widget_message_wrap').slice(-10);
const out = await Promise.all(
list
- .map((index, item) => {
+ .map(async (index, item) => {
item = $(item);
- const title = item.find('.tgme_widget_message_text > a:nth-child(2)').text();
- const link = item.find('.tgme_widget_message_text > a:nth-child(2)').attr('href');
+
+ let author;
+ let title = item.find('.tgme_widget_message_text > a:nth-child(5)').text() || item.find('.tgme_widget_message_text > a:nth-child(2)').text();
+
+ const all_text = item.find('.tgme_widget_message_text').text();
+ if (all_text.indexOf(':') !== -1) {
+ author = all_text.split(':')[0].split(' ')[1];
+ title = author + ': ' + title;
+ }
+
+ const link = item.find('.tgme_widget_message_text > a:nth-child(5)').attr('href') || item.find('.tgme_widget_message_text > a:nth-child(2)').attr('href');
const pubDate = new Date(item.find('.tgme_widget_message_date time').attr('datetime')).toUTCString();
- const description = item.find('.tgme_widget_message_text').html();
const single = {
title,
pubDate,
link,
- description,
+ author,
};
- return single;
+ if (link !== undefined) {
+ const value = await ctx.cache.get(link);
+ if (value) {
+ single.description = value;
+ } else {
+ try {
+ const reponse = await axios.get(link);
+ const $ = cheerio.load(reponse.data);
+
+ single.description = $('.rich_media_content')
+ .html()
+ .replace(/data-src/g, 'src');
+ ctx.cache.set(link, single.description, 12 * 60 * 60);
+ } catch (err) {
+ single.description = item.find('.tgme_widget_message_text').html();
+ }
+ }
+ }
+
+ return Promise.resolve(single);
})
.get()
);