Further implementation of nested functions in interactions, including in consent module
This commit is contained in:
@@ -172,3 +172,16 @@ function modpol.interactions.binary_poll_user(user, question, func)
|
||||
modpol.interactions.message(user, "Error: invalid response")
|
||||
end
|
||||
end
|
||||
|
||||
-- COMPLEX INTERACTIONS
|
||||
-- ====================
|
||||
|
||||
-- Function: modpol.interactions.message_org
|
||||
-- input: initiator (string), org_id (number), message (string)
|
||||
-- output: broadcasts message to all org members
|
||||
|
||||
-- Function: modpol.interactions.binary_poll_org
|
||||
-- input: initator (user string), org_id (number)
|
||||
-- output: gets question from initiator, asks all org members, broadcasts answers
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user