From 355689bb3547b37f73ad64916bf2f7db6d99649c Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 8 Oct 2019 13:57:26 +0100 Subject: [PATCH] send ducks 5-20 seconds after the message that triggered it --- modules/ducks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/ducks.py b/modules/ducks.py index 8fb62ebf..0312f01d 100644 --- a/modules/ducks.py +++ b/modules/ducks.py @@ -52,7 +52,11 @@ class Module(ModuleManager.BaseModule): def _trigger_duck(self, channel): channel.duck_lines = 0 channel.duck_active = time.time() - channel.send_message(DUCK) + delay = random.SystemRandom().randint(5, 20) + self.timers.add("duck", self._send_duck, delay, channel=channel) + + def _send_duck(self, timer): + timer.kwargs["channel"].send_message(DUCK) def _duck_action(self, channel, user, action, setting): duck_timestamp = channel.duck_active