Asyncio IRC bot with decorator-based plugin system. Zero external dependencies, Python 3.11+. - IRC protocol: message parsing, formatting, async TCP/TLS connection - Plugin system: @command and @event decorators, file-based loading - Bot orchestrator: connect, dispatch, reconnect, nick recovery - CLI: argparse entry point with TOML config - Built-in plugins: ping, help, version, echo - 28 unit tests for parser and plugin system
24 lines
636 B
Python
24 lines
636 B
Python
"""Example plugin demonstrating the derp plugin API."""
|
|
|
|
from derp.plugin import command, event
|
|
|
|
|
|
@command("echo", help="Echo back text")
|
|
async def cmd_echo(bot, message):
|
|
"""Repeat everything after the command.
|
|
|
|
Usage: !echo <text>
|
|
"""
|
|
parts = message.text.split(None, 1)
|
|
if len(parts) > 1:
|
|
await bot.reply(message, parts[1])
|
|
else:
|
|
await bot.reply(message, "Usage: !echo <text>")
|
|
|
|
|
|
@event("JOIN")
|
|
async def on_join(bot, message):
|
|
"""Greet users joining a channel (skip self)."""
|
|
if message.nick and message.nick != bot.nick:
|
|
await bot.send(message.target, f"Hey {message.nick}")
|