diff options
| author | 2019-07-23 17:46:40 +0100 | |
|---|---|---|
| committer | 2019-07-23 17:46:40 +0100 | |
| commit | a27aa6f7d8cee0face5677daabdfd472d910d3ae (patch) | |
| tree | cf71e9494da59ecff524c79018405d6bb83ec795 /modules/throttle.py | |
| parent | add set_throttle(lines, seconds) function to tweak throttle per-server (diff) | |
| signature | ||
add throttle.py
closes #101
Diffstat (limited to 'modules/throttle.py')
| -rw-r--r-- | modules/throttle.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/modules/throttle.py b/modules/throttle.py new file mode 100644 index 00000000..6104b32d --- /dev/null +++ b/modules/throttle.py @@ -0,0 +1,18 @@ +from src import ModuleManager, utils + +class ThrottleSetting(utils.Setting): + def parse(self, value): + lines, _, seconds = value.partition(":") + if lines.isdigit() and seconds.isdigit(): + return [int(lines), int(seconds)] + return None + +@utils.export("serverset", ThrottleSetting("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) |
