feat: paste overflow via FlaskPaste for long replies

Add Bot.long_reply() that sends lines directly when under threshold,
or creates a FlaskPaste paste with preview + link when over. Refactor
abuseipdb, alert history, crtsh, dork, exploitdb, and subdomain
plugins to use long_reply(). Configurable paste_threshold (default: 4).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
user
2026-02-17 22:07:31 +01:00
parent 8cabe0f8e8
commit 1836fa50af
9 changed files with 242 additions and 21 deletions

View File

@@ -460,6 +460,52 @@ class Bot:
if target:
await self.send(target, text)
async def long_reply(
self, msg: Message, lines: list[str], *,
label: str = "",
) -> None:
"""Reply with a list of lines; paste overflow to FlaskPaste.
If len(lines) <= paste_threshold, sends each line via send().
If len(lines) > paste_threshold, creates a paste with all lines
and sends a preview (first 2 lines) + paste URL.
Falls back to sending all lines if FlaskPaste is unavailable.
"""
threshold = self.config["bot"].get("paste_threshold", 4)
target = msg.target if msg.is_channel else msg.nick
if not lines or not target:
return
if len(lines) <= threshold:
for line in lines:
await self.send(target, line)
return
# Attempt paste overflow
fp = self.registry._modules.get("flaskpaste")
paste_url = None
if fp:
full_text = "\n".join(lines)
loop = asyncio.get_running_loop()
paste_url = await loop.run_in_executor(
None, fp.create_paste, self, full_text,
)
if paste_url:
preview_count = min(2, threshold - 1)
for line in lines[:preview_count]:
await self.send(target, line)
remaining = len(lines) - preview_count
suffix = f" ({label})" if label else ""
await self.send(
target,
f"... {remaining} more lines{suffix}: {paste_url}",
)
else:
for line in lines:
await self.send(target, line)
async def action(self, target: str, text: str) -> None:
"""Send a CTCP ACTION (/me) to a target."""
await self.send(target, f"\x01ACTION {text}\x01")

View File

@@ -27,6 +27,7 @@ DEFAULTS: dict = {
"plugins_dir": "plugins",
"rate_limit": 2.0,
"rate_burst": 5,
"paste_threshold": 4,
"admins": [],
},
"channels": {},