Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed parsing of Telegram entities #2515

Merged
merged 1 commit into from
Jul 5, 2024
Merged

Fixed parsing of Telegram entities #2515

merged 1 commit into from
Jul 5, 2024

Conversation

BrettDean
Copy link
Contributor

app/modules/telegram/telegram.py的函数__send_request

如果字符串caption中包含不成对的:下划线'_', 星号'*', 反引号'`'

发送消息出去就会报错: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 0, 3 秒后重试 ...

比如: 当caption

*开始播放电影 哆啦A梦:2112年哆啦A梦的诞生 (1995)*\n用户:brett_dean\n设备:iPhone  \nIP地址:xxx.xxx.xxx.xxx X国[XX] XX省 XX市 XX区\n剧情:《2112年哆啦A梦的诞生》(日语:2112年 ドラえもん誕生)是1995年3月4日公映的哆啦A梦附篇电影,由米谷良知导演,原作者藤子·F·不二雄,与《大雄的创世日记》同时上映。片长30分钟,主要叙述...\n时间:2024-xx-xx xx:xx:xx\n[查看详情](https://xxx.xxx.com/web/index.html#!/server/xxxxx/details?key=xxxx)

的时候,就会因为 用户:brett_dean 中含有下划线_而报错

所以发消息前要先转义一下,转义后即可正常发送:
image


api说明: https://core.telegram.org/bots/api#markdown-style

Please note:
To escape characters '_', '*', '`', '[' outside of an entity, prepend the characters '\' before them.

另外这种发送文字+媒体的形式,文字最多只能有1024个,多了就会报错,和下面的纯文字可以发4096个不一样。
一般用也不到1024个字,吧

@jxxghp jxxghp merged commit 2b9e69b into jxxghp:main Jul 5, 2024
@jxxghp
Copy link
Owner

jxxghp commented Jul 12, 2024

IMG_8295

产生了新bug,请修复 @BrettDean

@BrettDean
Copy link
Contributor Author

BrettDean commented Jul 12, 2024

IMG_8295

产生了新bug,请修复 @BrettDean

新pr中,替换前做了个简单判断,能力有限啊大佬😭

@freefrank
Copy link

freefrank commented Jul 15, 2024

【WARNING】2024-07-15 17:46:44,420 - common.py - A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 379, 6 秒后重试 ...
【WARNING】2024-07-15 17:46:40,699 - common.py - A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 379, 3 秒后重试 ...
【INFO】2024-07-15 17:46:39,969 - command.py - 处理事件:notice.message - []
描述:仙逆 第14集 | 导演: 石头熊 主演: 史泽鲲 常文涛 林强 | [国语中字] *已切片头片尾,userid=None
标签:禁转 官方 国语 中字
促销:50%
做种数:25
发布时间:2023-12-11 12:01:06
种子:Renegade Immortal 2023 S01 E14 2160p WEB-DL H265 AAC-**已处理**
大小:886.61M
质量: WEB-DL 2160p
站点:**已处理**
【INFO】2024-07-15 17:46:39,966 - chain - 发送消息:channel=None,title=仙逆 (2023) S01 E14 开始下载, text=用户:**已处理**
【INFO】2024-07-15 17:46:34,272 - download.py - 开始下载 Renegade Immortal 2023 S01 E14 2160p WEB-DL H265 AAC-**已处理** ...
【INFO】2024-07-15 17:46:34,270 - download.py - 季 1 剩余需要集:[14, 16, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85]
【INFO】2024-07-15 17:46:34,269 - download.py - Renegade Immortal 2023 S01 E11 2160p WEB-DL H265 AAC-**已处理** 添加下载成功
【INFO】2024-07-15 17:46:34,268 - command.py - 处理事件:download.added - []```

类似的错误

jxxghp added a commit that referenced this pull request Jul 16, 2024
@BrettDean
Copy link
Contributor Author

@freefrank 是因为这里:*已切片头片尾只有一个*导致的,这个东西不好处理。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants