Add nickserv-password and sasl to !serverset
This commit is contained in:
parent
2346eeffd0
commit
8b7cecda04
2 changed files with 13 additions and 11 deletions
|
@ -3,12 +3,11 @@ import EventManager
|
||||||
|
|
||||||
class Module(object):
|
class Module(object):
|
||||||
def __init__(self, bot, events, exports):
|
def __init__(self, bot, events, exports):
|
||||||
events.on("received").on("numeric").on("001"
|
events.on("received").on("numeric").on("001").hook(self.on_connect,
|
||||||
).hook(self.on_connect, priority=EventManager.PRIORITY_URGENT)
|
priority=EventManager.PRIORITY_URGENT)
|
||||||
events.on("received").on("command").on("setnickserv"
|
|
||||||
).hook(self.set_nickserv, min_args=1, permission="setnickserv",
|
exports.add("serverset", {"setting": "nickserv-password",
|
||||||
help="Set bot's nickserv password", usage="<password>",
|
"help": "Set the nickserv password for this server"})
|
||||||
private_only=True)
|
|
||||||
|
|
||||||
def on_connect(self, event):
|
def on_connect(self, event):
|
||||||
nickserv_password = event["server"].get_setting(
|
nickserv_password = event["server"].get_setting(
|
||||||
|
@ -17,8 +16,3 @@ class Module(object):
|
||||||
event["server"].attempted_auth = True
|
event["server"].attempted_auth = True
|
||||||
event["server"].send_message("nickserv",
|
event["server"].send_message("nickserv",
|
||||||
"identify %s" % nickserv_password)
|
"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")
|
|
||||||
|
|
|
@ -8,6 +8,14 @@ class Module(object):
|
||||||
events.on("received.authenticate").hook(self.on_authenticate)
|
events.on("received.authenticate").hook(self.on_authenticate)
|
||||||
events.on("received.numeric.903").hook(self.sasl_success)
|
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):
|
def on_cap(self, event):
|
||||||
has_sasl = "sasl" in event["capabilities"]
|
has_sasl = "sasl" in event["capabilities"]
|
||||||
has_mechanisms = has_sasl and not event["capabilities"]["sasl"
|
has_mechanisms = has_sasl and not event["capabilities"]["sasl"
|
||||||
|
|
Loading…
Reference in a new issue