[PR #56] [MERGED] Implement webhook configuration support. Default is existing Discord implementation #65

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

📋 Pull Request Information

Original PR: https://github.com/misiektoja/instagram_monitor/pull/56
Author: @tomballgithub
Created: 1/25/2026
Status: Merged
Merged: 1/25/2026
Merged by: @misiektoja

Base: devHead: webhooks3


📝 Commits (5)

  • b62241a Implement webhook configuration support. Default is existing Discord implementation
  • 8ebffbb Remove token from example
  • 7186c40 fix: restore webhook URL validation and notification type filtering removed in PR
  • 311b27e fix: correct webhook template indentation and handle missing placeholders gracefully
  • e6f9b2c feat: update webhook URL validation to accept both HTTP and HTTPS schemes

📊 Changes

1 file changed (+118 additions, -40 deletions)

View changed files

📝 instagram_monitor.py (+118 -40)

📄 Description

Implement webhook configuration support. Default is existing Discord implementation

Tested with Discord and NTFY both in execution and with the webhook test option

Default is to existing Discord implementation:

# Webhook request payload template
# Substitutions will apply for items in {}, which can include title, description, version, image_url, fields, fields_str, color, timestamp, username, avatar_url
#
# The default template is for Discord:
WEBHOOK_TEMPLATE = {
    "username": "Instagram Monitor",
    "embeds": [{
        "title": "{title}",
        "description": "{description}",
        "color": 7506394,
        "fields": "{fields}",
        "footer": {
            "text": "Instagram Monitor v{version}"
        },
        "image": {
            "url": "{image_url}"
        }
    }]
}

# Webhook request headers as a dictionary, but it can be empty. 
# Some examples:
#   {
#       "Content-Type": "application/json",
#       "Authorization": "Bearer tk_redacted"
#   }
WEBHOOK_HEADERS = {}

# Transformations to apply to WEBHOOK_TEMPLATE and WEBHOOK_HEADERS as a list of tuples, but it can be empty
# tuple format is: (field_to_target, method_name, *optional_arguments)
#
# Some examples:
#   [
#       ("title", "upper"),                       # Make title all uppercase
#       ("description", "replace", "**", ""),     # Remove bold markdown in description
#       ("description", "strip")                  # Remove leading/trailing whitespace
#   ]
WEBHOOK_TRANSFORMS = []

Here's what I used to test NTFY:

WEBHOOK_URL = "https://ntfy.sh/"

WEBHOOK_HEADERS = {
    "Content-Type": "application/json",
    "Authorization": "Bearer tk_redacted"
}

WEBHOOK_TEMPLATE = {
    "topic": "status_reports_test",
    "title": "{description}",
    "message": "{fields_str}",
    "tags": ["mailbox"],
    "priority": 3
}

WEBHOOK_TRANSFORMS = [
    # (field_to_target, method_name, *optional_arguments)
    ("fields_str", "replace", "**A", "\nA"),    # Add newline before Added Followers/ings
    ("fields_str", "replace", "**R", "\nR"),    # Add newline before Removed Followers/ings
    ("fields_str", "replace", "**:", ":\n"),    # Add newline before list of named
    ("fields_str", "replace", "**", ""),        # Remove bold markdown
    ("fields_str", "replace", "<",  ""),        # Remove extra chars around URL
    ("fields_str", "replace", "/>", ""),        # Remove extra chars around URL
    ("fields_str", "replace", "\n\n\n", "\n\n"),# Remove double blank lines
    ("description", "replace", "**", ""),       # Remove bold markdown
    # ("fields_str", "strip"),                  # Remove leading/trailing whitespace
    # ("description", "upper")                  # Make title all caps
]

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/misiektoja/instagram_monitor/pull/56 **Author:** [@tomballgithub](https://github.com/tomballgithub) **Created:** 1/25/2026 **Status:** ✅ Merged **Merged:** 1/25/2026 **Merged by:** [@misiektoja](https://github.com/misiektoja) **Base:** `dev` ← **Head:** `webhooks3` --- ### 📝 Commits (5) - [`b62241a`](https://github.com/misiektoja/instagram_monitor/commit/b62241ac43643120ab83ae49efcfa1a533d8cbeb) Implement webhook configuration support. Default is existing Discord implementation - [`8ebffbb`](https://github.com/misiektoja/instagram_monitor/commit/8ebffbb040c1202614440b704273d95dbe74790e) Remove token from example - [`7186c40`](https://github.com/misiektoja/instagram_monitor/commit/7186c40df4c4e11e91a738d3c7f7ecf0d1db575d) fix: restore webhook URL validation and notification type filtering removed in PR - [`311b27e`](https://github.com/misiektoja/instagram_monitor/commit/311b27e78dfb33d657407b9aa40448b6a757e020) fix: correct webhook template indentation and handle missing placeholders gracefully - [`e6f9b2c`](https://github.com/misiektoja/instagram_monitor/commit/e6f9b2c79d3498b606364ca41f89b569d8251ea2) feat: update webhook URL validation to accept both HTTP and HTTPS schemes ### 📊 Changes **1 file changed** (+118 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `instagram_monitor.py` (+118 -40) </details> ### 📄 Description Implement webhook configuration support. Default is existing Discord implementation Tested with Discord and NTFY both in execution and with the webhook test option Default is to existing Discord implementation: ``` # Webhook request payload template # Substitutions will apply for items in {}, which can include title, description, version, image_url, fields, fields_str, color, timestamp, username, avatar_url # # The default template is for Discord: WEBHOOK_TEMPLATE = { "username": "Instagram Monitor", "embeds": [{ "title": "{title}", "description": "{description}", "color": 7506394, "fields": "{fields}", "footer": { "text": "Instagram Monitor v{version}" }, "image": { "url": "{image_url}" } }] } # Webhook request headers as a dictionary, but it can be empty. # Some examples: # { # "Content-Type": "application/json", # "Authorization": "Bearer tk_redacted" # } WEBHOOK_HEADERS = {} # Transformations to apply to WEBHOOK_TEMPLATE and WEBHOOK_HEADERS as a list of tuples, but it can be empty # tuple format is: (field_to_target, method_name, *optional_arguments) # # Some examples: # [ # ("title", "upper"), # Make title all uppercase # ("description", "replace", "**", ""), # Remove bold markdown in description # ("description", "strip") # Remove leading/trailing whitespace # ] WEBHOOK_TRANSFORMS = [] ``` Here's what I used to test NTFY: ``` WEBHOOK_URL = "https://ntfy.sh/" WEBHOOK_HEADERS = { "Content-Type": "application/json", "Authorization": "Bearer tk_redacted" } WEBHOOK_TEMPLATE = { "topic": "status_reports_test", "title": "{description}", "message": "{fields_str}", "tags": ["mailbox"], "priority": 3 } WEBHOOK_TRANSFORMS = [ # (field_to_target, method_name, *optional_arguments) ("fields_str", "replace", "**A", "\nA"), # Add newline before Added Followers/ings ("fields_str", "replace", "**R", "\nR"), # Add newline before Removed Followers/ings ("fields_str", "replace", "**:", ":\n"), # Add newline before list of named ("fields_str", "replace", "**", ""), # Remove bold markdown ("fields_str", "replace", "<", ""), # Remove extra chars around URL ("fields_str", "replace", "/>", ""), # Remove extra chars around URL ("fields_str", "replace", "\n\n\n", "\n\n"),# Remove double blank lines ("description", "replace", "**", ""), # Remove bold markdown # ("fields_str", "strip"), # Remove leading/trailing whitespace # ("description", "upper") # Make title all caps ] ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:05:16 +03:00
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#65
No description provided.