Initial commit: memo app with FastAPI, SQLite, APScheduler, Discord notifications
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import requests
|
||||
from .database import get_db
|
||||
|
||||
def get_webhook_url() -> str:
|
||||
with get_db() as conn:
|
||||
row = conn.execute("SELECT value FROM settings WHERE key = 'discord_webhook'").fetchone()
|
||||
return row["value"] if row else ""
|
||||
|
||||
def send_reminder(memo: dict):
|
||||
url = get_webhook_url()
|
||||
if not url:
|
||||
return
|
||||
|
||||
description = memo["description"] or ""
|
||||
desc_line = f"\n> {description}" if description else ""
|
||||
|
||||
payload = {
|
||||
"embeds": [{
|
||||
"title": f"🔔 Rappel : {memo['title']}",
|
||||
"description": f"{desc_line}\n📅 Créé le {memo['created_at'][:10]}",
|
||||
"color": 0xf59e0b,
|
||||
"footer": {"text": "memo.nas.percolouco.com"}
|
||||
}]
|
||||
}
|
||||
try:
|
||||
requests.post(url, json=payload, timeout=5)
|
||||
except Exception:
|
||||
pass
|
||||
Reference in New Issue
Block a user