Annotate

plugins/groupchat.lua @ 184:8173e57522bf

plugins.groupchat: Fix a missing `st.` and send join stanza regardless of return value from pre-join event.
author Kim Alvefur <zash@zash.se>
date Thu, 13 Jan 2011 00:23:17 +0100
parent 182:51c0baa2bd19
child 185:4f897d0e01c4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
182
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 local events = require "events";
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2 local st = require "util.stanza";
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 local room_mt = {};
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 room_mt.__index = room_mt;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 local xmlns_delay = "urn:xmpp:delay";
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 local xmlns_muc = "http://jabber.org/protocol/muc";
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 function verse.plugins.groupchat(stream)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11 stream:add_plugin("presence")
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 stream.rooms = {};
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 stream:hook("stanza", function (stanza)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 local room_jid = jid.bare(stanza.attr.from);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 local room = stream.rooms[room_jid]
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 if room then
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18 local nick = select(3, jid.split(stanza.attr.from));
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 local body = stanza:get_child("body");
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20 local delay = stanza:get_child("delay", xmlns_delay);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 local event = {
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 room_jid = room_jid;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 room = room;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24 sender = room.occupants[nick];
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25 nick = nick;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
26 body = (body and body:get_text()) or nil;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27 stanza = stanza;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
28 delay = (delay and delay.attr.stamp);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
29 };
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30 local ret = room:event(stanza.name, event);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
31 return ret or (stanza.name == "message") or nil;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
32 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
33 end, 500);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
34
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
35 function stream:join_room(jid, nick)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
36 if not nick then
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
37 return false, "no nickname supplied"
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
38 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
39 local room = setmetatable({
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
40 stream = stream, jid = jid, nick = nick,
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
41 subject = "",
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
42 occupants = {},
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
43 events = events.new()
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
44 }, room_mt);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
45 self.rooms[jid] = room;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
46 local occupants = room.occupants;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
47 room:hook("presence", function (presence)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
48 local nick = presence.nick or nick;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
49 if not occupants[nick] and presence.stanza.attr.type ~= "unavailable" then
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
50 occupants[nick] = {
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
51 nick = nick;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
52 jid = presence.stanza.attr.from;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
53 presence = presence.stanza;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
54 };
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
55 local x = presence.stanza:get_child("x", xmlns_muc .. "#user");
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
56 if x then
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
57 local x_item = x:get_child("item");
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
58 if x_item and x_item.attr then
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
59 occupants[nick].real_jid = x_item.attr.jid;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
60 occupants[nick].affiliation = x_item.attr.affiliation;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
61 occupants[nick].role = x_item.attr.role;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
62 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
63 --TODO Check for status 100?
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
64 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
65 if nick == room.nick then
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
66 room.stream:event("groupchat/joined", room);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
67 else
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
68 room:event("occupant-joined", occupants[nick]);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
69 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
70 elseif occupants[nick] and presence.stanza.attr.type == "unavailable" then
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
71 if nick == room.nick then
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
72 room.stream:event("groupchat/left", room);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
73 self.rooms[room.jid] = nil;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
74 else
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
75 occupants[nick].presence = presence.stanza;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
76 room:event("occupant-left", occupants[nick]);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
77 occupants[nick] = nil;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
78 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
79 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
80 end);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
81 room:hook("message", function(msg)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
82 local subject = msg.stanza:get_child("subject");
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
83 if subject then
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
84 room.subject = subject and subject:get_text() or "";
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
85 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
86 end);
184
8173e57522bf plugins.groupchat: Fix a missing `st.` and send join stanza regardless of return value from pre-join event.
Kim Alvefur <zash@zash.se>
parents: 182
diff changeset
87 local join_st = st.presence({to = jid.."/"..nick})
182
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
88 :tag("x",{xmlns = xmlns_muc}):reset();
184
8173e57522bf plugins.groupchat: Fix a missing `st.` and send join stanza regardless of return value from pre-join event.
Kim Alvefur <zash@zash.se>
parents: 182
diff changeset
89 self:event("pre-groupchat/joining", join_st);
8173e57522bf plugins.groupchat: Fix a missing `st.` and send join stanza regardless of return value from pre-join event.
Kim Alvefur <zash@zash.se>
parents: 182
diff changeset
90 self:send(join_st)
8173e57522bf plugins.groupchat: Fix a missing `st.` and send join stanza regardless of return value from pre-join event.
Kim Alvefur <zash@zash.se>
parents: 182
diff changeset
91 self:event("groupchat/joining", room);
182
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
92 return room;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
93 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
94
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
95 stream:hook("presence-out", function(presence)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
96 if not presence.attr.to then
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
97 for _, room in pairs(stream.rooms) do
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
98 room:send(presence);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
99 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
100 presence.attr.to = nil;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
101 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
102 end);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
103 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
104
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
105 function room_mt:send(stanza)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
106 if stanza.name == "message" and not stanza.attr.type then
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
107 stanza.attr.type = "groupchat";
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
108 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
109 if stanza.attr.type == "groupchat" or not stanza.attr.to then
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
110 stanza.attr.to = self.jid;
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
111 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
112 self.stream:send(stanza);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
113 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
114
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
115 function room_mt:send_message(text)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
116 self:send(st.message():tag("body"):text(text));
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
117 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
118
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
119 function room_mt:set_subject(text)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
120 self:send(st.message():tag("subject"):text(text));
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
121 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
122
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
123 function room_mt:leave(message)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
124 self.stream:event("groupchat/leaving", room);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
125 self:send(st.presence({type="unavailable"}));
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
126 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
127
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
128 function room_mt:admin_set(nick, what, value, reason)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
129 self:send(st.iq({type="set"})
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
130 :query(xmlns_muc .. "#admin")
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
131 :tag("item", {nick = nick, [what] = value})
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
132 :tag("reason"):text(reason or ""));
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
133 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
134
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
135 function room_mt:set_role(nick, role, reason)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
136 self:admin_set(nick, "role", role, reason);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
137 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
138
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
139 function room_mt:set_affiliation(nick, affiliation, reason)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
140 self:admin_set(nick, "affiliation", affiliation, reason);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
141 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
142
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
143 function room_mt:kick(nick, reason)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
144 self:set_role(nick, "none", reason);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
145 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
146
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
147 function room_mt:ban(nick, reason)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
148 self:set_affiliation(nick, "outcast", reason);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
149 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
150
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
151 function room_mt:event(name, arg)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
152 self.stream:debug("Firing room event: %s", name);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
153 return self.events.fire_event(name, arg);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
154 end
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
155
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
156 function room_mt:hook(name, callback, priority)
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
157 return self.events.add_handler(name, callback, priority);
51c0baa2bd19 plugins.groupchat: Adapt from Riddim
Kim Alvefur <zash@zash.se>
parents:
diff changeset
158 end