From 3adc445e5bef3f54182715f6838ccd49ffb37a5a Mon Sep 17 00:00:00 2001 From: CMDR furrycat Date: Fri, 1 Sep 2017 08:01:19 +0100 Subject: [PATCH] Require a minute between typing. --- plugin/typing/typing.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/typing/typing.py b/plugin/typing/typing.py index 47f9309..5bb23a8 100644 --- a/plugin/typing/typing.py +++ b/plugin/typing/typing.py @@ -10,6 +10,7 @@ class Typing(object): self.threshold = 6 # In how long? self.ttl = datetime.timedelta(0, 90) + self.min_ttl = datetime.timedelta(0, 60) self.probability = 0.1 self.cache = {} self.cleaned_up = datetime.datetime.utcnow() @@ -57,7 +58,7 @@ class Typing(object): key = self.key(user, channel) times = self.times(key) times.append(when) - if len(times) > self.threshold: + if len(times) > self.threshold and max(times) - min(times) >= self.min_ttl: await bot.maybe_say(channel, '**{}** is typing ...'.format(user.nick if user.nick is not None else user.name), probability = self.probability) self.cleanup() else: -- 2.7.4