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

[BUG] Unexpected backslashes in forwarded messages #109

Open
SharzyL opened this issue Mar 21, 2021 · 3 comments
Open

[BUG] Unexpected backslashes in forwarded messages #109

SharzyL opened this issue Mar 21, 2021 · 3 comments

Comments

@SharzyL
Copy link
Member

SharzyL commented Mar 21, 2021

Describe the bug
When EFB forward a message from ETM to EWS, under some circumstances there will be unexpected backslashes in messages in WeChat.

To Reproduce
Steps to reproduce the behavior:

  1. Set up EFB to sync messages between Telegram and WeChat
  2. Send a message in Telegram with the following content:
URL
---------------

where URL is a URL with address tg://user?id=629325599

Now the message is forwarded to WeChat, but its content is strange:

[URL](tg://user?id=629325599) 
\- \- \- \- \- \- \- \- \- \- \- \- \- \- \-

Expected behavior
The message forwarded to WeChat should be something like:

[URL](tg://user?id=629325599) 
---------------

or

URL
---------------

Version information (please complete the following information):

  • OS: Ubuntu 20.04.1 LTS x86_64
  • Detailed Python, EFB and module versions:
EH Forwarder Bot
Version: 2.1.0
Python version:
3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0]
Running on profile "wechat2tg".

Master channel:
    Telegram Master (blueset.telegram) 2.2.3 # Default instance

Slave channel:
    WeChat Slave (blueset.wechat) 2.0.4 # Default instance

Middleware:
    Search Message Middleware (catbaron.search_msg) 0.1.0 # Default instance

Additional context
If we downgrade efb-telegram-master from 2.2.3 to 2.2.2, everything goes OK.

@SharzyL SharzyL added the bug label Mar 21, 2021
@blueset
Copy link
Member

blueset commented Mar 21, 2021

Thanks for the report.

This was a known issue in a ETM dependency python-telegram-bot, and has been fixed in version 13.2.

Please try to upgrade your python-telegram-bot locally and see if it fixes the issue. The latest version is version.

@SharzyL
Copy link
Member Author

SharzyL commented Mar 21, 2021

I have upgraded python-telegram-bot to 13.4.1. The versions of other dependencies keep unchanged. But the backslashes still exists.

By the way, it is noteworthy that downgrading efb-telegram-master from 2.2.3 to 2.2.2 fixes the problem.

@blueset
Copy link
Member

blueset commented Mar 21, 2021

Thanks again for the report. I can reproduce this behavior in my dev environment.

After inspection, I can confirm that this is an intended behavior by Telegram Bot specs. Telegram MarkdownV2 requires all of the following characters to be escaped when not used as a part of its semantics:

_*[]()~`>#+-=|{}.!

In ETM, we are avoiding such escape to happen when there is no any sort of formatting going on in the message. However, if any Markdown formatting is found, we kept all the escapes per Telegram’s syntax. This is resulting - to be escaped as \-.

By far this is the intended behavior. If you have any idea on improving this, feel free to leave a comment here. Thanks!

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

No branches or pull requests

2 participants