From 20df824f723334005d930ee9cd5d4f51d16f2d8e Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 20 Jun 2019 12:08:35 +0100 Subject: [PATCH] Make it configurable whether people need permission to start a vote --- modules/vote.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/vote.py b/modules/vote.py index 6a90e157..c80890a9 100644 --- a/modules/vote.py +++ b/modules/vote.py @@ -10,7 +10,9 @@ STR_NOVOTE = "Unknown vote '%s'" class VoteCastResult(enum.Enum): Cast = 1 Changed = 2 - +@utils.export("channelset", {"setting": "vote-start-restricted", + "help": "Whether starting a vote should be restricted to ops", + "validate": utils.bool_or_none, "example": "on"}) class Module(ModuleManager.BaseModule): def _get_vote(self, channel, vote_id): return channel.get_setting("vote-%s" % vote_id, None) @@ -72,9 +74,12 @@ class Module(ModuleManager.BaseModule): """ :help: Start a vote :usage: - :require_mode: o - :permission: vote """ + + if event["target"].get_setting("vote-start-restricted", True): + event["check_assert"](utils.Check("channel-mode", "o")| + utils.Check("permission", "vote")) + vote = self._start_vote(event["target"], event["args"]) event["stdout"].write( "Vote %s started. use '%svote