add +time param to !silence

This commit is contained in:
jesopo 2019-09-09 18:06:27 +01:00
parent 695c7982a6
commit 0c5171a44f

View file

@ -17,13 +17,24 @@ class Module(ModuleManager.BaseModule):
return False return False
@utils.hook("received.command.silence", channel_only=True) @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): def silence(self, event):
""" """
:help: Silence me for 5 minutes :help: Silence me for 5 minutes
:require_mode: high :require_mode: high
:permission: silence :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["target"].set_setting("silence-until", silence_until)
event["stdout"].write("Ok, I'll be back") event["stdout"].write("Ok, I'll be back")