Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f98f83d5df | |||
| 611a9551df | |||
| 512275a8b8 | |||
| 3abc37bb3c | |||
| 9c1f18fbee | |||
| 98e2683b80 | |||
| cba7a701bf |
+6
-3
@@ -1,12 +1,15 @@
|
|||||||
FROM python:3
|
FROM python:3.14
|
||||||
|
|
||||||
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
COPY main.py parker.gif requirements.txt ./
|
COPY requirements.txt ./
|
||||||
|
RUN uv pip install --system --no-cache -r requirements.txt
|
||||||
|
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
COPY main.py parker.gif ./
|
||||||
|
|
||||||
USER 1000:1000
|
USER 1000:1000
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
# ParkerBot
|
# ParkerBot
|
||||||
|
|
||||||
ParkerBot is a Matrix bot that monitors a channel for YouTube links and
|
ParkerBot is a Matrix bot that monitors a channel for YouTube links and
|
||||||
generates weekly playlists from them.
|
generates weekly playlists from them. It also sends YouTube link titles to the
|
||||||
|
channel it's in.
|
||||||
|
|
||||||
## Running locally
|
## Running locally
|
||||||
|
|
||||||
1. Clone the repo
|
1. Clone the repo
|
||||||
2. Install the dependencies, preferably in a venv:
|
2. Install the dependencies, preferably in a venv:
|
||||||
```shell
|
```shell
|
||||||
python3 -m venv venv
|
uv venv --python 3.14 --seed
|
||||||
source ./venv/bin/activate
|
source .venv/bin/activate
|
||||||
pip3 install -r requirements.txt
|
uv pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
3. Copy [example.env](example.env) to `.env`, customize it.
|
3. Copy [example.env](example.env) to `.env`, customize it.
|
||||||
4. Source `.env`:
|
4. Source `.env`:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import asyncio
|
import asyncio
|
||||||
import datetime
|
import datetime
|
||||||
|
import html
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
import re
|
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
|
# 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
|
# Only do this for recent messages to prevent spam during backwards-sync
|
||||||
if recent:
|
if recent:
|
||||||
display_text = f"▶️ {title}"
|
plain_text = f"{title}"
|
||||||
if channel:
|
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(
|
await client.room_send(
|
||||||
room_id=room.room_id,
|
room_id=room.room_id,
|
||||||
message_type="m.room.message",
|
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
|
# Only add to the playlist if it's categorized as music/entertainment
|
||||||
|
|||||||
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
matrix-nio == 0.24.0
|
matrix-nio == 0.24.0
|
||||||
google-auth-oauthlib
|
google-auth-oauthlib == 1.3.1
|
||||||
google-api-python-client
|
google-api-python-client == 2.194.0
|
||||||
|
|||||||
Reference in New Issue
Block a user