#!/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 = trigger.args[1] if len(trigger.args) >= 2 else None key = trigger.args[2] if len(trigger.args) >= 3 else None 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.""" if len(trigger.args) < 2: return channel = trigger.args[1] if len(trigger.args) >= 3: part_msg = ' '.join(trigger.args[2:]) else: part_msg = None if not channel.startswith("#"): part_msg = channel channel = "" 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.""" if len(trigger.args) >= 2: quit_message = ' '.join(trigger.args[1:]) else: 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 len(trigger.args) < 3: return channel = trigger.args[1] message = ' '.join(trigger.args[2:]) 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 len(trigger.args) < 3: return channel = trigger.args[1] action = ' '.join(trigger.args[2:]) # 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 Fulvia. Can only be done in privmsg by an admin.""" if len(trigger.args) < 2: return mode = trigger.args[1] add_mode = mode.startswith("+") bot.mode(bot.nickname, add_mode, mode)