Add !serverset and !serverget
This commit is contained in:
parent
561dcdf799
commit
87ff49c4d2
2 changed files with 24 additions and 8 deletions
|
@ -64,13 +64,15 @@ class Module(object):
|
||||||
help="Unignore commands from a given user", usage="<nickname>",
|
help="Unignore commands from a given user", usage="<nickname>",
|
||||||
permission="unignore")
|
permission="unignore")
|
||||||
|
|
||||||
exports.add("channelset", {"setting": "command-prefix",
|
|
||||||
"help": "Set the command prefix used in this channel"})
|
|
||||||
|
|
||||||
events.on("new").on("user", "channel").hook(self.new)
|
events.on("new").on("user", "channel").hook(self.new)
|
||||||
events.on("send").on("stdout").hook(self.send_stdout)
|
events.on("send").on("stdout").hook(self.send_stdout)
|
||||||
events.on("send").on("stderr").hook(self.send_stderr)
|
events.on("send").on("stderr").hook(self.send_stderr)
|
||||||
|
|
||||||
|
exports.add("channelset", {"setting": "command-prefix",
|
||||||
|
"help": "Set the command prefix used in this channel"})
|
||||||
|
exports.add("serverset", {"setting": "identity-mechanism",
|
||||||
|
"help": "Set the identity mechanism for this server"})
|
||||||
|
|
||||||
def new(self, event):
|
def new(self, event):
|
||||||
if "user" in event:
|
if "user" in event:
|
||||||
target = event["user"]
|
target = event["user"]
|
||||||
|
|
|
@ -22,6 +22,13 @@ class Module(object):
|
||||||
require_mode="o", help="Get a specified setting for the current "
|
require_mode="o", help="Get a specified setting for the current "
|
||||||
"channel")
|
"channel")
|
||||||
|
|
||||||
|
events.on("received.command.serverset").hook(self.server_set,
|
||||||
|
usage="<setting> <value>", permission="serverset",
|
||||||
|
help="Set a specified setting for the current server")
|
||||||
|
events.on("received.command.serverget").hook(self.server_get,
|
||||||
|
usage="<setting>", min_args=1, permission="serverget",
|
||||||
|
help="Get a specified setting for the current server")
|
||||||
|
|
||||||
def _set(self, settings, event, target):
|
def _set(self, settings, event, target):
|
||||||
settings_dict = dict([(setting["setting"], setting
|
settings_dict = dict([(setting["setting"], setting
|
||||||
) for setting in settings])
|
) for setting in settings])
|
||||||
|
@ -47,8 +54,10 @@ class Module(object):
|
||||||
self._set(self.exports.get_all("set"), event, event["user"])
|
self._set(self.exports.get_all("set"), event, event["user"])
|
||||||
|
|
||||||
def channel_set(self, event):
|
def channel_set(self, event):
|
||||||
self._set(self.exports.get_all("channelset"), event,
|
self._set(self.exports.get_all("channelset"), event, event["target"])
|
||||||
event["target"])
|
|
||||||
|
def server_set(self, event):
|
||||||
|
self._set(self.exports.get_all("serverset"), event, event["server"])
|
||||||
|
|
||||||
def _get(self, event, setting, qualifier, value):
|
def _get(self, event, setting, qualifier, value):
|
||||||
if not value == None:
|
if not value == None:
|
||||||
|
@ -57,12 +66,17 @@ class Module(object):
|
||||||
else:
|
else:
|
||||||
event["stdout"].write("'%s' has no value set" % setting)
|
event["stdout"].write("'%s' has no value set" % setting)
|
||||||
|
|
||||||
|
def get(self, event):
|
||||||
|
setting = event["args_split"][0]
|
||||||
|
self._get(event, setting, "", event["user"].get_setting(
|
||||||
|
setting, None))
|
||||||
|
|
||||||
def channel_get(self, event):
|
def channel_get(self, event):
|
||||||
setting = event["args_split"][0]
|
setting = event["args_split"][0]
|
||||||
self._get(event, setting, " for %s" % event["target"].name,
|
self._get(event, setting, " for %s" % event["target"].name,
|
||||||
event["target"].get_setting(setting, None))
|
event["target"].get_setting(setting, None))
|
||||||
|
|
||||||
def get(self, event):
|
def server_get(self, event):
|
||||||
setting = event["args_split"][0]
|
setting = event["args_split"][0]
|
||||||
self._get(event, setting, "", event["user"].get_setting(
|
self._get(event, setting, " for %s" % event["server"].name,
|
||||||
setting, None))
|
event["server"].get_setting(setting, None))
|
||||||
|
|
Loading…
Reference in a new issue