bitbot-3.11-fork/modules/throttle.py

18 lines
645 B
Python
Raw Normal View History

2019-07-23 16:46:40 +00:00
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
2019-07-23 16:46:40 +00:00
@utils.export("serverset", utils.FunctionSetting(_parse, "throttle",
2019-07-23 16:46:40 +00:00
"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)