Pārlūkot izejas kodu

Added message_org module

Nathan Schneider 2 gadi atpakaļ
vecāks
revīzija
fe2d5fdb2a

+ 1 - 0
modpol_core/api.lua

@@ -16,6 +16,7 @@ dofile (localdir .. "/modules/change_modules.lua")
 dofile (localdir .. "/modules/consent.lua")
 dofile (localdir .. "/modules/join_org_consent.lua")
 dofile (localdir .. "/modules/leave_org.lua")
+dofile (localdir .. "/modules/message_org.lua")
 dofile (localdir .. "/modules/remove_child_consent.lua")
 dofile (localdir .. "/modules/remove_member_consent.lua")
 dofile (localdir .. "/modules/remove_org_consent.lua")

+ 38 - 0
modpol_core/modules/message_org.lua

@@ -0,0 +1,38 @@
+--- message_org
+-- @module message_org
+
+local message_org = {
+    name = "Message org",
+    slug = "message_org",
+    desc = "Send a message to all members of the org",
+    hide = false;
+}
+
+message_org.data = {
+}
+
+message_org.config = {
+}
+
+-- @function initiate
+function message_org:initiate(result)
+   modpol.interactions.text_query(
+      self.initiator, "Message to all org members: ",
+      function(input)
+         local message = self.initiator.." to org "..
+            self.org.name..": "..input
+         if input and input ~= "" then
+            modpol.interactions.message_org(
+               self.initiator, self.org.id, message)
+         end
+         modpol.interactions.org_dashboard(
+            self.initiator, self.org.id)
+
+      end
+   )
+   if result then result() end
+   self.org:delete_process(self.id)
+end
+
+--- (Required) Add to module table
+modpol.modules.message_org = message_org

+ 1 - 1
modpol_core/modules/template.lua

@@ -8,7 +8,7 @@
 -- @field hide "Whether this is a hidden utility module"
 local module_template = {
     name = "Module Human-Readable Name",
-    slug = "template",
+    slug = "module_template",
     desc = "Description of the module",
     hide = false;
 }