tgtg icon indicating copy to clipboard operation
tgtg copied to clipboard

Unable to include the TELEGRAM_BODY to receive direct link

Open Schollino opened this issue 1 year ago • 16 comments

Hi there,

first of all: I am not an IT expert but I love to deal with those things in my leisure time. So, I got this awesome software to work on my Synology-NAS with docker. I think there should be the possibility to include a link concerning the appropriate magic bag directly in the telegram notification, so that you can just click on this link and can buy the magic back more quickly and comfortable. This solution should work with the TELEGRAM_BODY I guess?

In the configuration is discribed, that the body has to look like this and you should also be able to include the "link" there? *${{display_name}}* \n*Available*: ${{items_available}}\n*Price*: ${{price}} ${{currency}}\n*Pickup*: ${{pickupdate}} Unfortunately, when I add this originale code to my TELEGRAM_BODY, Portainer gives me the following error, with which I am not able to do anything. "There is an error in the yaml syntax: YAMLSemanticError: Nested mappings are not allowed in compact mappings"

So, I started to just add one content there like this: *${{display_name}}* which leads to another failure: "failed to deploy a stack: invalid interpolation format for services.scanner.environment.[]. You may need to escape any $ with another $. TELEGRAM_BODY=*${{display_name}}*"

*${{display_name}}$* leads to the same error. *{{display_name}}* leads to "Telegram Error: Can't parse entities: character '{' is reserved and must be escaped with the preceding ''. For details see https://github.com/Der-Henning/tgtg/wiki/Configuration#note-on-markdown-v2"

*\{\{display_name\}\}* leads to "2024-01-28 10:41:34 ERROR Telegram Error: Can't parse entities: can't find end of bold entity at byte offset 21. For details see https://github.com/Der-Henning/tgtg/wiki/Configuration#note-on-markdown-v2"

So, does anyone has an idea to help me including the direct product link into my TELEGRAM_BODY? Thank you!!

Schollino avatar Jan 28 '24 09:01 Schollino

${{display_name}}\nLink: ${{link}}

For the above example (Note: code omitted the asterisks (for bold)): asterisk dollar sign two curly braces in display_name 2 curly braces out asterisk backslash n asterisk Link asterisk colon space dollar sign 2 curly braces in link 2 curly braces out

...

Please also see this: https://github.com/Der-Henning/tgtg/issues/351

Edit: Please see this, regarding Portainer (add surrounding single quotes): https://github.com/Der-Henning/tgtg/issues/154#issuecomment-1245689147

pershoot avatar Jan 28 '24 10:01 pershoot

Hi, thank you for your fast reply. I just changed the input accordingly to your suggestion:

image

I get the following failure-message: image

Also the closing with another $ shows the same message.

Schollino avatar Jan 28 '24 10:01 Schollino

Please see this, regarding Portainer: https://github.com/Der-Henning/tgtg/issues/154#issuecomment-1245689147

pershoot avatar Jan 28 '24 11:01 pershoot

Hi @Schollino. In Portainer you need to add quotes.

- 'TELEGRAM_BODY=*${{display_name}}*'

Der-Henning avatar Jan 28 '24 11:01 Der-Henning

I think this will not work ... I am using the "Stack"-Feature in Portainer with the "editor", which obviously uses docker compose to create the container. The rest in the editor looks like this: image

If I add the quotes, Portainer complains about this which results in a failure.

Schollino avatar Jan 28 '24 11:01 Schollino

Try this: - "\'TELEGRAM_BODY=*${{display_name}}*\n*Link*: ${{link}}\'"

pershoot avatar Jan 28 '24 11:01 pershoot

I use portainer on docker swarm. My telegram config (working):

      - 'TELEGRAM_BODY={{`*$${{display_name}}*\n*Anzahl*: $${{items_available}}\n*Wann*: $${{pickupdate}}\n*Wo*: $${{pickup_location}}\n*Preis*: $${{price}} $${{currency}}`}}'

Der-Henning avatar Jan 28 '24 12:01 Der-Henning

This entry is marked red in the portainer editor ... image

... and leads to this error:

2024-01-28 14:45:54 ERROR Telegram Error: Can't parse entities: character '{' is reserved and must be escaped with the preceding ''. For details see https://github.com/Der-Henning/tgtg/wiki/Configuration#note-on-markdown-v2

Schollino avatar Jan 28 '24 13:01 Schollino

Any suggestions? :-(

Schollino avatar Jan 29 '24 18:01 Schollino

Any suggestions? :-(

Are you on the latest Portainer update?

pershoot avatar Jan 29 '24 20:01 pershoot

In my setup I use the compose version: "3.6".

Der-Henning avatar Jan 31 '24 16:01 Der-Henning

My version is 2.18.2. After an update, my version is 2.19.4. In my Stack-Editor of the tgtg-container, my version is version: '3.3'

I do not understand, why every suggestion begins with an ' before TELEGRAM_BODY? I did not find any config for a docker container, where it is written like this - 'TELEGRAM_BODY ... By the way: also not in the example-config under https://hub.docker.com/r/derhenning/tgtg . Could you maybe once share your config for docker/portainer or describe the way, you integrate this?

Schollino avatar Jan 31 '24 17:01 Schollino

The surrounding ' ' is a portainer thing. I don't know how I figured it out when I had the same problem, but the data you put in the portainer UI is not exactly the same as if you create a compose.yml as you could also include environment variables in compose files. The environment variables defined as list - key=value are send as strings including key=value to the container. The ' ' should send the string as is to the compose backend.

Another way is to define them as key-value pairs with key: value. But you cannot mix both notations.

Der-Henning avatar Jan 31 '24 17:01 Der-Henning

I had the same issue with portainer, this is what worked for me: - 'TELEGRAM_BODY=*$${{display_name}}*\n*Pickup*: $${{pickupdate}}\n*Order*: $${{link}}' Kind of strange format tbh though.

If somebody could confirm this working, i think it would be nice to add this to the docs.

Butanding avatar Feb 13 '24 08:02 Butanding

Hi,

wow, I don't understand why, but it works!!! We should really add this in the docs.

Thank you very much :-)

Schollino avatar Feb 14 '24 18:02 Schollino

This information was present in the docker-compose.yml until https://github.com/Der-Henning/tgtg/commit/e6b4c07da0b48b7ae1c4eeee0f0bab57825cfb5a. Somehow in the transfer of the configration information from the docker-compose file to the wiki a lot of important information got lost. Can we maybe ether add this file back as an e.g., docker-compose.example.yml or add the missing information from there to the wiki (which configurations need special handling in docker compose files (including the 'TELEGRAM_BODY={{...}}' thing), where to get a google maps API key from, ...)? @Der-Henning

floriegl avatar May 07 '24 21:05 floriegl