Implement !botset/!botget in modules/set.py

This commit is contained in:
jesopo 2018-10-04 17:09:52 +01:00
parent a533228112
commit 57b72a94c5
2 changed files with 22 additions and 0 deletions

View file

@ -36,6 +36,9 @@ class Handler(http.server.BaseHTTPRequestHandler):
pass pass
_bot.lock.release() _bot.lock.release()
@utils.export("botset", {"setting": "rest-api",
"help": "Enable/disable REST API",
"validate": utils.bool_or_none})
class Module(object): class Module(object):
def __init__(self, bot, events, exports): def __init__(self, bot, events, exports):
self.bot = bot self.bot = bot

View file

@ -50,6 +50,15 @@ class Module(ModuleManager.BaseModule):
""" """
self._set(self.exports.get_all("serverset"), event, event["server"]) self._set(self.exports.get_all("serverset"), event, event["server"])
@utils.hook("received.command.botset")
def bot_set(self, event):
"""
:help: Set a specified bot setting
:usage: <setting> <value>
:permission: botset
"""
self._set(self.exports.get_all("botset"), event, self.bot)
def _get(self, event, setting, qualifier, value): def _get(self, event, setting, qualifier, value):
if not value == None: if not value == None:
event["stdout"].write("'%s'%s: %s" % (setting, event["stdout"].write("'%s'%s: %s" % (setting,
@ -88,3 +97,13 @@ class Module(ModuleManager.BaseModule):
setting = event["args_split"][0] setting = event["args_split"][0]
self._get(event, setting, "", event["server"].get_setting( self._get(event, setting, "", event["server"].get_setting(
setting, None)) setting, None))
@utils.hook("received.command.botget", min_args=1)
def bot_get(self, event):
"""
:help: Get a specified bot setting
:usage: <setting>
:permission: botget
"""
setting = event["args_split"][0]
self._get(event, setting, "", self.bot.get_setting(setting, None))