From 5a8d568931d9b23ce0df1265d05259a7012081c9 Mon Sep 17 00:00:00 2001 From: Ahmed Date: Sun, 14 Jun 2026 01:46:29 +0300 Subject: init: mostly vibed --- salvador/commands.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 salvador/commands.py (limited to 'salvador/commands.py') diff --git a/salvador/commands.py b/salvador/commands.py new file mode 100644 index 0000000..833a953 --- /dev/null +++ b/salvador/commands.py @@ -0,0 +1,64 @@ +""" +Sopel plugin: salvador admin commands + +Owner-only commands for managing the bot at runtime. + + !join #channel - join a channel + !part [#channel] - leave a channel (defaults to current) + !chans - list channels the bot is in + !help - show usage +""" + +from sopel import plugin + + +def _is_owner(bot, trigger): + return trigger.nick == bot.settings.core.owner + + +@plugin.command("join") +def cmd_join(bot, trigger): + if not _is_owner(bot, trigger): + return + channel = (trigger.group(2) or "").strip() + if not channel.startswith("#"): + bot.say("usage: !join #channel") + return + bot.join(channel) + + +@plugin.command("part") +def cmd_part(bot, trigger): + if not _is_owner(bot, trigger): + return + channel = (trigger.group(2) or "").strip() + if not channel: + channel = trigger.sender + bot.part(channel) + + +@plugin.command("chans") +def cmd_chans(bot, trigger): + if not _is_owner(bot, trigger): + return + chans = sorted(str(c) for c in bot.channels) + if chans: + bot.say("in: " + " ".join(chans)) + else: + bot.say("not in any channels") + + +@plugin.command("help") +def cmd_help(bot, trigger): + lines = [ + "!draw [] - render image as mIRC colour art (lines: 4-12, default 6)", + ] + if _is_owner(bot, trigger): + lines += [ + "!join #channel - join a channel (owner)", + "!part [#channel] - leave a channel (owner)", + "!chans - list channels the bot is in (owner)", + ] + lines.append("!help - this message") + for line in lines: + bot.say(line, trigger.nick) -- cgit v1.2.3