Mercurial > prosody-modules
comparison mod_muc_moderation_delay/mod_muc_moderation_delay.lua @ 5938:959382fac20c
mod_muc_moderation_delay: first commit to prosody-modules.
| author | John Livingston <git@john-livingston.fr> |
|---|---|
| date | Fri, 26 Jul 2024 15:36:05 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 5937:da942a3f3660 | 5938:959382fac20c |
|---|---|
| 1 -- mod_muc_moderation_delay | |
| 2 -- | |
| 3 -- SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/> | |
| 4 -- SPDX-License-Identifier: AGPL-3.0-only | |
| 5 -- | |
| 6 -- This file is AGPL-v3 licensed. | |
| 7 -- Please see the Peertube livechat plugin copyright information. | |
| 8 -- https://livingston.frama.io/peertube-plugin-livechat/credits/ | |
| 9 -- | |
| 10 | |
| 11 local add_disco_form = module:require("config").add_disco_form; | |
| 12 local config_submitted = module:require("config").config_submitted; | |
| 13 local add_form_option = module:require("config").add_form_option; | |
| 14 local handle_broadcast_message = module:require("delay").handle_broadcast_message; | |
| 15 | |
| 16 -- form_position: the position in the room config form (this value will be passed as priority for the "muc-config-form" hook). | |
| 17 -- By default, field will be between muc#roomconfig_changesubject and muc#roomconfig_moderatedroom | |
| 18 local form_position = module:get_option_number("moderation_delay_form_position") or 80-2; | |
| 19 | |
| 20 -- Plugin dependencies | |
| 21 local mod_muc = module:depends "muc"; | |
| 22 | |
| 23 -- muc-disco and muc-config to configure the feature: | |
| 24 module:hook("muc-disco#info", add_disco_form); | |
| 25 module:hook("muc-config-submitted/muc#roomconfig_moderation_delay", config_submitted); | |
| 26 module:hook("muc-config-form", add_form_option, form_position); | |
| 27 | |
| 28 -- intercept muc-broadcast-message, and broadcast with delay if required. | |
| 29 -- Priority is negative, as we want it to be the last handler. | |
| 30 module:hook("muc-broadcast-message", handle_broadcast_message, -1000); |
