Further implementation of nested functions in interactions, including in consent module

This commit is contained in:
Nathan Schneider
2021-07-31 17:11:26 -06:00
parent 74263b252b
commit 4e10d74bff
3 changed files with 66 additions and 40 deletions

View File

@@ -41,12 +41,16 @@ end
-- ============================
-- interact function for the consent module
function modpol.modules.consent:interact(user)
local resp = modpol.interactions.binary_poll_user(user, "How do you vote?")
if resp == 'yes' then
self:approve(user, true)
elseif resp == 'no' then
self:approve(user, false)
end
-- TODO this needs more context on the vote at hand
modpol.interactions.binary_poll_user(
user, "How do you vote?",
function(vote)
if vote == 'yes' then
self:approve(user, true)
elseif vote == 'no' then
self:approve(user, false)
end
end)
end
-- =========================================
@@ -100,4 +104,4 @@ function modpol.modules.consent:update_status()
else
modpol.ocutil.log('Waiting for more votes...')
end
end
end