[PP-Script / Queue-Script] Notifications (All In One)

Share your scripts or request scripts with specific features.
Forum rules
Please keep the forum clean - one topic per script. Questions not related to a specific script should be posted in Support forum.
l2g
Posts: 185
Joined: 27 Jun 2014, 22:13
Contact:

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by l2g » 06 Jul 2017, 02:16

Applied several accumulating bugs into one release in addition to another new notification service called MatterMost.

Release v0.6.0 (Direct Download Link) is now in place.

The release details (and new documentation) can be found at the head of this thread (quick link).

Happy notifying! :)

l2g
Posts: 185
Joined: 27 Jun 2014, 22:13
Contact:

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by l2g » 10 Jul 2017, 02:08

Final bump for this script (sorry for the double post).
This is just a minor release that applies some small updates:
  • Small bug fix for MatterMost Notifications users.
  • Inline Configuration Check (users can test their settings now right from the NZB-Get configuration page)!
Release v0.6.1 (Direct Download Link) is now in place.

The release details (and new documentation) can be found at the head of this thread (quick link).

Happy notifying! :)

devicenull
Posts: 5
Joined: 04 Feb 2016, 18:37

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by devicenull » 10 Aug 2017, 17:22

I just found this script when I was looking to see if I could send notifications to slack. Nice work. I have run into one problem though, running NZBGet 19.1 on a Qnap w/ Notify 0.6.1 installed, I am still getting the certificate errors mentioned above. I do not have https connections enabled for NZBGet though it appears to be an issue processing Slack's cert for the https connection.

If I run Notify from the command line to my slack instance, it works fine but when a file or the test operation is run, it fails (even though the dialog says that the test passed). Here are the logs from NZBget:

Code: Select all

Thu Aug 10 13:05:12 2017        INFO    Executing script Notify.py with command TestServers
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) SERVERS="slack://RedactedTokenA/RedactedTokenB/RedactedTokenC/#notifications"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(default) TITLE=None
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(default) BODY=None
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) INCLUDEIMAGE="yes"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) SERVERS="slack://RedactedTokenA/RedactedTokenB/RedactedTokenC/#notifications"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) ONFAILURE="yes"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) ONSUCCESS="yes"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) INCLUDESTATS="yes"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) INCLUDEFILES="yes"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) INCLUDELOGS="OnFailure"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) INCLUDEIMAGE="yes"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] Server parsed to: {'host': 'RedactedTokenA', 'user': None, 'query': '%23notifications', 'url': 'slack://RedactedTokenA/RedactedTokenB/RedactedTokenC/%23notifications', 'path': '/RedactedTokenB/RedactedTokenC/', 'fullpath': '/RedactedTokenB/RedactedTokenC/%23notifications', 'password': None, 'port': None, 'qsd': {}, 'schema': 'slack'}
Thu Aug 10 13:05:13 2017        WARNING Notify: No user was specified; using NZB-Notify.
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] Slack POST URL: https://hooks.slack.com/services/RedactedTokenA/RedactedTokenB/RedactedTokenC (cert_verify=True)
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] Slack Payload: {'username': 'NZB-Notify', 'mrkdwn': True, 'channel': '#notifications', 'attachments': [{'footer': 'NZB-Notify', 'color': '#3AA3E3', 'text': '## NZBGet-Notify Configuration Test ##\r\n- **OnFailure**: Yes\r\n- **OnSuccess**: Yes\r\n- **Include Statistics**: Yes\r\n- **Include File Listings**: Yes\r\n- **Include Log Details**: Yes\r\n', 'title': 'NZBGet-Notify Configuration Test', 'ts': 1502384713.785524, 'footer_icon': 'http://yes'}]}
Thu Aug 10 13:05:14 2017        WARNING Notify: A Connection error occured sending Slack:notifications notification.
Thu Aug 10 13:05:14 2017        INFO    Notify: [DEBUG] Socket Exception: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)
Thu Aug 10 13:05:14 2017        INFO    Notify: [DEBUG] Exiting with return code: 93
Thu Aug 10 13:05:14 2017        INFO    Script Notify.py with command TestServers successful
From the command line:

Code: Select all

