Comparison

plugins/muc/mod_muc.lua @ 8867:c601c834bf01

MUC: Add support for setting MUC room defaults from the config file Defaults are roughtly like this: muc_rooom_default_public = true muc_rooom_default_persistent = false muc_rooom_default_members_only = false muc_rooom_default_moderated = false muc_rooom_default_public_jids = false muc_rooom_default_change_subject = false muc_room_default_history_length = 20 muc_room_default_language = nil
author Kim Alvefur <zash@zash.se>
date Sun, 03 Jun 2018 14:43:06 +0200
parent 8865:2a8bbfcb6868
child 8868:b9e56f46916e
comparison
equal deleted inserted replaced
8866:2c60ae791bdc 8867:c601c834bf01
280 reply:tag("item", { jid = jid, name = room_name }):up(); 280 reply:tag("item", { jid = jid, name = room_name }):up();
281 end 281 end
282 end 282 end
283 end 283 end
284 end); 284 end);
285
286 module:hook("muc-room-pre-create", function (event)
287 local room = event.room;
288 room:set_public(module:get_option_boolean("muc_rooom_default_public", room:get_public()));
289 room:set_persistent(module:get_option_boolean("muc_rooom_default_persistent", room:get_persistent()));
290 room:set_members_only(module:get_option_boolean("muc_rooom_default_members_only", room:get_members_only()));
291 room:set_moderated(module:get_option_boolean("muc_rooom_default_moderated", room:get_moderated()));
292 room:set_whois(module:get_option_boolean("muc_rooom_default_public_jids", room:get_whois() == "anyone") and "anyone" or "moderators");
293 room:set_changesubject(module:get_option_boolean("muc_rooom_default_change_subject", room:get_changesubject()));
294 room:set_historylength(module:get_option_number("muc_room_default_history_length", room:get_historylength()));
295 room:set_language(module:get_option_string("muc_room_default_language"));
296 end, 1);
285 297
286 module:hook("muc-room-pre-create", function(event) 298 module:hook("muc-room-pre-create", function(event)
287 local origin, stanza = event.origin, event.stanza; 299 local origin, stanza = event.origin, event.stanza;
288 if not track_room(event.room) then 300 if not track_room(event.room) then
289 origin.send(st.error_reply(stanza, "wait", "resource-constraint")); 301 origin.send(st.error_reply(stanza, "wait", "resource-constraint"));