Fix indentation.
This commit is contained in:
parent
f452c3529c
commit
92af46641e
@ -32,21 +32,21 @@ local form_position = module:get_option_number("slow_mode_delay_form_position")
|
|||||||
|
|
||||||
-- Getter/Setter
|
-- Getter/Setter
|
||||||
local function get_slow_mode_delay(room)
|
local function get_slow_mode_delay(room)
|
||||||
return room._data.slow_mode_delay or 0;
|
return room._data.slow_mode_delay or 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
local function set_slow_mode_delay(room, delay)
|
local function set_slow_mode_delay(room, delay)
|
||||||
if delay then
|
if delay then
|
||||||
delay = assert(tonumber(delay), "Slow mode delay is not a valid number");
|
delay = assert(tonumber(delay), "Slow mode delay is not a valid number");
|
||||||
end
|
end
|
||||||
if delay and delay < 0 then
|
if delay and delay < 0 then
|
||||||
delay = 0;
|
delay = 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
if get_slow_mode_delay(room) == delay then return false; end
|
if get_slow_mode_delay(room) == delay then return false; end
|
||||||
|
|
||||||
room._data.slow_mode_delay = delay;
|
room._data.slow_mode_delay = delay;
|
||||||
return true;
|
return true;
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Discovering support
|
-- Discovering support
|
||||||
@ -65,7 +65,7 @@ local function add_form_option(event)
|
|||||||
table.insert(event.form, {
|
table.insert(event.form, {
|
||||||
name = "muc#roomconfig_slow_mode_delay";
|
name = "muc#roomconfig_slow_mode_delay";
|
||||||
type = "text-single";
|
type = "text-single";
|
||||||
datatype = "xs:integer";
|
datatype = "xs:integer";
|
||||||
label = "Slow Mode (0=disabled, any positive integer= minimal delay in seconds between two messages from the same user)";
|
label = "Slow Mode (0=disabled, any positive integer= minimal delay in seconds between two messages from the same user)";
|
||||||
desc = "Minimal delay, in seconds, between two messages for the same user in the room. If value is set to 0, the slow mode is not active.";
|
desc = "Minimal delay, in seconds, between two messages for the same user in the room. If value is set to 0, the slow mode is not active.";
|
||||||
value = get_slow_mode_delay(event.room);
|
value = get_slow_mode_delay(event.room);
|
||||||
@ -73,10 +73,10 @@ local function add_form_option(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
module:hook("muc-config-submitted/muc#roomconfig_slow_mode_delay", function(event)
|
module:hook("muc-config-submitted/muc#roomconfig_slow_mode_delay", function(event)
|
||||||
if set_slow_mode_delay(event.room, event.value) then
|
if set_slow_mode_delay(event.room, event.value) then
|
||||||
-- status 104 = configuration change: Inform occupants that a non-privacy-related room configuration change has occurred
|
-- status 104 = configuration change: Inform occupants that a non-privacy-related room configuration change has occurred
|
||||||
event.status_codes["104"] = true;
|
event.status_codes["104"] = true;
|
||||||
end
|
end
|
||||||
end);
|
end);
|
||||||
|
|
||||||
module:hook("muc-config-form", add_form_option, form_position);
|
module:hook("muc-config-form", add_form_option, form_position);
|
||||||
@ -94,16 +94,16 @@ function handle_groupchat(event)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Checking user's permissions (moderators are not subject to slow mode)
|
-- Checking user's permissions (moderators are not subject to slow mode)
|
||||||
local actor = stanza.attr.from;
|
local actor = stanza.attr.from;
|
||||||
local actor_nick = room:get_occupant_jid(actor);
|
local actor_nick = room:get_occupant_jid(actor);
|
||||||
local actor_jid = jid_bare(actor);
|
local actor_jid = jid_bare(actor);
|
||||||
-- Only checking role, not affiliation (slow mode only applies on users currently connected to the room)
|
-- Only checking role, not affiliation (slow mode only applies on users currently connected to the room)
|
||||||
local role = room:get_role(actor_nick);
|
local role = room:get_role(actor_nick);
|
||||||
if valid_roles[role or "none"] >= valid_roles.moderator then
|
if valid_roles[role or "none"] >= valid_roles.moderator then
|
||||||
-- user bypasses the slow mode.
|
-- user bypasses the slow mode.
|
||||||
-- module:log("debug", "User is moderator, bypassing slow mode");
|
-- module:log("debug", "User is moderator, bypassing slow mode");
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
if not room.slow_mode_last_messages then
|
if not room.slow_mode_last_messages then
|
||||||
-- We store last message time for each users in room.slow_mode_last_messages:
|
-- We store last message time for each users in room.slow_mode_last_messages:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user