aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2019-10-15 10:32:56 +0100
committerGravatar jesopo2019-10-15 10:33:13 +0100
commit124fc4fc424e018df6dec8ace912a7b38d207614 (patch)
treeb502614427f65f04dfbc2f0fe86c173c900ca194
parentfix type linting issues for `client` in Control.is_readable (diff)
signature
Set `duck_lines` to -1 when a duck is waiting to quack - do not allow bef/trap
closes #177
-rw-r--r--modules/ducks.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/modules/ducks.py b/modules/ducks.py
index 4bfb875c..945962a7 100644
--- a/modules/ducks.py
+++ b/modules/ducks.py
@@ -32,13 +32,15 @@ class Module(ModuleManager.BaseModule):
ducks_enabled = channel.get_setting("ducks-enabled", False)
- if ducks_enabled and not channel.duck_active:
+ if (ducks_enabled and
+ not channel.duck_active and
+ not channel.duck_lines == -1):
channel.duck_lines += 1
min_lines = channel.get_setting("ducks-min-messages",
DEFAULT_MIN_MESSAGES)
if channel.duck_lines >= min_lines:
- show_duck = random.SystemRandom().randint(1, 20) == 1
+ show_duck = random.SystemRandom().randint(1, 2) == 1
if show_duck:
self._trigger_duck(channel)
@@ -52,13 +54,15 @@ class Module(ModuleManager.BaseModule):
self._activity(event["target"])
def _trigger_duck(self, channel):
- channel.duck_lines = 0
+ channel.duck_lines = -1
delay = random.SystemRandom().randint(5, 20)
- channel.duck_active = time.time()+delay
self.timers.add("duck", self._send_duck, delay, channel=channel)
def _send_duck(self, timer):
- timer.kwargs["channel"].send_message(DUCK)
+ channel = timer.kwargs["channel"]
+ channel.duck_active = time.time()
+ channel.duck_lines = 0
+ channel.send_message(DUCK)
def _duck_action(self, channel, user, action, setting):
duck_timestamp = channel.duck_active