vogler / free-games-claimer

Automatically claims free games on the Epic Games Store, Amazon Prime Gaming and GOG.
GNU Affero General Public License v3.0
2.46k stars 149 forks source link

Notification specified in .env file not working #280

Closed KairuByte closed 9 months ago

KairuByte commented 9 months ago

Using the following line, as specified in the docs, does not actually yield a push to the discord server. I've verified that the unsanitized webhook does indeed work in other tools.

NOTIFY='discord://[webhook_id]/[webhook_token]'

vogler commented 9 months ago

Works fine for me. Docker or node? Does other configuration from your .env file get picked up? Did you check the apprise docs for discord? Run with DEBUG=1 to see the command used for apprise.

KairuByte commented 9 months ago

Running locally with node on Windows 11. Now that you mention it, some variables in the .env are honored, some are not. SHOW=0, DEBUG=1, and NOTIFY seem to be ignored, while BROWSER_DIR, PG_CLAIMDLC=1, and username/password/otp entries are all properly utilized.

And before it's asked, there's no particular order that I can tell. BROWSER_DIR is the first entry, DEBUG the second, followed by usernames and passwords, then SHOW.

I don't see anything in the appraise docs that would show any issues. I can attempt running the command with apprise directly tomorrow to ensure it works.

Edit: For the record, when running within docker NOTIFY does indeed work when the environment variable is set.

vogler commented 9 months ago

Maybe it's some syntax problem with (see dotenv) or the variables are already in your environment (values from .env have the lowest priority). You can post the contents and just replace the sensitive data.

vogler commented 9 months ago

You can also run node test/notify.js to test with some dummy notifications.

KairuByte commented 9 months ago

I was finally able to sit down and work through this.

First issue, is that dotenv doesn't take single quotes, it takes double quotes. And double quotes only appear to be necessary if there is a hash (#) symbol. This is obviously an issue on my part, but honestly may be a good idea to call out in the documentation for notifications.

Next issue is that node test/notify.js fails even when this is corrected. The relevant part of the error is the syntax being passed to apprise: apprise discord://[snip]/[snip] -i html -b epic-games:<br>- <a href="https://gaming.amazon.com/home">Epistory - Typing Chronicles</a> (claimed) This errors on execution. When you run it directly with apprise you get the following:

At line:1 char:136
+ ... [snip] -i html -b epic-games:<br>- <a href=" ...
+                                                                 ~
The '<' operator is reserved for future use.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RedirectionNotSupported

(For clarification, the error indicator is on the < in <a)

When you wrap the body (argument -b) in single quotes, it no longer errors: apprise discord://[snip]/[snip] -i html -b 'epic-games:<br>- <a href="https://gaming.amazon.com/home">Epistory - Typing Chronicles</a> (claimed)'

However the resulting notification does not actually include the anchor, it is simply displayed as plain text: image

Of note, I believe that last point has always been the case. I don't believe I have ever seen an anchor tag work on a discord notification with this project.