feat(route)(telegram/channel): major rewrite (#9213)

feed title changed to English
route path changed
exclude 'no posts found' messages (always)

custom route params:
exclude forwarded/reply/service messages (selectable)
exclude unsupported messages (selectable, default)
remove link preview (selectable)
remove metadata (via bot / forwarded from / reply to) (selectable)
add forwarded message author (selectable, default)
add inline buttons (selectable)
remove media tags in title (selectable)
non-emoji media tags (selectable)
search query (selectable, retain backward compatibility)

message types newly supported / enhanced:
reply (previous not in media tags, lacks of via bot)
forwarded (previously not in media tags, lacks of via bot)
service (previous not in media tags, img not extracted)
via bot (previous unrecognized, treated as normal messages)
video (previous use another emoji as media tag)
GIF (previous unrecognized, treated as video)
poll (previous only poll title)
voice (previous use another emoji as media tag, no title/content)
music (previous unrecognized, treated as document)
document (previous no content, broken if multiple exist)
location (previous only media tag)
contact (previous totally unsupported)
sticker (previous only media tag)
animated sticker (previous totally unsupported)
unsupported (previous totally unsupported)

misc:
fix emoji in posts: weird format (Italic and Bold)
fix title: lacks of spaces
fix title: use pubDate even if media tags exist
fix broken documents message if multiple documents exist
fix mistaken exception description
fix media sequence: video always at last, #4777
fix: autofilled title (pubDate) not in UTC
use cache
minor refactor

Signed-off-by: Rongrong <15956627+Rongronggg9@users.noreply.github.com>
This commit is contained in:
Rongrong
2022-03-02 19:25:03 +08:00
committed by GitHub
parent 3ceb12182a
commit 2ef844425b
6 changed files with 512 additions and 124 deletions
+27 -1
View File
@@ -241,10 +241,36 @@ Only for self-hosted
### Channel
<RouteEn path="/telegram/channel/:username/:searchQuery?" example="/telegram/channel/awesomeDIYgod/%23DIYgod的豆瓣动态" :paramsDesc="['channel name', 'search query; replace `#` by `%23` for tag searching']" radar="1" rssbud="1">
<RouteEn author="DIYgod Rongronggg9" path="/telegram/channel/:username/:routeParams?" example="/telegram/channel/awesomeDIYgod/searchQuery=%23DIYgod的豆瓣动态" :paramsDesc="['channel username', 'extra parameters, see the table below']" radar="1" rssbud="1">
| Key | Description | Accepts | Defaults to |
|-----------------------|-----------------------------------------------------------------------|------------------------------------------------------|-------------------|
| showLinkPreview | Show the link preview from Telegram | 0/1/true/false | true |
| showViaBot | For messages sent via bot, show the bot | 0/1/true/false | true |
| showReplyTo | For reply messages, show the target of the reply | 0/1/true/false | true |
| showFwdFrom | For forwarded messages, show the forwarding source | 0/1/true/false | true |
| showFwdFromAuthor | For forwarded messages, show the author of the forwarding source | 0/1/true/false | true |
| showInlineButtons | Show inline buttons | 0/1/true/false | false |
| showMediaTagInTitle | Show media tags in the title | 0/1/true/false | true |
| showMediaTagAsEmoji | Show media tags as emoji | 0/1/true/false | true |
| includeFwd | Include forwarded messages | 0/1/true/false | true |
| includeReply | Include reply messages | 0/1/true/false | true |
| includeServiceMsg | Include service messages (e.g. message pinned, channel photo updated) | 0/1/true/false | true |
| includeUnsupportedMsg | Include messages unsupported by t.me | 0/1/true/false | false |
| searchQuery | search query | keywords; replace `#` by `%23` for hashtag searching | (search disabled) |
Specify different option values than default values can meet different needs, URL
```
https://rsshub.app/telegram/channel/NewlearnerChannel/showLinkPreview=0&showViaBot=0&showReplyTo=0&showFwdFrom=0&showFwdFromAuthor=0&showInlineButtons=0&showMediaTagInTitle=1&showMediaTagAsEmoji=1&includeFwd=0&includeReply=1&includeServiceMsg=0&includeUnsupportedMsg=0
```
generates an RSS without any link previews and annoying metadata, with emoji media tags in the title, without forwarded messages (but with reply messages), and without messages you don't care about (service messages and unsupported messages), for people who prefer pure subscriptions.
::: tip
For backward compatibility reasons, invalid `routeParams` will be treated as `searchQuery` .
Due to Telegram restrictions, some channels involving pornography, copyright, and politics cannot be subscribed. You can confirm by visiting `https://t.me/s/:username`.
:::
+27 -1
View File
@@ -602,10 +602,36 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
### 频道
<Route author="DIYgod" example="/telegram/channel/awesomeDIYgod/%23DIYgod的豆瓣动态" path="/telegram/channel/:username/:searchQuery?" :paramsDesc="['频道 username', '搜索关键词, 如需搜索 tag 请用 `%23` 替代 `#`']" radar="1" rssbud="1">
<Route author="DIYgod Rongronggg9" example="/telegram/channel/awesomeDIYgod/searchQuery=%23DIYgod的豆瓣动态" path="/telegram/channel/:username/:routeParams?" :paramsDesc="['频道 username', '额外参数,请参阅下面的表格']" radar="1" rssbud="1">
| 键 | 含义 | 接受的值 | 默认值 |
|-----------------------|-------------------------|-----------------------------------|--------|
| showLinkPreview | 是否显示 Telegram 的链接预览 | 0/1/true/false | true |
| showViaBot | 对于经 bot 发出的消息,是否显示该 bot | 0/1/true/false | true |
| showReplyTo | 对于回复消息,是否显示回复的目标 | 0/1/true/false | true |
| showFwdFrom | 对于转发消息,是否显示消息的转发来源 | 0/1/true/false | true |
| showFwdFromAuthor | 对于转发消息,是否显示消息的转发来源的原始作者 | 0/1/true/false | true |
| showInlineButtons | 是否显示消息的按钮 | 0/1/true/false | false |
| showMediaTagInTitle | 是否在标题中显示媒体标签 | 0/1/true/false | true |
| showMediaTagAsEmoji | 将媒体标签显示为 emoji | 0/1/true/false | true |
| includeFwd | 包含转发消息 | 0/1/true/false | true |
| includeReply | 包含回复消息 | 0/1/true/false | true |
| includeServiceMsg | 包含服务消息 (如: 置顶了消息,更换了头像) | 0/1/true/false | true |
| includeUnsupportedMsg | 包含 t.me 不支持的消息 | 0/1/true/false | false |
| searchQuery | 搜索关键词 | 关键词; 如需搜索 hashtag 请用 `%23` 替代 `#` | (禁用搜索) |
指定更多与默认值不同的参数选项可以满足不同的需求,如
```
https://rsshub.app/telegram/channel/NewlearnerChannel/showLinkPreview=0&showViaBot=0&showReplyTo=0&showFwdFrom=0&showFwdFromAuthor=0&showInlineButtons=0&showMediaTagInTitle=1&showMediaTagAsEmoji=1&includeFwd=0&includeReply=1&includeServiceMsg=0&includeUnsupportedMsg=0
```
会生成一个没有任何链接预览和烦人的元数据,在标题中显示 emoji 媒体标签,不含转发消息(但含有回复消息),也不含你不关心的消息(服务消息和不支持的消息)的 RSS,适合喜欢纯净订阅的人。
::: tip 提示
为向后兼容,不合法的 `routeParams` 会被视作 `searchQuery` 。
由于 Telegram 限制,部分涉及色情、版权、政治的频道无法订阅,可通过访问 <https://t.me/s/:username> 确认。
:::