Software /
code /
prosody-modules
Annotate
mod_muc_lang/mod_muc_lang.lua @ 3180:00034d0cc05a
mod_profile: Reformat README
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 12 Jul 2018 21:07:10 +0200 |
parent | 3076:091b042cada0 |
child | 3546:ef5d52ca31bb |
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 |
3073
ef8fe8bec5b1
mod_muc_lang: Fix to use correct data field
Kim Alvefur <zash@zash.se>
parents:
3069
diff
changeset
|
16 room._data.language = new; |
3069
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, { |
3074
57396a32fc05
mod_muc_lang: Fix to use correct field name in disco#info
Kim Alvefur <zash@zash.se>
parents:
3073
diff
changeset
|
29 name = "muc#roominfo_lang", |
3069
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 value = room._data.language, |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 }); |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 formdata["muc#roominfo_lang"] = room._data.language; |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 end); |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 |