Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 98e2683b80 | |||
| cba7a701bf |
@@ -4,6 +4,7 @@
|
||||
import argparse
|
||||
import asyncio
|
||||
import datetime
|
||||
import html
|
||||
import os
|
||||
import pickle
|
||||
import re
|
||||
@@ -307,14 +308,23 @@ async def message_callback(conn, cursor, youtube, client, room, event):
|
||||
# Send the title to the channel so people know what the link is
|
||||
# Only do this for recent messages to prevent spam during backwards-sync
|
||||
if recent:
|
||||
display_text = f"▶️ {title}"
|
||||
plain_text = f"🎵 {title}"
|
||||
if channel:
|
||||
display_text += f" - {channel}"
|
||||
plain_text += f" - {channel}"
|
||||
|
||||
# Escape HTML characters to prevent broken rendering in Matrix
|
||||
escaped_text = html.escape(plain_text)
|
||||
html_text = f"<em><span data-mx-color='#808080'>{escaped_text}</span></em>"
|
||||
|
||||
await client.room_send(
|
||||
room_id=room.room_id,
|
||||
message_type="m.room.message",
|
||||
content={"msgtype": "m.text", "body": display_text},
|
||||
content={
|
||||
"msgtype": "m.text",
|
||||
"body": plain_text,
|
||||
"format": "org.matrix.custom.html",
|
||||
"formatted_body": html_text
|
||||
},
|
||||
)
|
||||
|
||||
# Only add to the playlist if it's categorized as music/entertainment
|
||||
|
||||
Reference in New Issue
Block a user