diff options
| author | 2019-12-10 05:27:35 +0000 | |
|---|---|---|
| committer | 2019-12-10 05:27:35 +0000 | |
| commit | 638eee0d685c06d258cb55287204ca97bca7c344 (patch) | |
| tree | 33442439317ae2846f1efb7674b7a3758c8990a1 /src/core_modules/throttle.py | |
| parent | move sys.exit() codes to an enum in utils.consts (diff) | |
| signature | ||
move core modules to src/core_modules, make them uneffected by white/black list
Diffstat (limited to 'src/core_modules/throttle.py')
| -rw-r--r-- | src/core_modules/throttle.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/core_modules/throttle.py b/src/core_modules/throttle.py new file mode 100644 index 00000000..e204cc34 --- /dev/null +++ b/src/core_modules/throttle.py @@ -0,0 +1,17 @@ +from src import ModuleManager, utils + +def _parse(value): + lines, _, seconds = value.partition(":") + if lines.isdigit() and seconds.isdigit(): + return [int(lines), int(seconds)] + return None + +@utils.export("serverset", utils.FunctionSetting(_parse, "throttle", + "Configure lines:seconds throttle for the current server", example="4:2")) +class Module(ModuleManager.BaseModule): + @utils.hook("received.001") + def connect(self, event): + throttle = event["server"].get_setting("throttle", None) + if throttle: + lines, seconds = throttle + event["server"].socket.set_throttle(lines, seconds) |