[/share/CACHEDEV1_DATA/.qpkg/NZBGet/nzbget/scripts] # python Notify.py -s slack://Redacted TokenA/RedactedTokenB/RedactedTokenC/#notifications -t "Test" -b "Test Msg" -D
[INFO] [DEBUG] Script mode forced off.
2017-08-10 13:18:37,959 - 21480 - DEBUG - get(default) SERVERS=None
2017-08-10 13:18:37,959 - 21480 - DEBUG - set(config) SERVERS="slack://Redacted TokenA/RedactedTokenB/RedactedTokenC/#notifications"
2017-08-10 13:18:37,959 - 21480 - DEBUG - set(environment) SERVERS="slack://Redacted TokenA/RedactedTokenB/RedactedTokenC/#notifications"
2017-08-10 13:18:37,959 - 21480 - DEBUG - get(default) TITLE=None
2017-08-10 13:18:37,959 - 21480 - DEBUG - set(config) TITLE="Test"
2017-08-10 13:18:37,960 - 21480 - DEBUG - set(environment) TITLE="Test"
2017-08-10 13:18:37,960 - 21480 - DEBUG - get(default) BODY=None
2017-08-10 13:18:37,960 - 21480 - DEBUG - set(config) BODY="Test Msg"
2017-08-10 13:18:37,960 - 21480 - DEBUG - set(environment) BODY="Test Msg"
2017-08-10 13:18:37,960 - 21480 - DEBUG - get(default) INCLUDEIMAGE=None
2017-08-10 13:18:37,960 - 21480 - DEBUG - get(config) SERVERS="slack://Redacted TokenA/RedactedTokenB/RedactedTokenC/#notifications"
2017-08-10 13:18:37,961 - 21480 - DEBUG - get(config) SERVERS="slack://Redacted TokenA/RedactedTokenB/RedactedTokenC/#notifications"
2017-08-10 13:18:37,961 - 21480 - DEBUG - get(config) TITLE="Test"
2017-08-10 13:18:37,961 - 21480 - DEBUG - get(config) BODY="Test Msg"
2017-08-10 13:18:37,961 - 21480 - DEBUG - get(default) INCLUDEIMAGE=None
2017-08-10 13:18:37,961 - 21480 - DEBUG - get(default) INCLUDEIMAGE=None
2017-08-10 13:18:37,961 - 21480 - DEBUG - get(config) SERVERS="slack://Redacted TokenA/RedactedTokenB/RedactedTokenC/#notifications"
2017-08-10 13:18:37,964 - 21480 - DEBUG - Server parsed to: {'host': 'Redacted TokenA', 'user': None, 'query': '%23notifications', 'url': 'slack://Redacted TokenA/RedactedTokenB/RedactedTokenC/%23notifications', 'path': '/RedactedTokenB/RedactedTokenC/', 'fullpath': '/RedactedTokenB/RedactedTokenC/%23notifications', 'password': None, 'port': None, 'qsd': {}, 'schema': 'slack'}
2017-08-10 13:18:37,964 - 21480 - WARNING - No user was specified; using NZB-Notify.
2017-08-10 13:18:38,184 - 21480 - DEBUG - Slack POST URL: https://hooks.slack.com/services/Redacted TokenA/RedactedTokenB/RedactedTokenC (cert_verify=True)
2017-08-10 13:18:38,185 - 21480 - DEBUG - Slack Payload: {'username': 'NZB-Notify', 'mrkdwn': True, 'channel': '#notifications', 'attachments': [{'color': '#3AA3E3', 'text': 'Test Msg', 'footer': 'NZB-Notify', 'ts': 1502385518.184911, 'title': 'Test'}]}
2017-08-10 13:18:38,529 - 21480 - DEBUG - Exiting with return code: 93

l2g
Posts: 185
Joined: 27 Jun 2014, 22:13
Contact:

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by l2g » 11 Aug 2017, 00:24

Try adding ?verify=False to your url...

So: slack://RedactedTokenA/RedactedTokenB/RedactedTokenC/?verify=False.

Let me know how it goes.

Consider that this error you're getting is happening for a reason though... your Qnap server is unable to verify the authenticity of Slacks website which could be caused by a number of reasons, but here are the most likely:
  • Your certificate authority (CA) file may be out of whack causing your Qnap server to fail in properly validating the authenticity of Slacks website.
  • Your Qnap has been compromised in some way and your being subjected to a man-in-the-middle attack when using this device.
Either way... ?verify=False should fix the issue for you. I trust you know your own environment and trust all authors of any apps/plugins you installed onto your Qnap device. So it should be safe to assume the first option; that just your CA file is just messed or out dated. I will admit though... your situation certainly does seem peculiar though... Good luck!

devicenull
Posts: 5
Joined: 04 Feb 2016, 18:37

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by devicenull » 11 Aug 2017, 00:47

Hmm...... That does work. I did have an issue recently where this box was hit with some malware that was hitting a lot of Qnap boxes. I did go through Qnap's removal process and hadn't seen any other quirks with cert verification. I wonder if there is a way to clear and re-install all the certificates on a Qnap..? Off to Google.

Thanks!

devicenull
Posts: 5
Joined: 04 Feb 2016, 18:37

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by devicenull » 11 Aug 2017, 19:25

Just to circle back.... I'd been on Qnap's QTS 4.2.x firmware for a while since updating to 4.3.x was a 32->64 bit change and required updating a lot of installed services I was worried they wouldn't update cleanly. I bit the bullet and did that update today and found that I no longer need the "verify" parameter for the URL. Not sure if the firmware fixed an underlying cert store issue or if it was just a side effect of newer (and 64-bit) libraries and python...? Either way, thanks for the workaround and now I don't need it.

I also found that QSonarr and QRadarr (both Mono apps) worked fine to Slack with their built-in connections but did have issues with the certs in the logs if you cranked debug up to trace. When I did the firmware upgrade, I had to go from QMono 4.2.x (32-bit) to QMono 4.6.x (64-bit) which was auto updated and they still did the same even though NZBget and Notify.py were fine. I manually reved QMono up to 4.8.x (64-bit) and they started working.

I definitely think there was some issue with the underlying libraries and/or the interfaces to them that were solved by going to fully 64-bit OS and newer frameworks (be that the latest Python 3.x/2.x that got installed or QMono).

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest