Software / code / verse
Comparison
plugins/groupchat.lua @ 197:7e98cf2c1d8d
plugins.*: Use verse.stanza() & co instead of require util.stanza
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 17 Mar 2011 18:33:52 +0100 |
| parent | 189:033f1bd7420d |
| child | 207:78f59d7b1ef7 |
comparison
equal
deleted
inserted
replaced
| 196:eb9d69d3f0b5 | 197:7e98cf2c1d8d |
|---|---|
| 1 local events = require "events"; | 1 local events = require "events"; |
| 2 local st = require "util.stanza"; | |
| 3 | 2 |
| 4 local room_mt = {}; | 3 local room_mt = {}; |
| 5 room_mt.__index = room_mt; | 4 room_mt.__index = room_mt; |
| 6 | 5 |
| 7 local xmlns_delay = "urn:xmpp:delay"; | 6 local xmlns_delay = "urn:xmpp:delay"; |
| 98 subject = subject and subject:get_text(); | 97 subject = subject and subject:get_text(); |
| 99 if subject then | 98 if subject then |
| 100 room.subject = #subject > 0 and subject or nil; | 99 room.subject = #subject > 0 and subject or nil; |
| 101 end | 100 end |
| 102 end); | 101 end); |
| 103 local join_st = st.presence():tag("x",{xmlns = xmlns_muc}):reset(); | 102 local join_st = verse.presence():tag("x",{xmlns = xmlns_muc}):reset(); |
| 104 self:event("pre-groupchat/joining", join_st); | 103 self:event("pre-groupchat/joining", join_st); |
| 105 room:send(join_st) | 104 room:send(join_st) |
| 106 self:event("groupchat/joining", room); | 105 self:event("groupchat/joining", room); |
| 107 return room; | 106 return room; |
| 108 end | 107 end |
| 132 end | 131 end |
| 133 self.stream:send(stanza); | 132 self.stream:send(stanza); |
| 134 end | 133 end |
| 135 | 134 |
| 136 function room_mt:send_message(text) | 135 function room_mt:send_message(text) |
| 137 self:send(st.message():tag("body"):text(text)); | 136 self:send(verse.message():tag("body"):text(text)); |
| 138 end | 137 end |
| 139 | 138 |
| 140 function room_mt:set_subject(text) | 139 function room_mt:set_subject(text) |
| 141 self:send(st.message():tag("subject"):text(text)); | 140 self:send(verse.message():tag("subject"):text(text)); |
| 142 end | 141 end |
| 143 | 142 |
| 144 function room_mt:leave(message) | 143 function room_mt:leave(message) |
| 145 self.stream:event("groupchat/leaving", self); | 144 self.stream:event("groupchat/leaving", self); |
| 146 self:send(st.presence({type="unavailable"})); | 145 self:send(verse.presence({type="unavailable"})); |
| 147 end | 146 end |
| 148 | 147 |
| 149 function room_mt:admin_set(nick, what, value, reason) | 148 function room_mt:admin_set(nick, what, value, reason) |
| 150 self:send(st.iq({type="set"}) | 149 self:send(verse.iq({type="set"}) |
| 151 :query(xmlns_muc .. "#admin") | 150 :query(xmlns_muc .. "#admin") |
| 152 :tag("item", {nick = nick, [what] = value}) | 151 :tag("item", {nick = nick, [what] = value}) |
| 153 :tag("reason"):text(reason or "")); | 152 :tag("reason"):text(reason or "")); |
| 154 end | 153 end |
| 155 | 154 |