Mercurial > prosody-modules
comparison mod_muc_lang/mod_muc_lang.lua @ 3069:e1db146984a0
mod_muc_lang: Advertises the room language
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 30 May 2018 08:40:59 +0200 |
parents | |
children | ef8fe8bec5b1 |
comparison
equal
deleted
inserted
replaced
3068:380f92276e57 | 3069:e1db146984a0 |
---|---|
1 | |
2 module:hook("muc-config-form", function(event) | |
3 local room, form = event.room, event.form; | |
4 table.insert(form, { | |
5 name = "muc#roomconfig_lang", | |
6 type = "text-single", | |
7 label = "Natural Language for Room Discussions", | |
8 value = room._data.language, | |
9 }); | |
10 end); | |
11 | |
12 module:hook("muc-config-submitted", function(event) | |
13 local room, fields, changed = event.room, event.fields, event.changed; | |
14 local new = fields["muc#roomconfig_lang"]; | |
15 if new ~= room._data.language then | |
16 room._data.archiving = new; | |
17 if type(changed) == "table" then | |
18 changed["muc#roomconfig_lang"] = true; | |
19 else | |
20 event.changed = true; | |
21 end | |
22 end | |
23 end); | |
24 | |
25 module:hook("muc-disco#info", function (event) | |
26 local room, form, formdata = event.room, event.form, event.formdata; | |
27 | |
28 table.insert(form, { | |
29 name = "muc#roomconfig_lang", | |
30 type = "text-single", | |
31 label = "Natural Language for Room Discussions", | |
32 value = room._data.language, | |
33 }); | |
34 formdata["muc#roominfo_lang"] = room._data.language; | |
35 end); | |
36 |