support per-channel dns nameservers

This commit is contained in:
jesopo 2019-09-02 14:23:51 +01:00
parent c80aab88f3
commit e1da095023

View file

@ -17,6 +17,8 @@ class DnsSetting(utils.Setting):
@utils.export("serverset", DnsSetting("dns-nameserver",
"Set DNS nameserver", example="8.8.8.8"))
@utils.export("channelset", DnsSetting("dns-nameserver",
"Set DNS nameserver", example="8.8.8.8"))
class Module(ModuleManager.BaseModule):
@utils.hook("received.command.dns", min_args=1)
def dns(self, event):
@ -26,7 +28,8 @@ class Module(ModuleManager.BaseModule):
:prefix: DNS
"""
args = event["args_split"][:]
nameserver = event["server"].get_setting("dns-nameserver", None)
nameserver = event["channel"].get_setting("dns-nameserver",
event["server"].get_setting("dns-nameserver", None))
for i, arg in enumerate(args):
if arg[0] == "@":
nameserver = args.pop(i)[1:]