[GH-ISSUE #51] Webhook Enhancement Request #39

Closed
opened 2026-02-27 20:05:06 +03:00 by kerem · 14 comments
Owner

Originally created by @tomballgithub on GitHub (Jan 22, 2026).
Original GitHub issue: https://github.com/misiektoja/instagram_monitor/issues/51

I'd work on a PR, but I don't even know how to approach this.

Is there a way to make the WEBHOOK support more configurable? Right now, it's very focused on discord.

For instance, here are two method of using NTFY via webhooks (examples from the official documentation):

  1. Would need a method to configure the URL and use GET
    requests.get("https://ntfy.sh/mywebhook/publish?message=Webhook+triggered&priority=high&tags=warning,skull")

  2. Would need a method to configure the payload and use POST

requests.post("https://ntfy.sh/",  data=json.dumps({
        "topic": "mytopic",
        "message": "Disk space is low at 5.1 GB",
        "title": "Low disk space alert",
        "tags": ["warning","cd"],
        "priority": 4,
        "attach": "https://filesrv.lan/space.jpg",
        "filename": "diskspace.jpg",
        "click": "https://homecamera.lan/xasds1h2xsSsa/",
        "actions": [{ "action": "view", "label": "Admin panel", "url": "https://filesrv.lan/admin" }]
    })
)

I use custom code to do NTFY alerts, but I'd prefer to use your official mechanism, especially if you end up taking this and putting it into your other utilities next (any tool that sends email alerts).

Originally created by @tomballgithub on GitHub (Jan 22, 2026). Original GitHub issue: https://github.com/misiektoja/instagram_monitor/issues/51 I'd work on a PR, but I don't even know how to approach this. Is there a way to make the WEBHOOK support more configurable? Right now, it's very focused on discord. For instance, here are two method of using NTFY via webhooks (examples from the official documentation): 1. Would need a method to configure the URL and use GET `requests.get("https://ntfy.sh/mywebhook/publish?message=Webhook+triggered&priority=high&tags=warning,skull")` 2. Would need a method to configure the payload and use POST ``` requests.post("https://ntfy.sh/", data=json.dumps({ "topic": "mytopic", "message": "Disk space is low at 5.1 GB", "title": "Low disk space alert", "tags": ["warning","cd"], "priority": 4, "attach": "https://filesrv.lan/space.jpg", "filename": "diskspace.jpg", "click": "https://homecamera.lan/xasds1h2xsSsa/", "actions": [{ "action": "view", "label": "Admin panel", "url": "https://filesrv.lan/admin" }] }) ) ``` I use custom code to do NTFY alerts, but I'd prefer to use your official mechanism, especially if you end up taking this and putting it into your other utilities next (any tool that sends email alerts).
kerem 2026-02-27 20:05:06 +03:00
Author
Owner

@misiektoja commented on GitHub (Jan 22, 2026):

Yes, right now we are tied to Discord's specific implementation. To support other services properly, we would need a generic webhook mode where the user can define the template of the payload and switch between GET and POST.

<!-- gh-comment-id:3784148731 --> @misiektoja commented on GitHub (Jan 22, 2026): Yes, right now we are tied to Discord's specific implementation. To support other services properly, we would need a generic webhook mode where the user can define the template of the payload and switch between GET and POST.
Author
Owner

@tomballgithub commented on GitHub (Jan 24, 2026):

Developed a PR that works with --send-test-webhook
Need to test it in normal operation

<!-- gh-comment-id:3793924227 --> @tomballgithub commented on GitHub (Jan 24, 2026): Developed a PR that works with --send-test-webhook Need to test it in normal operation
Author
Owner

@misiektoja commented on GitHub (Jan 25, 2026):

Cool, looking forward to it!

<!-- gh-comment-id:3796699323 --> @misiektoja commented on GitHub (Jan 25, 2026): Cool, looking forward to it!
Author
Owner

@tomballgithub commented on GitHub (Jan 25, 2026):

Submitted #56

<!-- gh-comment-id:3797218306 --> @tomballgithub commented on GitHub (Jan 25, 2026): Submitted #56
Author
Owner

@tomballgithub commented on GitHub (Jan 26, 2026):

The new feature is working well for me with NTFY both for updates and errors (account was flagged overnight)

Note for release is that it's a breaking change from the last release for anyone using the webhook feature. They need to update their configuration file with the default Discord information.

@Sha-Dox Can you test this out since you implemented the Discord webhook feature? It's in the Dev branch.

<!-- gh-comment-id:3801073203 --> @tomballgithub commented on GitHub (Jan 26, 2026): The new feature is working well for me with NTFY both for updates and errors (account was flagged overnight) Note for release is that it's a breaking change from the last release for anyone using the webhook feature. They need to update their configuration file with the default Discord information. @Sha-Dox Can you test this out since you implemented the Discord webhook feature? It's in the Dev branch.
Author
Owner

@tomballgithub commented on GitHub (Jan 26, 2026):

I've seen this twice now. I'm not sure if it's something with the code under certain situations or if it's something else.
I am restarting to see if it reproduces under same situation/changes.

* Error sending webhook: HTTPSConnectionPool(host='ntfy.sh', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1081)')))

<!-- gh-comment-id:3801154566 --> @tomballgithub commented on GitHub (Jan 26, 2026): I've seen this twice now. I'm not sure if it's something with the code under certain situations or if it's something else. I am restarting to see if it reproduces under same situation/changes. `* Error sending webhook: HTTPSConnectionPool(host='ntfy.sh', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLEOFError(8, '[SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1081)'))) `
Author
Owner

@Sha-Dox commented on GitHub (Jan 26, 2026):

@tomballgithub hi, I sadly cannot test it out as discord is sadly banned in my country but I'll se what I can do

<!-- gh-comment-id:3801167511 --> @Sha-Dox commented on GitHub (Jan 26, 2026): @tomballgithub hi, I sadly cannot test it out as discord is sadly banned in my country but I'll se what I can do
Author
Owner

@tomballgithub commented on GitHub (Jan 26, 2026):

OK, for the PR, I created a server and channel and tested it, but I don't know all of the nuances to this.
And if I run NTFY, I cannot also run DISCORD as a compare.

<!-- gh-comment-id:3801193061 --> @tomballgithub commented on GitHub (Jan 26, 2026): OK, for the PR, I created a server and channel and tested it, but I don't know all of the nuances to this. And if I run NTFY, I cannot also run DISCORD as a compare.
Author
Owner

@tomballgithub commented on GitHub (Jan 26, 2026):

On the SSL Error above, I reran and got the same email content as last time (order of the added followings was different), but the webhook didn't get the SSL error above. That indicates to me that it's not something in the payload or request that is causing this (weird character in header or body, etc)

At a minimum, feels like we need our own wait/retry loop because that retry warning seems to be coming from requests.

<!-- gh-comment-id:3801374111 --> @tomballgithub commented on GitHub (Jan 26, 2026): On the SSL Error above, I reran and got the same email content as last time (order of the added followings was different), but the webhook didn't get the SSL error above. That indicates to me that it's not something in the payload or request that is causing this (weird character in header or body, etc) At a minimum, feels like we need our own wait/retry loop because that retry warning seems to be coming from requests.
Author
Owner

@misiektoja commented on GitHub (Jan 26, 2026):

These are some strange transient connection issues. I implemented a simple retry mechanism that attempts connection up to three times and added a user agent (not sure if it will help, but it shouldn't cause any harm). Let me know if it made it any better.

<!-- gh-comment-id:3802297018 --> @misiektoja commented on GitHub (Jan 26, 2026): These are some strange transient connection issues. I implemented a simple retry mechanism that attempts connection up to three times and added a user agent (not sure if it will help, but it shouldn't cause any harm). Let me know if it made it any better.
Author
Owner

@tomballgithub commented on GitHub (Jan 27, 2026):

Great. I see it. I will likely hack the code to brute force the payload that failed and just repeat the webhook sending on a loop and see what happens

<!-- gh-comment-id:3802491868 --> @tomballgithub commented on GitHub (Jan 27, 2026): Great. I see it. I will likely hack the code to brute force the payload that failed and just repeat the webhook sending on a loop and see what happens
Author
Owner

@tomballgithub commented on GitHub (Jan 27, 2026):

I updated send_webhook and then uses the test webhook command line argument to run 100 cycles, which I did > out.txt to capture the output

There were no errors but then I noticed that at some point I started to see tests that didn't make it past the "final_headers" line, indicating that the code didn't make it past the 'request' execution. But there were also no exception messages (and I verified that each one prints a message) or errors on the screen

I am rerunning without the try/catch and not redirecting to a file.

Webhook test #995
final_payload: {'topic': 'YYY', 'title': 'User XXX followings changed from 4418 to 4420', 'message': 'Old Count: 4418\nNew Count: 4420\nChange: +2\n\nAdded followings::\n- markjcarney (www.instagram.com/markjcarney)\n- ladydiana.forever (www.instagram.com/ladydiana.forever)\n- senatorandykim (www.instagram.com/senatorandykim)\n- investinggoal (www.instagram.com/investinggoal)\n\nRemoved followings::\n- ilovediana.forever (www.instagram.com/ilovediana.forever)', 'tags': ['mailbox'], 'priority': 3}
final_headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer ZZZ'}
response.headers: {'Server': 'nginx', 'Date': 'Tue, 27 Jan 2026 06:53:02 GMT', 'Content-Type': 'application/json', 'Content-Length': '578', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*'}
response: <Response [200]>
* Webhook notification sent successfully
sleeping for 10 seconds

Webhook test #996
final_payload: {'topic': 'YYY', 'title': 'User XXX followings changed from 4418 to 4420', 'message': 'Old Count: 4418\nNew Count: 4420\nChange: +2\n\nAdded followings::\n- markjcarney (www.instagram.com/markjcarney)\n- ladydiana.forever (www.instagram.com/ladydiana.forever)\n- senatorandykim (www.instagram.com/senatorandykim)\n- investinggoal (www.instagram.com/investinggoal)\n\nRemoved followings::\n- ilovediana.forever (www.instagram.com/ilovediana.forever)', 'tags': ['mailbox'], 'priority': 3}
final_headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer ZZZ'}

Webhook test #997
final_payload: {'topic': 'YYY', 'title': 'User XXX followings changed from 4418 to 4420', 'message': 'Old Count: 4418\nNew Count: 4420\nChange: +2\n\nAdded followings::\n- markjcarney (www.instagram.com/markjcarney)\n- ladydiana.forever (www.instagram.com/ladydiana.forever)\n- senatorandykim (www.instagram.com/senatorandykim)\n- investinggoal (www.instagram.com/investinggoal)\n\nRemoved followings::\n- ilovediana.forever (www.instagram.com/ilovediana.forever)', 'tags': ['mailbox'], 'priority': 3}
final_headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer ZZZ'}

Webhook test #998
final_payload: {'topic': 'YYY', 'title': 'User XXX followings changed from 4418 to 4420', 'message': 'Old Count: 4418\nNew Count: 4420\nChange: +2\n\nAdded followings::\n- markjcarney (www.instagram.com/markjcarney)\n- ladydiana.forever (www.instagram.com/ladydiana.forever)\n- senatorandykim (www.instagram.com/senatorandykim)\n- investinggoal (www.instagram.com/investinggoal)\n\nRemoved followings::\n- ilovediana.forever (www.instagram.com/ilovediana.forever)', 'tags': ['mailbox'], 'priority': 3}
final_headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer ZZZ'}
response.headers: {'Server': 'nginx', 'Date': 'Tue, 27 Jan 2026 06:53:14 GMT', 'Content-Type': 'application/json', 'Content-Length': '578', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*'}
response: <Response [200]>
* Webhook notification sent successfully
sleeping for 10 seconds

Webhook test #999
final_payload: {'topic': 'YYY', 'title': 'User XXX followings changed from 4418 to 4420', 'message': 'Old Count: 4418\nNew Count: 4420\nChange: +2\n\nAdded followings::\n- markjcarney (www.instagram.com/markjcarney)\n- ladydiana.forever (www.instagram.com/ladydiana.forever)\n- senatorandykim (www.instagram.com/senatorandykim)\n- investinggoal (www.instagram.com/investinggoal)\n\nRemoved followings::\n- ilovediana.forever (www.instagram.com/ilovediana.forever)', 'tags': ['mailbox'], 'priority': 3}
final_headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer ZZZ'}

<!-- gh-comment-id:3807300339 --> @tomballgithub commented on GitHub (Jan 27, 2026): I updated send_webhook and then uses the test webhook command line argument to run 100 cycles, which I did > out.txt to capture the output There were no errors but then I noticed that at some point I started to see tests that didn't make it past the "final_headers" line, indicating that the code didn't make it past the 'request' execution. But there were also no exception messages (and I verified that each one prints a message) or errors on the screen I am rerunning without the try/catch and not redirecting to a file. ``` Webhook test #995 final_payload: {'topic': 'YYY', 'title': 'User XXX followings changed from 4418 to 4420', 'message': 'Old Count: 4418\nNew Count: 4420\nChange: +2\n\nAdded followings::\n- markjcarney (www.instagram.com/markjcarney)\n- ladydiana.forever (www.instagram.com/ladydiana.forever)\n- senatorandykim (www.instagram.com/senatorandykim)\n- investinggoal (www.instagram.com/investinggoal)\n\nRemoved followings::\n- ilovediana.forever (www.instagram.com/ilovediana.forever)', 'tags': ['mailbox'], 'priority': 3} final_headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer ZZZ'} response.headers: {'Server': 'nginx', 'Date': 'Tue, 27 Jan 2026 06:53:02 GMT', 'Content-Type': 'application/json', 'Content-Length': '578', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*'} response: <Response [200]> * Webhook notification sent successfully sleeping for 10 seconds Webhook test #996 final_payload: {'topic': 'YYY', 'title': 'User XXX followings changed from 4418 to 4420', 'message': 'Old Count: 4418\nNew Count: 4420\nChange: +2\n\nAdded followings::\n- markjcarney (www.instagram.com/markjcarney)\n- ladydiana.forever (www.instagram.com/ladydiana.forever)\n- senatorandykim (www.instagram.com/senatorandykim)\n- investinggoal (www.instagram.com/investinggoal)\n\nRemoved followings::\n- ilovediana.forever (www.instagram.com/ilovediana.forever)', 'tags': ['mailbox'], 'priority': 3} final_headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer ZZZ'} Webhook test #997 final_payload: {'topic': 'YYY', 'title': 'User XXX followings changed from 4418 to 4420', 'message': 'Old Count: 4418\nNew Count: 4420\nChange: +2\n\nAdded followings::\n- markjcarney (www.instagram.com/markjcarney)\n- ladydiana.forever (www.instagram.com/ladydiana.forever)\n- senatorandykim (www.instagram.com/senatorandykim)\n- investinggoal (www.instagram.com/investinggoal)\n\nRemoved followings::\n- ilovediana.forever (www.instagram.com/ilovediana.forever)', 'tags': ['mailbox'], 'priority': 3} final_headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer ZZZ'} Webhook test #998 final_payload: {'topic': 'YYY', 'title': 'User XXX followings changed from 4418 to 4420', 'message': 'Old Count: 4418\nNew Count: 4420\nChange: +2\n\nAdded followings::\n- markjcarney (www.instagram.com/markjcarney)\n- ladydiana.forever (www.instagram.com/ladydiana.forever)\n- senatorandykim (www.instagram.com/senatorandykim)\n- investinggoal (www.instagram.com/investinggoal)\n\nRemoved followings::\n- ilovediana.forever (www.instagram.com/ilovediana.forever)', 'tags': ['mailbox'], 'priority': 3} final_headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer ZZZ'} response.headers: {'Server': 'nginx', 'Date': 'Tue, 27 Jan 2026 06:53:14 GMT', 'Content-Type': 'application/json', 'Content-Length': '578', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*'} response: <Response [200]> * Webhook notification sent successfully sleeping for 10 seconds Webhook test #999 final_payload: {'topic': 'YYY', 'title': 'User XXX followings changed from 4418 to 4420', 'message': 'Old Count: 4418\nNew Count: 4420\nChange: +2\n\nAdded followings::\n- markjcarney (www.instagram.com/markjcarney)\n- ladydiana.forever (www.instagram.com/ladydiana.forever)\n- senatorandykim (www.instagram.com/senatorandykim)\n- investinggoal (www.instagram.com/investinggoal)\n\nRemoved followings::\n- ilovediana.forever (www.instagram.com/ilovediana.forever)', 'tags': ['mailbox'], 'priority': 3} final_headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer ZZZ'} ```
Author
Owner

@misiektoja commented on GitHub (Jan 29, 2026):

It looks like the SSL error is still happening, but the new retry logic is successfully catching it and trying again in the background. Because the retries are silent (no print unless in debug mode) and likely running in parallel threads, the logs look like the script is skipping tests or hanging.

To verify this, you can temporarily change the debug_print inside send_webhook to a regular print to see the failures as they happen:

# Change this:
debug_print(f"* Webhook attempt {attempt + 1} failed: {e}. Retrying...")
# To this:
print(f"* Webhook attempt {attempt + 1} failed: {e}. Retrying...")

This will confirm if those missing log sections are actually just failed attempts that are currently waiting to retry.

<!-- gh-comment-id:3814781059 --> @misiektoja commented on GitHub (Jan 29, 2026): It looks like the SSL error is still happening, but the new retry logic is successfully catching it and trying again in the background. Because the retries are silent (no print unless in debug mode) and likely running in parallel threads, the logs look like the script is skipping tests or hanging. To verify this, you can temporarily change the debug_print inside send_webhook to a regular print to see the failures as they happen: ```python # Change this: debug_print(f"* Webhook attempt {attempt + 1} failed: {e}. Retrying...") # To this: print(f"* Webhook attempt {attempt + 1} failed: {e}. Retrying...") ```` This will confirm if those missing log sections are actually just failed attempts that are currently waiting to retry.
Author
Owner

@tomballgithub commented on GitHub (Jan 30, 2026):

Assumed fixed. I'll reopen if observed again.

<!-- gh-comment-id:3821840966 --> @tomballgithub commented on GitHub (Jan 30, 2026): Assumed fixed. I'll reopen if observed again.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/instagram_monitor#39
No description provided.