Software /
code /
verse
Comparison
plugins/groupchat.lua @ 185:4f897d0e01c4
plugins.groupchat: Trying to get subject to behave properly
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 19 Jan 2011 20:37:12 +0100 |
parent | 184:8173e57522bf |
child | 186:bb34b8bc00ae |
comparison
equal
deleted
inserted
replaced
184:8173e57522bf | 185:4f897d0e01c4 |
---|---|
36 if not nick then | 36 if not nick then |
37 return false, "no nickname supplied" | 37 return false, "no nickname supplied" |
38 end | 38 end |
39 local room = setmetatable({ | 39 local room = setmetatable({ |
40 stream = stream, jid = jid, nick = nick, | 40 stream = stream, jid = jid, nick = nick, |
41 subject = "", | 41 subject = nil, |
42 occupants = {}, | 42 occupants = {}, |
43 events = events.new() | 43 events = events.new() |
44 }, room_mt); | 44 }, room_mt); |
45 self.rooms[jid] = room; | 45 self.rooms[jid] = room; |
46 local occupants = room.occupants; | 46 local occupants = room.occupants; |
78 end | 78 end |
79 end | 79 end |
80 end); | 80 end); |
81 room:hook("message", function(msg) | 81 room:hook("message", function(msg) |
82 local subject = msg.stanza:get_child("subject"); | 82 local subject = msg.stanza:get_child("subject"); |
83 subject = subject and subject:get_text(); | |
83 if subject then | 84 if subject then |
84 room.subject = subject and subject:get_text() or ""; | 85 room.subject = #subject > 0 and subject or nil; |
85 end | 86 end |
86 end); | 87 end); |
87 local join_st = st.presence({to = jid.."/"..nick}) | 88 local join_st = st.presence({to = jid.."/"..nick}) |
88 :tag("x",{xmlns = xmlns_muc}):reset(); | 89 :tag("x",{xmlns = xmlns_muc}):reset(); |
89 self:event("pre-groupchat/joining", join_st); | 90 self:event("pre-groupchat/joining", join_st); |