From 0fbf9932016f64552d7b5a942a1a0d9fd7e9834e Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 13 May 2019 20:57:47 +0100 Subject: [PATCH] Expose is-silenced through Exports, use it in karma.py --- modules/karma.py | 4 ++++ modules/silence.py | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/karma.py b/modules/karma.py index c05edec7..ccab1fcf 100644 --- a/modules/karma.py +++ b/modules/karma.py @@ -34,6 +34,10 @@ class Module(ModuleManager.BaseModule): if is_ignored_f(event["server"], event["user"], "karma"): return + if_silenced_f = self.exports.get_one("is-silenced", lambda _: False) + if is_silenced_f(event["channel"]): + return + verbose = event["channel"].get_setting("karma-verbose", False) nickname_only = event["server"].get_setting("karma-nickname-only", False) diff --git a/modules/silence.py b/modules/silence.py index 3621b501..89b99bac 100644 --- a/modules/silence.py +++ b/modules/silence.py @@ -4,6 +4,15 @@ from src import ModuleManager, utils SILENCE_TIME = 60*5 # 5 minutes class Module(ModuleManager.BaseModule): + def on_load(self): + self.exports.add("is-silenced", self._is_silenced) + + def _is_silenced(self, target): + silence_until = target.get_setting("silence-until", None) + if silence_until and time.time()