Remove array-setting log - we don't/shouldn't use it.
This commit is contained in:
parent
cf29c37112
commit
13a878cc17
1 changed files with 6 additions and 30 deletions
|
@ -2,8 +2,6 @@ import enum
|
||||||
from src import ModuleManager, utils
|
from src import ModuleManager, utils
|
||||||
|
|
||||||
CHANNELSET_HELP = "Get a specified channel setting for the current channel"
|
CHANNELSET_HELP = "Get a specified channel setting for the current channel"
|
||||||
CHANNELSETADD_HELP = ("Add to a specified channel setting for the "
|
|
||||||
"current channel")
|
|
||||||
|
|
||||||
class ConfigInvalidValue(Exception):
|
class ConfigInvalidValue(Exception):
|
||||||
pass
|
pass
|
||||||
|
@ -38,7 +36,7 @@ class ConfigChannelTarget(object):
|
||||||
self._bot.database.channel_settings.delete(channel_id, setting)
|
self._bot.database.channel_settings.delete(channel_id, setting)
|
||||||
|
|
||||||
class Module(ModuleManager.BaseModule):
|
class Module(ModuleManager.BaseModule):
|
||||||
def _set(self, category, event, target, array, arg_index=0):
|
def _set(self, category, event, target, arg_index=0):
|
||||||
args = event["args_split"][arg_index:]
|
args = event["args_split"][arg_index:]
|
||||||
settings = self.exports.get_all(category)
|
settings = self.exports.get_all(category)
|
||||||
settings_dict = {setting["setting"]: setting for setting in settings}
|
settings_dict = {setting["setting"]: setting for setting in settings}
|
||||||
|
@ -47,24 +45,12 @@ class Module(ModuleManager.BaseModule):
|
||||||
setting = args[0].lower()
|
setting = args[0].lower()
|
||||||
if setting in settings_dict:
|
if setting in settings_dict:
|
||||||
setting_options = settings_dict[setting]
|
setting_options = settings_dict[setting]
|
||||||
if not setting_options.get("array", False) == array:
|
|
||||||
if array:
|
|
||||||
raise utils.EventError(
|
|
||||||
"Can't add to a non-array setting")
|
|
||||||
else:
|
|
||||||
raise utils.EventError(
|
|
||||||
"You can only 'add' to an array setting")
|
|
||||||
|
|
||||||
value = " ".join(args[1:])
|
value = " ".join(args[1:])
|
||||||
value = setting_options.get("validate", lambda x: x)(value)
|
value = setting_options.get("validate", lambda x: x)(value)
|
||||||
|
|
||||||
if not value == None:
|
if not value == None:
|
||||||
if array:
|
target.set_setting(setting, value)
|
||||||
current_value = target.get_setting(setting, [])
|
|
||||||
current_value.append(value)
|
|
||||||
target.set_setting(setting, current_value)
|
|
||||||
else:
|
|
||||||
target.set_setting(setting, value)
|
|
||||||
|
|
||||||
self.events.on("set").on(category).on(setting).call(
|
self.events.on("set").on(category).on(setting).call(
|
||||||
value=value, target=target)
|
value=value, target=target)
|
||||||
|
@ -84,13 +70,11 @@ class Module(ModuleManager.BaseModule):
|
||||||
", ".join(shown_settings)))
|
", ".join(shown_settings)))
|
||||||
|
|
||||||
@utils.hook("received.command.set", help="Set a specified user setting")
|
@utils.hook("received.command.set", help="Set a specified user setting")
|
||||||
@utils.hook("received.command.setadd",
|
|
||||||
help="Add to a specified user setting")
|
|
||||||
def set(self, event):
|
def set(self, event):
|
||||||
"""
|
"""
|
||||||
:usage: <setting> <value>
|
:usage: <setting> <value>
|
||||||
"""
|
"""
|
||||||
self._set("set", event, event["user"], event["command"]=="setadd")
|
self._set("set", event, event["user"])
|
||||||
|
|
||||||
@utils.hook("received.command.channelset", min_args=1, private_only=True,
|
@utils.hook("received.command.channelset", min_args=1, private_only=True,
|
||||||
help=CHANNELSET_HELP)
|
help=CHANNELSET_HELP)
|
||||||
|
@ -106,39 +90,31 @@ class Module(ModuleManager.BaseModule):
|
||||||
|
|
||||||
@utils.hook("received.command.channelset", channel_only=True,
|
@utils.hook("received.command.channelset", channel_only=True,
|
||||||
help=CHANNELSET_HELP)
|
help=CHANNELSET_HELP)
|
||||||
@utils.hook("received.command.channelsetadd", channel_only=True,
|
|
||||||
help=CHANNELSETADD_HELP)
|
|
||||||
def channel_set(self, event):
|
def channel_set(self, event):
|
||||||
"""
|
"""
|
||||||
:usage: <setting> <value>
|
:usage: <setting> <value>
|
||||||
:require_mode: high
|
:require_mode: high
|
||||||
:permission: channelsetoverride
|
:permission: channelsetoverride
|
||||||
"""
|
"""
|
||||||
self._set("channelset", event, event["target"],
|
self._set("channelset", event, event["target"])
|
||||||
event["command"].startswith("channelsetadd"))
|
|
||||||
|
|
||||||
@utils.hook("received.command.serverset",
|
@utils.hook("received.command.serverset",
|
||||||
help="Set a specified server setting for the current server")
|
help="Set a specified server setting for the current server")
|
||||||
@utils.hook("received.command.serversetadd",
|
|
||||||
help="Add to a specified server setting for the current server")
|
|
||||||
def server_set(self, event):
|
def server_set(self, event):
|
||||||
"""
|
"""
|
||||||
:usage: <setting> <value>
|
:usage: <setting> <value>
|
||||||
:permission: serverset
|
:permission: serverset
|
||||||
"""
|
"""
|
||||||
self._set("serverset", event, event["server"],
|
self._set("serverset", event, event["server"])
|
||||||
event["command"]=="serversetadd")
|
|
||||||
|
|
||||||
@utils.hook("received.command.botset", help="Set a specified bot setting")
|
@utils.hook("received.command.botset", help="Set a specified bot setting")
|
||||||
@utils.hook("received.command.botsetadd",
|
|
||||||
help="Add to a specified bot setting")
|
|
||||||
def bot_set(self, event):
|
def bot_set(self, event):
|
||||||
"""
|
"""
|
||||||
:help: Set a specified bot setting
|
:help: Set a specified bot setting
|
||||||
:usage: <setting> <value>
|
:usage: <setting> <value>
|
||||||
:permission: botset
|
:permission: botset
|
||||||
"""
|
"""
|
||||||
self._set("botset", event, self.bot, event["command"]=="botsetadd")
|
self._set("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:
|
||||||
|
|
Loading…
Reference in a new issue