From 7922f6e9a5e1a71bb6884cd1c8ef3ef2e38824ab Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 13 May 2019 20:50:31 +0100 Subject: Added !silence, to silence the bot in a channel for 5 mins --- modules/silence.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 modules/silence.py (limited to 'modules') diff --git a/modules/silence.py b/modules/silence.py new file mode 100644 index 00000000..3621b501 --- /dev/null +++ b/modules/silence.py @@ -0,0 +1,25 @@ +import time +from src import ModuleManager, utils + +SILENCE_TIME = 60*5 # 5 minutes + +class Module(ModuleManager.BaseModule): + @utils.hook("received.command.silence", channel_only=True) + def silence(self, event): + """ + :help: Silence me for 5 minutes + :require_mode: high + """ + silence_until = time.time()+SILENCE_TIME + event["target"].set_setting("silence-until", silence_until) + event["stdout"].write("Ok, I'll be back") + + @utils.hook("preprocess.command") + def preprocess_command(self, event): + if event["is_channel"]: + silence_until = event["target"].get_setting("silence-until", None) + if silence_until: + if time.time()