Add nickserv-password and sasl to !serverset

This commit is contained in:
jesopo 2018-09-09 10:04:21 +01:00 committed by Dan
parent c3ebb32111
commit 2fa7d9b8a9
2 changed files with 13 additions and 11 deletions

View file

@ -3,12 +3,11 @@ import EventManager
class Module(object):
def __init__(self, bot, events, exports):
events.on("received").on("numeric").on("001"
).hook(self.on_connect, priority=EventManager.PRIORITY_URGENT)
events.on("received").on("command").on("setnickserv"
).hook(self.set_nickserv, min_args=1, permission="setnickserv",
help="Set bot's nickserv password", usage="<password>",
private_only=True)
events.on("received").on("numeric").on("001").hook(self.on_connect,
priority=EventManager.PRIORITY_URGENT)
exports.add("serverset", {"setting": "nickserv-password",
"help": "Set the nickserv password for this server"})
def on_connect(self, event):
nickserv_password = event["server"].get_setting(
@ -17,8 +16,3 @@ class Module(object):
event["server"].attempted_auth = True
event["server"].send_message("nickserv",
"identify %s" % nickserv_password)
def set_nickserv(self, event):
nickserv_password = event["args"]
event["server"].set_setting("nickserv-password", nickserv_password)
event["stdout"].write("Nickserv password saved")

View file

@ -8,6 +8,14 @@ class Module(object):
events.on("received.authenticate").hook(self.on_authenticate)
events.on("received.numeric.903").hook(self.sasl_success)
exports.add("serverset", {"setting": "sasl",
"help": "Set the sasl username/password for this server",
"validate": self._validate})
def _validate(self, s):
if " " in s:
return s.split(" ", 1)
def on_cap(self, event):
has_sasl = "sasl" in event["capabilities"]
has_mechanisms = has_sasl and not event["capabilities"]["sasl"