Comparison

mod_track_muc_joins/README.md @ 6211:750d64c47ec6 draft default tip

Merge
author Trần H. Trung <xmpp:trần.h.trung@trung.fun>
date Tue, 18 Mar 2025 00:31:36 +0700
parent 6003:fe081789f7b5
comparison
equal deleted inserted replaced
6210:24316a399978 6211:750d64c47ec6
1 ---
2 summary: Keep track of joined chat rooms
3 ...
4
5 # Introduction
6
7 This module attempts to keep track of what MUC chat rooms users have
8 joined. It's not very useful on its own, but can be used by other
9 modules to influence decisions.
10
11 # Usage
12
13 Rooms joined and the associated nickname is kept in a table field
14 `rooms_joined` on the users session.
15
16 An example:
17
18 ``` lua
19 local jid_bare = require"util.jid".bare;
20
21 module:hook("message/full", function (event)
22 local stanza = event.stanza;
23 local session = prosody.full_sessions[stanza.attr.to];
24 if not session then
25 return -- No such session
26 end
27
28 local joined_rooms = session.joined_rooms;
29 if not joined_rooms then
30 return -- This session hasn't joined any rooms at all
31 end
32
33 -- joined_rooms is a map of room JID -> room nickname
34 local nickname = joined_rooms[jid_bare(stanza.attr.from)];
35 if nickname then
36 session.log("info", "Got a MUC message from %s", stanza.attr.from);
37
38 local body = stanza:get_child_text("body");
39 if body and body:find(nickname, 1, true) then
40 session.log("info", "The message contains my nickname!");
41 end
42 end
43 end);
44 ```
45
46 # Known issues
47
48 [XEP 45 § 7.2.3 Presence Broadcast][enter-pres] has the following text:
49
50 > In particular, if roomnicks are locked down then the service MUST do
51 > one of the following.
52 >
53 > \[...\]
54 >
55 > If the user has connected using a MUC client (...), then the service
56 > MUST allow the client to enter the room, modify the nick in accordance
57 > with the lockdown policy, and **include a status code of "210"** in
58 > the presence broadcast that it sends to the new occupant.
59
60 This case is not yet handled.
61
62 [enter-pres]: http://xmpp.org/extensions/xep-0045.html#enter-pres