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

Webhook notifier. Error when " character is present in name. #528

Open
tomasz-kusy opened this issue Aug 6, 2024 · 4 comments
Open

Webhook notifier. Error when " character is present in name. #528

tomasz-kusy opened this issue Aug 6, 2024 · 4 comments

Comments

@tomasz-kusy
Copy link

Hello.
- 'WEBHOOK_BODY={"username": "TooGoodToGoBot", "content": "$${{display_name}}: $${{items_available}}, pickup: $${{pickupdate}}"}'

tgtg-scanner-1: 2024-08-06 16:57:30 DEBUG    Sending Console Notification
tgtg-scanner-1: 2024-08-06 16:57:30 Cukiernia "ABC" - Tórz - new amount: 0
tgtg-scanner-1: 2024-08-06 16:57:30 DEBUG    Sending WebHook Notification
tgtg-scanner-1: 2024-08-06 16:57:30 DEBUG    WebHook url: https://[redacted]
tgtg-scanner-1: 2024-08-06 16:57:30 ERROR    Failed sending WebHook: Expecting ',' delimiter: line 1 column 55 (char 54)
@Der-Henning
Copy link
Owner

Hi @tomasz-kusy.
Can you give me some more context?
I guess you are running the scanner as docker container and manage it using portainer?
In this case you probably need to escape {}.
Try:
- 'WEBHOOK_BODY={{"username": "TooGoodToGoBot", "content": "$${{display_name}}: $${{items_available}}, pickup: $${{pickupdate}}"}}'

@tomasz-kusy
Copy link
Author

Hi.
Yes. I'm using Docker. It works well with other strings (vendor names). Only when there is " character I have error.Probably there is lack of escaping " character:

body = json.dumps(json.loads(item.unmask(self.body).replace("\n", "\\n"))).encode("utf-8")

I don't know Python so I'm not sure :)

@tomasz-kusy
Copy link
Author

In this case you probably need to escape {}. Try: - 'WEBHOOK_BODY={{"username": "TooGoodToGoBot", "content": "$${{display_name}}: $${{items_available}}, pickup: $${{pickupdate}}"}}'

Nope. Now nothing works:
tgtg-scanner-1: 2024-08-06 21:03:52 ERROR Failed sending WebHook: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

@tomasz-kusy
Copy link
Author

@Der-Henning Is chance to fix it? :)

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

2 participants