41 function stream:join_room(jid, nick, opts) |
41 function stream:join_room(jid, nick, opts) |
42 if not nick then |
42 if not nick then |
43 return false, "no nickname supplied" |
43 return false, "no nickname supplied" |
44 end |
44 end |
45 opts = opts or {}; |
45 opts = opts or {}; |
46 local room = setmetatable({ |
46 local room = setmetatable(verse.eventable{ |
47 stream = stream, jid = jid, nick = nick, |
47 stream = stream, jid = jid, nick = nick, |
48 subject = nil, |
48 subject = nil, |
49 occupants = {}, |
49 occupants = {}, |
50 opts = opts, |
50 opts = opts, |
51 events = events.new() |
|
52 }, room_mt); |
51 }, room_mt); |
53 if opts.source then |
52 if opts.source then |
54 self.rooms[opts.source.." "..jid] = room; |
53 self.rooms[opts.source.." "..jid] = room; |
55 else |
54 else |
56 self.rooms[jid] = room; |
55 self.rooms[jid] = room; |
174 end |
173 end |
175 |
174 |
176 function room_mt:ban(nick, reason) |
175 function room_mt:ban(nick, reason) |
177 self:set_affiliation(nick, "outcast", reason); |
176 self:set_affiliation(nick, "outcast", reason); |
178 end |
177 end |
179 |
|
180 function room_mt:event(name, arg) |
|
181 self.stream:debug("Firing room event: %s", name); |
|
182 return self.events.fire_event(name, arg); |
|
183 end |
|
184 |
|
185 function room_mt:hook(name, callback, priority) |
|
186 return self.events.add_handler(name, callback, priority); |
|
187 end |
|