#!/usr/bin/env python3 """ Some administrative functions relating to the bot. """ import module @module.require_admin @module.commands('join') @module.example('.join #example or .join #example key') def join(bot, trigger): """Join the specified channel. This is an admin-only command.""" channel, key = trigger.group(3), trigger.group(4) if not channel: return elif not key: bot.join(channel) else: bot.join(channel, key) @module.require_admin @module.commands('part') @module.example('.part #example') def part(bot, trigger): """Part the specified channel. This is an admin-only command.""" channel, _, part_msg = trigger.group(2).partition(' ') if not channel: channel = trigger.channel if part_msg: bot.part(channel, part_msg) else: bot.part(channel) @module.require_owner @module.commands('quit') def quit(bot, trigger): """Quit from the server. This is an owner-only command.""" quit_message = trigger.group(2) if not quit_message: quit_message = f"Quitting on command from {trigger.nick}" bot.quit(quit_message) @module.require_admin @module.commands('msg') @module.example('.msg #YourPants Does anyone else smell neurotoxin?') def msg(bot, trigger): """ Send a message to a given channel or nick. Can only be done by an admin. """ if trigger.group(2) is None: return channel, _, message = trigger.group(2).partition(' ') message = message.strip() if not channel or not message: return bot.msg(channel, message) @module.require_admin @module.commands('me') @module.example(".me #erp notices your bulge") def me(bot, trigger): """ Send an ACTION (/me) to a given channel or nick. Can only be done by an admin. """ if trigger.group(2) is None: return channel, _, action = trigger.group(2).partition(' ') action = action.strip() if not channel or not action: return # msg = '\x01ACTION %s\x01' % action bot.describe(channel, action) @module.require_admin @module.commands('selfmode') @module.example(".mode +B") def self_mode(bot, trigger): """Set a user mode on Sopel. Can only be done in privmsg by an admin.""" mode = trigger.group(3) add_mode = mode.startswith("+") bot.mode(bot.nickname, add_mode, mode)