Protect vote against spammers

This commit is contained in:
rubenwardy 2016-01-02 16:10:52 +00:00
parent 2e895b8592
commit d6ad3ca3d9
2 changed files with 15 additions and 9 deletions

View file

@ -7,7 +7,7 @@ function ctf_match.register_on_skip_map(func)
end
function ctf_match.vote_next(name, params)
vote.new_vote(name, {
return vote.new_vote(name, {
description = "Skip to next match",
help = "/yes, /no or /abstain",
duration = 60,
@ -44,7 +44,10 @@ minetest.register_chatcommand("vote", {
minetest.register_on_chat_message(function(name, msg)
if msg == "/vote_next" then
ctf_match.vote_next(name)
local suc, msg = ctf_match.vote_next(name)
if msg then
minetest.chat_send_player(name, msg)
end
return true
end
end)

View file

@ -5,16 +5,19 @@ vote = {
function vote.new_vote(creator, voteset)
local max_votes = tonumber(minetest.setting_get("vote.maximum_active")) or 1
local max_queue = tonumber(minetest.setting_get("vote.maximum_active")) or 0
if #vote.active < max_votes then
vote.start_vote(voteset)
else
return true, "Vote Started. You still need to vote: " .. voteset.help
elseif max_queue == 0 then
return false, "A vote is already running, please try again later."
elseif #vote.queue < max_queue then
table.insert(vote.queue, voteset)
if creator then
minetest.chat_send_player(creator,
"Vote queued until there is less then " .. max_votes ..
" votes active.")
end
return true, "Vote queued until there is less then " .. max_votes ..
" votes active."
else
return false, "The queue of votes waiting to run is full. Please try again later."
end
end
@ -303,7 +306,7 @@ if set == nil or minetest.is_yes(set) then
return
end
vote.new_vote(name, {
return vote.new_vote(name, {
description = "Kick " .. param,
help = "/yes, /no or /abstain",
name = param,