annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3069
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2 module:hook("muc-config-form", function(event)
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 local room, form = event.room, event.form;
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 table.insert(form, {
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 name = "muc#roomconfig_lang",
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 type = "text-single",
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 label = "Natural Language for Room Discussions",
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 value = room._data.language,
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 });
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 end);
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 module:hook("muc-config-submitted", function(event)
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 local room, fields, changed = event.room, event.fields, event.changed;
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 local new = fields["muc#roomconfig_lang"];
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 if new ~= room._data.language then
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 room._data.archiving = new;
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 if type(changed) == "table" then
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18 changed["muc#roomconfig_lang"] = true;
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 else
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20 event.changed = true;
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 end
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 end
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 end);
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25 module:hook("muc-disco#info", function (event)
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
26 local room, form, formdata = event.room, event.form, event.formdata;
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
28 table.insert(form, {
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
29 name = "muc#roomconfig_lang",
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30 type = "text-single",
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
31 label = "Natural Language for Room Discussions",
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
32 value = room._data.language,
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
33 });
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
34 formdata["muc#roominfo_lang"] = room._data.language;
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
35 end);
e1db146984a0 mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff changeset
36