nxy/bot/plugins/admin.py

40 lines
928 B
Python
Raw Normal View History

2017-05-15 22:26:10 +00:00
# -*- coding: utf-8 -*-
2017-07-04 13:22:20 +00:00
import logging
2017-05-16 10:06:29 +00:00
import irc3
2017-07-31 14:10:24 +00:00
# noinspection PyPackageRequirements
2017-07-04 13:22:20 +00:00
from docopt import Dict as DocOptDict
2017-05-15 22:26:10 +00:00
from irc3.plugins.command import command
2017-05-16 10:06:29 +00:00
from irc3.utils import IrcString
2017-05-15 22:26:10 +00:00
2017-07-04 13:22:20 +00:00
from . import MODULE, Plugin
logger = logging.getLogger(__name__)
2017-05-15 22:26:10 +00:00
@command(permission='admin', show_in_help_list=False)
def reload(bot: irc3.IrcBot, mask: IrcString, target: IrcString,
2017-07-04 13:22:20 +00:00
args: DocOptDict):
2017-06-30 11:16:39 +00:00
"""Reloads a plugin or the whole bot.
2017-05-16 12:42:21 +00:00
%%reload [<plugin>]
2017-05-15 22:26:10 +00:00
"""
2017-05-16 12:42:21 +00:00
plugin = args.get('<plugin>')
if plugin:
2017-07-31 14:10:24 +00:00
bot.reload('{}.{}'.format(plugin, MODULE))
bot.privmsg(target, 'Reloaded plugin "{}"'.format(plugin))
2017-05-16 12:42:21 +00:00
else:
bot.reload()
bot.privmsg(target, 'Reloaded the bot')
2017-07-04 13:22:20 +00:00
2017-07-31 14:10:24 +00:00
@irc3.event(irc3.rfc.CONNECTED)
def connected(bot, srv, me, data):
bot.mode(me, '+R')
2017-07-04 13:22:20 +00:00
@irc3.plugin
class Admin(Plugin):
2017-07-31 14:10:24 +00:00
# TODO: add admin functions (join, part, etc)
2017-07-04 13:22:20 +00:00
pass