feat: add !paste command and unit tests for 5 core plugins
Add cmd_paste to flaskpaste plugin (create paste, return URL). Add test suites for encode, hash, defang, cidr, and dns plugins (83 new test cases, 1093 total). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -192,3 +192,33 @@ async def cmd_shorten(bot, message):
|
||||
await bot.reply(message, short)
|
||||
else:
|
||||
await bot.reply(message, "shorten failed: no URL returned")
|
||||
|
||||
|
||||
@command("paste", help="Create a paste: !paste <text>")
|
||||
async def cmd_paste(bot, message):
|
||||
"""Create a paste via FlaskPaste.
|
||||
|
||||
Usage:
|
||||
!paste some text to paste
|
||||
"""
|
||||
parts = message.text.split(None, 1)
|
||||
if len(parts) < 2:
|
||||
await bot.reply(message, "Usage: !paste <text>")
|
||||
return
|
||||
|
||||
content = parts[1]
|
||||
base_url = _get_base_url(bot)
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
try:
|
||||
url = await loop.run_in_executor(
|
||||
None, _create_paste, base_url, content,
|
||||
)
|
||||
except Exception as exc:
|
||||
await bot.reply(message, f"paste failed: {exc}")
|
||||
return
|
||||
|
||||
if url:
|
||||
await bot.reply(message, url)
|
||||
else:
|
||||
await bot.reply(message, "paste failed: no URL returned")
|
||||
|
||||
Reference in New Issue
Block a user