nxy/bot/plugins/admin.py

38 lines
860 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-08-22 13:57:57 +00:00
from docopt import Dict
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)
2017-08-22 13:57:57 +00:00
def reload(bot: irc3.IrcBot, mask: IrcString, target: IrcString, args: Dict):
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-08-21 16:27:33 +00:00
bot.reload('{}.{}'.format(MODULE, plugin))
2017-07-31 14:10:24 +00:00
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