switch throttle.py to use FunctionSetting

This commit is contained in:
jesopo 2019-09-04 12:11:22 +01:00
parent 007bb78d30
commit 43fab6777c

View file

@ -1,13 +1,12 @@
from src import ModuleManager, utils from src import ModuleManager, utils
class ThrottleSetting(utils.Setting): def _parse(value):
def parse(self, value): lines, _, seconds = value.partition(":")
lines, _, seconds = value.partition(":") if lines.isdigit() and seconds.isdigit():
if lines.isdigit() and seconds.isdigit(): return [int(lines), int(seconds)]
return [int(lines), int(seconds)] return None
return None
@utils.export("serverset", ThrottleSetting("throttle", @utils.export("serverset", utils.FunctionSetting(_parse, "throttle",
"Configure lines:seconds throttle for the current server", example="4:2")) "Configure lines:seconds throttle for the current server", example="4:2"))
class Module(ModuleManager.BaseModule): class Module(ModuleManager.BaseModule):
@utils.hook("received.001") @utils.hook("received.001")