update !silence to use command specs
This commit is contained in:
parent
8c76f24c65
commit
22af5fae46
1 changed files with 2 additions and 9 deletions
|
@ -20,21 +20,14 @@ class Module(ModuleManager.BaseModule):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@utils.hook("received.command.silence")
|
@utils.hook("received.command.silence")
|
||||||
@utils.kwarg("channel_only", True)
|
|
||||||
@utils.kwarg("help", "Prevent me saying anything for a period of time "
|
@utils.kwarg("help", "Prevent me saying anything for a period of time "
|
||||||
"(default: 5 minutes)")
|
"(default: 5 minutes)")
|
||||||
@utils.kwarg("usage", "[+time]")
|
|
||||||
@utils.kwarg("require_mode", "high")
|
@utils.kwarg("require_mode", "high")
|
||||||
@utils.kwarg("require_access", "low,silence")
|
@utils.kwarg("require_access", "low,silence")
|
||||||
@utils.kwarg("permission", "silence")
|
@utils.kwarg("permission", "silence")
|
||||||
|
@utils.spec("!-channelonly ?duration")
|
||||||
def silence(self, event):
|
def silence(self, event):
|
||||||
duration = SILENCE_TIME
|
duration = event["spec"][0] or SILENCE_TIME
|
||||||
if event["args"] and event["args_split"][0].startswith("+"):
|
|
||||||
duration = utils.datetime.parse.from_pretty_time(
|
|
||||||
event["args_split"][0][1:])
|
|
||||||
if duration == None:
|
|
||||||
raise utils.EventError("Invalid duration provided")
|
|
||||||
|
|
||||||
silence_until = time.time()+duration
|
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")
|
||||||
|
|
Loading…
Reference in a new issue