caronc / apprise

Apprise - Push Notifications that work with just about every platform!
https://hub.docker.com/r/caronc/apprise
BSD 2-Clause "Simplified" License
10.9k stars 384 forks source link

Matrix markdown support #1138

Open bladecell opened 3 weeks ago

bladecell commented 3 weeks ago

:mega: Notification Service(s) Impacted Matrix

:lady_beetle: Describe the bug

Sending markdown message does not result in message being interpreted in markdown, while same message in chat app results in markdown preview.

import apprise

# Create an Apprise instance
apobj = apprise.Apprise()

# Define the Matrix URL with the Markdown format
matrix_url = "matrixs://<username>:<pass>@matrix.org?format=markdown/<room>:matrix.org"

# Add the Matrix URL to the Apprise object
apobj.add(matrix_url)

# Define your Markdown message
markdown_message = """
# Hello, Matrix!
This is a **Markdown** formatted message.
- Item 1
- Item 2
- Item 3
"""

# Send the notification
apobj.notify(
    body=markdown_message,
    title="Markdown Notification"
)

:bulb: Screenshots and Logs apprise image chat app image

caronc commented 3 weeks ago

Try adding ?format=markdown to the Apprise URL

bladecell commented 3 weeks ago

Thanks, changing the url to matrixs://<username>:<pass>@matrix.org/<room>:matrix.org?format=markdown fixed the issue

caronc commented 3 weeks ago

Great. Apprise has no idea what it is being fed (html, text, or markdown), so it doesn't make any rash or advanced (extra) decisions with it until you direct it.

Glad you're back in business!🙏

dgtlmoon commented 3 weeks ago

@bladecell can you try this code?

import apprise

# Create an Apprise instance
apobj = apprise.Apprise()

# Define the Matrix URL with the Markdown format
matrix_url = "matrixs://<username>:<pass>@matrix.org?format=markdown/<room>:matrix.org"

# Add the Matrix URL to the Apprise object
apobj.add(matrix_url)

# Define your Markdown message
markdown_message = """
# Hello, Matrix!
This is a **Markdown** formatted message.
- Item 1
- Item 2
- Item 3
"""

# Send the notification
apobj.notify(
    body=markdown_message,
    title="Markdown Notification",
    body_format="Markdown"
)

I want to see if my understanding of the python API is correct

caronc commented 3 weeks ago

Your URL should read:

matrix_url = "matrixs://<username>:<pass>@matrix.org/<room>:matrix.org?format=markdown"

The body_,format should also be markdown (all lower case). I may have safe guards in place... So it's possible it Will work with the first charter upshifted; is avoid the risk though

dgtlmoon commented 3 weeks ago

Your URL should read:

matrix_url = "matrixs://<username>:<pass>@matrix.org/<room>:matrix.org?format=markdown"

but shouldnt body_format in the call work? (If i understand what you're saying here :) )

bladecell commented 3 weeks ago

@bladecell can you try this code?

import apprise

# Create an Apprise instance
apobj = apprise.Apprise()

# Define the Matrix URL with the Markdown format
matrix_url = "matrixs://<username>:<pass>@matrix.org?format=markdown/<room>:matrix.org"

# Add the Matrix URL to the Apprise object
apobj.add(matrix_url)

# Define your Markdown message
markdown_message = """
# Hello, Matrix!
This is a **Markdown** formatted message.
- Item 1
- Item 2
- Item 3
"""

# Send the notification
apobj.notify(
    body=markdown_message,
    title="Markdown Notification",
    body_format="Markdown"
)

I want to see if my understanding of the python API is correct

this returns 0

dgtlmoon commented 3 weeks ago

@bladecell thats not what I was asking, what I want to know is if the message is sent or not to matrix in correct Markdown format?

@bladecell can you try this code?

import apprise

# Create an Apprise instance
apobj = apprise.Apprise()

# Define the Matrix URL with the Markdown format
matrix_url = "matrixs://<username>:<pass>@matrix.org?format=markdown/<room>:matrix.org"

# Add the Matrix URL to the Apprise object
apobj.add(matrix_url)

# Define your Markdown message
markdown_message = """
# Hello, Matrix!
This is a **Markdown** formatted message.
- Item 1
- Item 2
- Item 3
"""

# Send the notification
apobj.notify(
    body=markdown_message,
    title="Markdown Notification",
    body_format="Markdown"
)

I want to see if my understanding of the python API is correct

this returns 0

bladecell commented 3 weeks ago

@bladecell thats not what I was asking, what I want to know is if the message is sent or not to matrix in correct Markdown format?

@bladecell can you try this code?

import apprise

# Create an Apprise instance
apobj = apprise.Apprise()

# Define the Matrix URL with the Markdown format
matrix_url = "matrixs://<username>:<pass>@matrix.org?format=markdown/<room>:matrix.org"

# Add the Matrix URL to the Apprise object
apobj.add(matrix_url)

# Define your Markdown message
markdown_message = """
# Hello, Matrix!
This is a **Markdown** formatted message.
- Item 1
- Item 2
- Item 3
"""

# Send the notification
apobj.notify(
    body=markdown_message,
    title="Markdown Notification",
    body_format="Markdown"
)

I want to see if my understanding of the python API is correct

this returns 0

It did not send message

caronc commented 3 weeks ago

I could see value in adjusting the format automatically under the hood (if not specified and a body_format is). But this isn't in place yet.

The only reason is all 100+ notifications support text, only some support the others. So there is the edge case that i need to go though all of the plugins and identify what they can be. THEN i could look at the body_format thereafter and compare it at a per notification and if supported, then alter the default value.

Not sure if that makes sense, but it's a big job(not hard, but very big and error prone), so not something I've attempted yet.

For now Apprise runs through its conversions only if it has the explicit info to do so

caronc commented 3 weeks ago

Change Markdown to markdown

I'm replying on my phone, I'll see if i can have a closer look later on

caronc commented 3 weeks ago

@bladecell i can see in your last message that you have not applied my suggestions to change your URL. 2-3 comments up. This is why it's not working for you now. The Matrix Apprise URL is not valid in the format you recently changed it to