feat: add flaskpaste plugin with paste/shorten commands

- PoW-authenticated paste creation and URL shortening via FlaskPaste
- !paste <text> creates a paste, !shorten <url> shortens a URL
- Module-level shorten_url/create_paste helpers for cross-plugin use
- Alert plugin auto-shortens URLs in announcements and history output
- Custom TLS CA cert support via secrets/flaskpaste/derp.crt
- No SOCKS proxy -- direct urllib.request to FlaskPaste instance
This commit is contained in:
user
2026-02-16 23:10:59 +01:00
parent 35acc744ac
commit 3cdc00c285
5 changed files with 294 additions and 0 deletions

View File

@@ -1753,10 +1753,18 @@ async def _poll_once(bot, key: str, announce: bool = True) -> None:
if announce and matched:
channel = data["channel"]
name = data["name"]
fp = bot.registry._modules.get("flaskpaste")
for item in matched:
short_id = _save_result(channel, name, tag, item)
title = _truncate(item["title"]) if item["title"] else "(no title)"
url = item["url"]
if fp and url:
try:
url = await loop.run_in_executor(
None, fp.shorten_url, bot, url,
)
except Exception:
pass
date = item.get("date", "")
line = f"[{name}/{tag}/{short_id}]"
if date:
@@ -1936,9 +1944,18 @@ async def cmd_alert(bot, message):
if not rows:
await bot.reply(message, f"{name}: no history yet")
return
loop = asyncio.get_running_loop()
fp = bot.registry._modules.get("flaskpaste")
for backend, title, url, date, found_at, short_id in reversed(rows):
ts = found_at[:10]
title = _truncate(title) if title else "(no title)"
if fp and url:
try:
url = await loop.run_in_executor(
None, fp.shorten_url, bot, url,
)
except Exception:
pass
line = f"[{name}/{backend}/{short_id}] ({date or ts}) {title}"
if url:
line += f" -- {url}"