discord bot notifications not sending completed/summary
whur opened this issue · 32 comments
I setup the discord bot for notifications and I get the "script started" notification but not any completed notifications or summaries. Am I missing something?
switched to email
I'm sorry it's not working for you, but I really don't know what's wrong.
That's alright, I'm trying to move off discord anyways for notifications.
Telegram bots are working great for me.
And I'm about to increase the information sent to Telegram :)
I'm having the same issue on discord, btw :)
Hi, just a quick comment on this: Discord is very picky when sending data, requires complex character escaping, instead Telegram just accepts the code as is. I'm facing a lot of issues with Discord when trying to do other things and I believe is the same issue of what you're seeing. I don't know how to fix so any contribution is welcome
lol nevermind, I found the way to properly format and send stuff to Discord. I will keep you posted.
Can you please confirm that you're seeing the issue only when the final message is a WARNING and not a simple "COMPLETED"?
Hey there, just pushed the changes! If you fancy, you can quickly try the dev branch, but do not use it in production yet.
Please note that I was never able to replicate this specific problem, so hopefully I fixed it by making the Discord notifications more robust.
@auanasgheps Any ETA on the release of this :)?
@auanasgheps Any ETA on the release of this :)?
Can you try the dev branch and confirm the fix? I never managed to reproduce it, but I changed the Discord logic.
I might push the release soon, since I've done everything I wanted :)
I'm not sure how to test it besides running it live on my server. If it's ready for that, I'd be happy to try it!
Yes that's what I mean. Please try and let me know if you get notifications.
Alright, I will try the dev version.
Alright, just ran it. It sent the smart log to the discord channel, but not the snap status, instead I see this error in the log:
curl: (22) The requested URL returned error: 400
It's nice it gives a summary, but it should also include the duration.
Overall, nice improvement. I think using embeds in discord would look even better, with data more easily human readable and stylish. If not embeds, maybe just basic markdown to format things, add emojis, put things in bold where it makes sense, etc.
@firasdib thanks for the feedback! Can you please tell exactly when do you get the error? Only for the Snap Status? Do you get all the others?
I think using embeds in discord would look even better
I have enabled code formatting for Snap Status and SMART and if it's what you mean. Would you like to have it for all messages?
Error is after the script sync is complete, and it tries to post things to discord.
I mean, instead of just dumping large text blocks, embeds can look a lot nicer.
Yeah, but what is actually posted to Discord?
Ok, I understand what you mean with embeds. It's tough for me, short term I won't be able to make it.
I am also having the issue of only the "Job started" message being sent to Discord.
From what I can tell looking at the script, the notify_success()
that sends the details to Discord is only called from the prepare_mail()
function.
prepare_mail()
is only called if a email address is set. I don't intend to use email, so I configured the email address as described in the config script
So a full discord summary and warning are only sent if a email is also configured.
As discord notifications are much more convienent than email, I would really love to get this working. I will probably make some changes to the local script for my own use.
Just to have another data point, I came searching for this issue, and concur with @jack-mil. Same symptoms. When I populated the email address, I got the follow up message "[COMPLETED] DIFF + SYNC + SCRUB Jobs (SnapRAID on trainer)" upon completion.
Forgot to update here. I switched to the dev branch where a lot of features and reorganization has happened. The notification system works correctly with those changes
I just tried it myself, and only get the script started message with 3.3-dev.
EDIT:
With the dev script, I get the 400 error at the very end.
I can't figure out how to format this inline so:
https://paste.debian.net/1300667/
I just tried it myself, and only get the script started message with 3.3-dev.
EDIT: With the dev script, I get the 400 error at the very end.
I can't figure out how to format this inline so: https://paste.debian.net/1300667/
/usr/sbin/snapraid-aio-script-3.3-dev/snapraid-aio-script.sh: line 816: jq: command not found
There is a new dependency, jq
to format the json data properly.
I began looking into using jq
more comprehensivly to format embeds and make better use of the Discord webhook system. But then I found this https://github.com/firasdib/snapper and decided to switch since I am more familiar with Python and can more easily modify and contribute to that project.
The features I can tell are missing is the ability to schedule scrubs at less frequency (every N runs) and the ability to pause/stop docker containers.
Hi, apologies for the delayed response.
@jack-mil thanks for reporting the dev branch works for you. I'm sorry you abandoned this script because of the language, but be assured this project is alive :)
I made my best to make the Discord logic stronger. It has some weird stuff going around, it's more complex than Telegram.
I am not aware of jq
dependency. My testing is done on OMV 6 (which is Debian 11) and I did not need to install any jq package. Also, jq is never mentioned in my script so I guess it's a dependency from something else. I guess you need to update your packages?
Since I got confirmation that the fix is working fine, I'll be soon closing this issue.
@auanasgheps You could have a look at my snapraid script which has complex discord integration here: https://github.com/firasdib/snapper/blob/main/snapper.py#L111
I am not aware of
jq
dependency. My testing is done on OMV 6 (which is Debian 11) and I did not need to install any jq package. Also, jq is never mentioned in my script so I guess it's a dependency from something else. I guess you need to update your packages?
The [jq
](https://jqlang.github.io/jq/) tool is definitely used every time the discord webhook is sent on the dev branch. See: L816. This filter chain seems to be done to sanitize and escape the input strings into json format
I was able to get 3.3dev to run by installing jq. It would not run without it. I was also able to get appropriate notifications in discord with it.
See this line from my paste above:
/usr/sbin/snapraid-aio-script-3.3-dev/snapraid-aio-script.sh: line 816: jq: command not found
Ok, will add it to the requirement list and also install it if not found.
Hi all,
I implemented a little fix suggested in #78 that should fix the Discord notification!
If you want to test it, it's in the dev branch.
Hi there, I'm closing this out as I think we've finally found the root cause and fixed it.
I am planning for a release soon.