dgtlmoon / changedetection.io

The best and simplest free open source web page change detection, website watcher, restock monitor and notification service. Restock Monitor, change detection. Designed for simplicity - Simply monitor which websites had a text change for free. Free Open source web page change detection, Website defacement monitoring, Price change notification
https://changedetection.io
Apache License 2.0
16.85k stars 941 forks source link

[feature] Add an option to send embed messages to Discord webhooks #907

Open XXCoreRangerX opened 2 years ago

XXCoreRangerX commented 2 years ago

Version and OS 0.39.18 on linux/docker

Is your feature request related to a problem? Please describe. My monitored URL's {diff} often exceeds the 1700 characters limit. Using embeds could increase the limit up to 4096 characters by using the description field for diffs.

Describe the solution you'd like Add an embed message type for Discord notifications with a customizable structure consisting of embedded fields. I'm pretty sure Apprise, the dependency used for notifications, already has support for embeds, so adding it here shouldn't be much of an issue.

Describe the use-case and give concrete real-world examples The limit of diffs would be increased from 1700 to 4096 characters. Additionally, embedded Discord notifications would simply look better than pure text.

dgtlmoon commented 2 years ago

Thanks for that info!

Also looking interesting is the 'attachment object' too

Repooc commented 1 year ago

please please, i would love it if you were to add this functionality as that is prob the only thing keeping me from using this as I would like.

dhanadhan commented 1 year ago

I would love to have the embed option as well. Currently, the web url is embedded when sent through Discord webhook and it looks pretty ugly lol. There is no way to post a plain web link though webhook. If the Embed Message feature described in this post is added, it would solve this issue as well.

Thanks

jpdsc commented 1 year ago

You can use the apprise embeded option by adding ?format=markdown. Example: discord://webhook_id/webhook_token?format=markdown

Doing, apprise will embed the message. image

You can also add additional parameters: https://github.com/caronc/apprise/wiki/Notify_discord#parameter-breakdown

I checked footer, avatar_url and these are working. However, the footer cannot be changed and shows changedetection.io information.

dhanadhan commented 1 year ago

You can use the apprise embeded option by adding ?format=markdown. Example: discord://webhook_id/webhook_token?format=markdown

Doing, apprise will embed the message. image

You can also add additional parameters: https://github.com/caronc/apprise/wiki/Notify_discord#parameter-breakdown

I checked footer, avatar_url and these are working. However, the footer cannot be changed and shows changedetection.io information.

Awesome, that worked. Thank you.

Do you know how to get rid of that "changedetection.io" link on every embed?

jpdsc commented 1 year ago

That is the author field, not sure how apprise embeds this one as there is no reference to it in the apprise documentation.

Same for footer text and footer image.

naviem commented 11 months ago

Anyone ever figure out how to remove the author field? I don't like it showing it. Trying to keep the notification simple and clean as possible

dhanadhan commented 11 months ago

Anyone ever figure out how to remove the author field? I don't like it showing it. Trying to keep the notification simple and clean as possible

Nope, still can't figure out a way to remove author. It does look annoying so I don't use embed anymore. I wish dev can add it eventually 🤞

BlackWolfWoof commented 1 month ago

@XXCoreRangerX Hehe hello, 2 years later you have your answer :) It is still not natively supported BUUUT... posts://discord.com/api/webhooks/IDHERE/TOKENHERE?+Content-Type=application/json

{% set title = watch_title if watch_title else "N/A" %}
{% set title = title | replace("\n", "") %}
{% set restock_info = restock if restock else {} %}

{% set description = "" %}
{% if restock_info %}
{% set description = "**In Stock:** " ~ restock.in_stock ~ "\\n" %}
{% set description = description ~ "**Price:** " ~ restock_info.price ~ " " ~ restock_info.currency ~ "\\n" %}
{% set description = description ~ "**Original Price:** " ~ restock_info.original_price ~ " " ~ restock_info.currency ~ "\\n" %}
{% endif %}
{% set diffContent = diff | replace("\n", "\\n") %}

{
    "username": "Changedetection.io",
    "avatar_url": "https://cdn.discordapp.com/avatars/1269225949942124594/7cd30e60dd046655c0f02071c70122d2.webp",
    "embeds": [
        {
            "title": "{{ title }}",
            "url": "{{ watch_url }}",
            "color": 4372701,
            "description": "{% if description %}{{ description }}{% else %}{% endif %}**Difference:** [Link]({{diff_url}})\n{{diffContent}}"
        }
    ]
}

as example. Note: use a service like https://webhook.site/ to see what info gets sent and make sure newlines are escaped and you don't forget a , in the json like i did which added an additional 3h of troubleshooting 💀💀 1920-1078-max