allow per-server default mumble servers

closes #151
This commit is contained in:
jesopo 2019-09-17 10:58:02 +01:00
parent e77124604c
commit 141b326d5a

View file

@ -12,21 +12,21 @@ def _parse(s):
port = srt(DEFAULT_PORT) port = srt(DEFAULT_PORT)
return "%s:%s" % (host, port) return "%s:%s" % (host, port)
@utils.export("channelset", utils.FunctionSetting(_parse, "mumble-server", SETTING = utils.FunctionSetting(_parse, "mumble-server",
"Set the mumble server for this channel", "Set the mumble server for this channel",
example="example.com:%s" % DEFAULT_PORT)) example="example.com:%s" % DEFAULT_PORT)
@utils.export("channelset", SETTING)
@utils.export("serverset", SETTING)
class Module(ModuleManager.BaseModule): class Module(ModuleManager.BaseModule):
@utils.hook("received.command.mumble") @utils.hook("received.command.mumble")
@utils.kwarg("help", "Get user and bandwidth stats for a mumble server") @utils.kwarg("help", "Get user and bandwidth stats for a mumble server")
@utils.kwarg("usage", "[server[:<port>]]") @utils.kwarg("usage", "[server[:<port>]]")
def mumble(self, event): def mumble(self, event):
server = None server = None
if not event["args"] and event["is_channel"]: if not event["args"]:
server_setting = event["target"].get_setting("mumble-server", None) server = event["target"].get_setting("mumble-server",
if server_setting == None: event["server"].get_setting("mumble-server", None))
raise utils.EventError(
"This channel does not have a mumble server configured")
server = server_setting
elif event["args"]: elif event["args"]:
server = event["args_split"][0] server = event["args_split"][0]
if not server: if not server: