nxy/bot/plugins/admin.py

38 lines
860 B
Python
Raw Normal View History

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