allow short names for config contexts. people mistook "user" as "put your

nickname here" so having just "u" might prevent this
This commit is contained in:
jesopo 2019-06-19 10:28:53 +01:00
parent 43108b96ba
commit d00d026461

View file

@ -46,13 +46,13 @@ class ConfigChannelTarget(object):
class Module(ModuleManager.BaseModule): class Module(ModuleManager.BaseModule):
def _to_context(self, server, channel, user, context_desc): def _to_context(self, server, channel, user, context_desc):
context_desc_lower = context_desc.lower() context_desc_lower = context_desc.lower()
if context_desc_lower == "user": if "user".startswith(context_desc_lower):
return user, "set" return user, "set"
elif context_desc_lower == "channel": elif "channel".startswith(context_desc_lower):
return channel, "channelset" return channel, "channelset"
elif context_desc_lower == "server": elif "server".startswith(context_desc_lower):
return server, "serverset" return server, "serverset"
elif context_desc_lower == "bot": elif "bot".startswith(context_desc_lower):
return self.bot, "botset" return self.bot, "botset"
else: else:
raise ValueError() raise ValueError()
@ -85,7 +85,7 @@ class Module(ModuleManager.BaseModule):
if value == None: if value == None:
example = setting_info.get("example", "<value>") example = setting_info.get("example", "<value>")
return "Please set %s, e.g.: %sconfig %s %s %s" % ( return "Please set %s, e.g.: %sconfig %s %s %s" % (
require_setting, event["command_prefix"], context, require_setting, event["command_prefix"], context[0],
require_setting, example) require_setting, example)
def _get_export_setting(self, context): def _get_export_setting(self, context):