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

Can't parse entities #351

Closed
Marcel-NL1963 opened this issue May 31, 2023 · 16 comments
Closed

Can't parse entities #351

Marcel-NL1963 opened this issue May 31, 2023 · 16 comments

Comments

@Marcel-NL1963
Copy link

Marcel-NL1963 commented May 31, 2023

After installing update 1.16.3 on my Synology NAS I got an error message: Telegram Error: Can't parse entities: can't find end of entity starting at byte offset 161.
Can you help me solve this?
2023-05-31_12-58-18

Thanks in advance.

@Der-Henning
Copy link
Owner

Hi @Marcel-NL1963.
From which version did you upgrade?
The error might be caused by an invalid message body. Could you please provide your config for the telegram notifier? Without the tokens of cause.

@Marcel-NL1963
Copy link
Author

I updated from 1.16.2 to 1.16.3. I did this by stopping the old version and installing the new by duplicating the settings.

2023-05-31_13-06-37

@Der-Henning
Copy link
Owner

Could you please provide the whole value for the TELEGRAM_BODY?
Did you receive this error for the first time? This error could be caused by markdown characters in the display_name of the scanned items. I will fix this problem.
Could you please provide the IDs of the items you are watching so I could test the solution?
You see the IDs when you run the scanner with DEBUG=true.

@Marcel-NL1963
Copy link
Author

#- TELEGRAM_BODY=${{display_name}} \nBeschikbaar: ${{items_available}}\nBedrag: ${{price}} ${{currency}}\nOphalen: ${{pickupdate}}
I found out that something was wrong because I wasn't receiving almost any notifications.

Sorry for my lack of knowledge, but I don't know where to put debug=true in Synology. So I've done this in the Windows version, it comes with a lot of information, but I cannot see any ID's.

@Der-Henning
Copy link
Owner

There is a message like

DEBUG    new State: {'392605': 3, ...

These are the item IDs with the currently available number of bags.

@Marcel-NL1963
Copy link
Author

afbeelding

@Marcel-NL1963
Copy link
Author

Marcel-NL1963 commented May 31, 2023

When I run the Windows version I got a message in Telegram for one store, but there a more available.

@Der-Henning
Copy link
Owner

On startup, the scanner sends a test notification so you can see if everything is set up correctly. You can disable this behavior with DisableTests = True.

@Marcel-NL1963
Copy link
Author

Have you found anything that causes this error message?

@Marcel-NL1963
Copy link
Author

Marcel-NL1963 commented May 31, 2023

I've just found out that when there's one magix box available, I get a notification. When there's two or more boxes available (after restarting) the error message appears and no notifications at all.

@Der-Henning
Copy link
Owner

I couldn't reproduce your observed behavior directly. But I could create some edge cases that could cause comparable issues.
The bug fix is included in the current edge docker images and will be part of the next release.
Now every markdown string should be parsed correctly by the telegram notifier.
Any feedback is appreciated.

@Der-Henning
Copy link
Owner

As you are using the docker image with your Synology you could use the derhenning/tgtg:edge image instead of the latest or 1.16.3 tag.

@pershoot
Copy link

pershoot commented Jun 1, 2023

@Der-Henning Hi. I built against latest in main with this ver., and receive this in the Telegram notify when using 'link' in body. Notifications do not work, when that is added, as an error is encountered.

[2023-06-01 10:55:53][tgtg][telegram.py:_send_message:134][ERROR] Telegram Error: Can't parse entities: character '.' is reserved and must be escaped with the preceding ''

Body item:
Link: https://share.toogoodtogo.com/item/${{item_id}}

I wanted to let you know.

Thank you.

@Der-Henning
Copy link
Owner

Der-Henning commented Jun 1, 2023

Hi @pershoot.
Yes, the latest code uses the Markdown_V2 parser of the Telegram API. This parser requires all markdown-related characters that should not be used as markdown commands to be escaped with a preceding \.
The characters are _, *, [, ], (, ), ~, `, >, #, +, -, =, |, {, }, ., !.

So your body should be: *Link*: https://share\.toogoodtogo\.com/item/${{item_id}}

To include the link in your message you could also use the variable *Link*: ${{link}}.

Thank you for pointing out this issue, as this is a breaking change. I will make a special note for this.

@Marcel-NL1963
Copy link
Author

Marcel-NL1963 commented Jun 1, 2023

As you are using the docker image with your Synology you could use the derhenning/tgtg:edge image instead of the latest or 1.16.3 tag.

I've just installed the edge image, there are no boxes in my fafourites right now, so I jiust wait for that. In the meantime no error messages ;)
Got my first two notifications, so everything is working again!
Thank you very much!!!

@pershoot
Copy link

pershoot commented Jun 1, 2023

Hi @pershoot. Yes, the latest code uses the Markdown_V2 parser of the Telegram API. This parser requires all markdown-related characters that should not be used as markdown commands to be escaped with a preceding \. The characters are _, *, [, ], (, ), ~, `, >, #, +, -, =, |, {, }, ., !.

So your body should be: *Link*: https://share\.toogoodtogo\.com/item/${{item_id}}

To include the link in your message you could also use the variable *Link*: ${{link}}.

Thank you for pointing out this issue, as this is a breaking change. I will make a special note for this.

Ahh, yup. Thank you.

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

No branches or pull requests

3 participants