auanasgheps / snapraid-aio-script

The definitive all-in-one SnapRAID script on Linux. Diff, sync, scrub are things of the past. Manage SnapRAID and much, much more!
GNU General Public License v3.0
231 stars 37 forks source link

discord bot notifications not sending completed/summary #55

Closed whur closed 6 months ago

whur commented 1 year ago

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?

auanasgheps commented 1 year ago

I just made a test and it's working perfectly fine.

image

whur commented 1 year ago

This is all I get, it's a fresh install and i'm unsure what I missed.

The sync and script is working fine btw.

Capture
whur commented 1 year ago

switched to email

auanasgheps commented 1 year ago

I'm sorry it's not working for you, but I really don't know what's wrong.

whur commented 1 year ago

That's alright, I'm trying to move off discord anyways for notifications.

tehniemer commented 1 year ago

Telegram bots are working great for me.

auanasgheps commented 1 year ago

And I'm about to increase the information sent to Telegram :)

firasdib commented 1 year ago

I'm having the same issue on discord, btw :)

auanasgheps commented 1 year ago

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"?

auanasgheps commented 1 year ago

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.

firasdib commented 11 months ago

@auanasgheps Any ETA on the release of this :)?

auanasgheps commented 11 months ago

@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 :)

firasdib commented 11 months ago

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!

auanasgheps commented 11 months ago

Yes that's what I mean. Please try and let me know if you get notifications.

firasdib commented 11 months ago

Alright, I will try the dev version.

firasdib commented 11 months ago

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.

auanasgheps commented 11 months ago

@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?

firasdib commented 11 months ago

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.

auanasgheps commented 11 months ago

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.

firasdib commented 11 months ago

I see the smart log on discord, as well as the total amount of files processed. The array info nor run time is posted. Vänliga hälsningar / Best regards,Firas DibOn 18 Sep 2023, at 17:09, Oliver Cervera @.***> wrote: 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.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

jack-mil commented 9 months ago

I am also having the issue of only the "Job started" message being sent to Discord. image 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 image 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.

Hilo4321 commented 9 months ago

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.

jack-mil commented 9 months ago

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

Hilo4321 commented 9 months ago

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/

jack-mil commented 9 months ago

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.

auanasgheps commented 8 months ago

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.

firasdib commented 8 months ago

@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

jack-mil commented 8 months ago

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

Hilo4321 commented 8 months ago

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

auanasgheps commented 8 months ago

Ok, will add it to the requirement list and also install it if not found.

auanasgheps commented 7 months ago

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.

auanasgheps commented 6 months ago

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.