12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- --- leave_org
- -- @module leave_org
- local leave_org = {
- name = "Leave org",
- slug = "leave_org",
- desc = "Leave this org"
- }
- leave_org.data = {
- }
- leave_org.config = {
- }
- --- (Required): initiate function
- -- Modules have access to the following instance variables:
- -- <li><code>self.org</code> (the org the module was called in),</li>
- -- <li><code>self.initiator</code> (the user that callced the module),</li>
- -- <li><code>self.id</code> (the process id of the module instance)</li>
- -- @param config (optional) If user wants to override fields in the config table
- -- @param result (optional) Callback if this module is embedded in other modules
- -- @function initiate
- function leave_org:initiate(config, result)
- if self.org == modpol.instance then
- modpol.interactions.message(
- self.initiator,
- "You cannot leave the root org")
- else
- self.org:remove_member(self.initiator)
- modpol.interactions.message_org(
- self.initiator,self.org.id,
- self.initiator .. " has left org " .. self.org.name)
- modpol.interactions.message(
- self.initiator,
- "You have left org " .. self.org.name)
- -- call result function
- end
- if result then result() end
- end
- --- (Required) Add to module table
- modpol.modules.leave_org = leave_org
|