aboutsummaryrefslogtreecommitdiff
path: root/modules/ircv3_sasl
diff options
context:
space:
mode:
authorGravatar jesopo2019-06-28 23:16:05 +0100
committerGravatar jesopo2019-06-28 23:16:05 +0100
commitae9d099a41b703ce875cf8746a94b6995bbaedfb (patch)
treec389ae3b967c43055a1c671b8cebf04db4e8f8b6 /modules/ircv3_sasl
parentmessage arg for HTTPWrongContentTypeException/HTTPParsingException (diff)
Refactor set/channelset/serverset/botset in to 'utils.Setting' objects
Diffstat (limited to 'modules/ircv3_sasl')
-rw-r--r--modules/ircv3_sasl/__init__.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/modules/ircv3_sasl/__init__.py b/modules/ircv3_sasl/__init__.py
index c86796b0..b93c9b07 100644
--- a/modules/ircv3_sasl/__init__.py
+++ b/modules/ircv3_sasl/__init__.py
@@ -1,6 +1,6 @@
#--depends-on config
-import base64, hashlib, hmac, uuid
+import base64, hashlib, hmac, typing, uuid
from src import ModuleManager, utils
from . import scram
@@ -13,16 +13,16 @@ USERPASS_MECHANISMS = [
"PLAIN"
]
-def _validate(s):
- mechanism, _, arguments = s.partition(" ")
- return {"mechanism": mechanism, "args": arguments}
+class SaslSetting(utils.Setting):
+ def parse(self, value: str) -> typing.Any:
+ mechanism, _, arguments = value.partition(" ")
+ return {"mechanism": mechanism, "args": arguments}
-@utils.export("serverset", {"setting": "sasl",
- "help": "Set the sasl username/password for this server",
- "validate": _validate, "example": "PLAIN BitBot:hunter2"})
-@utils.export("serverset", {"setting": "sasl-hard-fail",
- "help": "Set whether a SASL failure should cause a disconnect",
- "validate": utils.bool_or_none, "example": "on"})
+@utils.export("serverset", SaslSetting("sasl",
+ "Set the sasl username/password for this server",
+ example="PLAIN BitBot:hunter2"))
+@utils.export("serverset", utils.BoolSetting("sasl-hard-fail",
+ "Set whether a SASL failure should cause a disconnect"))
class Module(ModuleManager.BaseModule):
def _best_userpass_mechanism(self, mechanisms):
for potential_mechanism in USERPASS_MECHANISMS: