Fixed parsing of Telegram entities #2515
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
在
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
是的时候,就会因为
用户:brett_dean
中含有下划线_
而报错所以发消息前要先转义一下,转义后即可正常发送:
另外这种发送
文字+媒体
的形式,文字最多只能有1024个,多了就会报错,和下面的纯文字可以发4096个不一样。一般用也不到1024个字,吧