From 0c5171a44f9095fb04e7660905e3da65c96d7eac Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 9 Sep 2019 18:06:27 +0100 Subject: [PATCH] add +time param to !silence --- modules/silence.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/silence.py b/modules/silence.py index 4dda2894..895644d1 100644 --- a/modules/silence.py +++ b/modules/silence.py @@ -17,13 +17,24 @@ class Module(ModuleManager.BaseModule): return False @utils.hook("received.command.silence", channel_only=True) + @utils.kwarg("help", "Prevent me saying anything for a period of time " + "(default: 5 minutes)") + @utils.kwarg("usage", "[+time]") + @utils.kwarg("require_mode", "high") + @utils.kwarg("permission", "silence") def silence(self, event): """ :help: Silence me for 5 minutes :require_mode: high :permission: silence """ - silence_until = time.time()+SILENCE_TIME + duration = SILENCE_TIME + if event["args"] and event["args_split"][0].startswith("+"): + duration = utils.from_pretty_time(event["args_split"][0][1:]) + if duration == None: + raise utils.EventError("Invalid duration provided") + + silence_until = time.time()+duration event["target"].set_setting("silence-until", silence_until) event["stdout"].write("Ok, I'll be back")