""" 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)