annotate mod_ircd/mod_ircd.lua @ 460:9bb9343f3c7a

mod_component_guard: made module global, refactored init.
author Marco Cirillo <maranda@lightwitch.org>
date Mon, 24 Oct 2011 00:20:51 +0000
parents 3bf6f102f1cc
children 7e6524555ab0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
448
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
1 -- README
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
2 -- Squish verse into this dir, then squish them into one, which you move
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
3 -- and rename to mod_ircd.lua in your prosody modules/plugins dir.
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
4 --
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
5 -- IRC spec:
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
6 -- http://tools.ietf.org/html/rfc2812
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
7 local _module = module
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
8 module = _G.module
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
9 local module = _module
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
10 --
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
11 local component_jid, component_secret, muc_server =
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
12 module.host, nil, module:get_option("conference_server");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
13
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
14 package.loaded["util.sha1"] = require "util.encodings";
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
15 local verse = require "verse"
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
16 require "verse.component"
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
17 require "socket"
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
18 c = verse.new();--verse.logger())
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
19 c:add_plugin("groupchat");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
20
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
21 local function verse2prosody(e)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
22 return c:event("stanza", e.stanza) or true;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
23 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
24 module:hook("message/bare", verse2prosody);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
25 module:hook("message/full", verse2prosody);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
26 module:hook("presence/bare", verse2prosody);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
27 module:hook("presence/full", verse2prosody);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
28 c.type = "component";
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
29 c.send = core_post_stanza;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
30
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
31 local jid = require "util.jid";
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
32
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
33 local function irc2muc(channel, nick)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
34 channel = channel:gsub("^#", "")
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
35 channel = channel:gsub("(%s:)$", "")
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
36 return jid.join(channel, muc_server, nick)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
37 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
38 local function muc2irc(room)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
39 local channel, _, nick = jid.split(room);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
40 return "#"..channel, nick;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
41 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
42 local rolemap = {
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
43 moderator = "@",
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
44 participant = "+",
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
45 }
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
46 local modemap = {
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
47 moderator = "o",
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
48 participant = "v",
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
49 }
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
50
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
51 local irc_listener = { default_port = 7000, default_mode = "*l" };
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
52
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
53 local sessions = {};
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
54 local jids = {};
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
55 local commands = {};
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
56
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
57 local nicks = {};
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
58
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
59 local st = require "util.stanza";
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
60
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
61 local conference_server = muc_server;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
62
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
63 local function irc_close_session(session)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
64 session.conn:close();
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
65 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
66
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
67 function irc_listener.onincoming(conn, data)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
68 local session = sessions[conn];
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
69 if not session then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
70 session = { conn = conn, host = component_jid, reset_stream = function () end,
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
71 close = irc_close_session, log = logger.init("irc"..(conn.id or "1")),
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
72 rooms = {},
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
73 roster = {} };
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
74 sessions[conn] = session;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
75 function session.data(data)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
76 local command, args = data:match("^%s*([^ ]+) *(.*)%s*$");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
77 if not command then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
78 return;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
79 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
80 command = command:upper();
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
81 if not session.nick then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
82 if not (command == "USER" or command == "NICK") then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
83 session.send(":" .. muc_server .. " 451 " .. command .. " :You have not registered")
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
84 return true;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
85 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
86 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
87 if commands[command] then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
88 local ret = commands[command](session, args);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
89 if ret then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
90 session.send(ret.."\r\n");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
91 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
92 else
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
93 session.send(":" .. muc_server .. " 421 " .. session.nick .. " " .. command .. " :Unknown command")
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
94 module:log("debug", "Unknown command: %s", command);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
95 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
96 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
97 function session.send(data)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
98 return conn:write(data.."\r\n");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
99 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
100 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
101 if data then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
102 session.data(data);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
103 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
104 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
105
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
106 function irc_listener.ondisconnect(conn, error)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
107 local session = sessions[conn];
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
108 for _, room in pairs(session.rooms) do
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
109 room:leave("Disconnected");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
110 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
111 if jids[session.full_jid] then jids[session.full_jid] = nil end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
112 if nicks[session.nick] then nicks[session.nick] = nil end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
113 if sessions[conn] then sessions[conn] = nil end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
114 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
115
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
116 function commands.NICK(session, nick)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
117 if session.nick then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
118 session.send(":"..muc_server.." 484 * "..nick.." :I'm afraid I can't let you do that, "..nick);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
119 --TODO Loop throug all rooms and change nick, with help from Verse.
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
120 return;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
121 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
122 nick = nick:match("^[%w_:]+"); nick = nick:gsub(":", "");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
123 if nicks[nick] then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
124 session.send(":"..muc_server.." 433 * "..nick.." :The nickname "..nick.." is already in use");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
125 return;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
126 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
127 local full_jid = jid.join(nick, component_jid, "ircd");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
128 jids[full_jid] = session;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
129 nicks[nick] = session;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
130 session.nick = nick;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
131 session.full_jid = full_jid;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
132 session.type = "c2s";
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
133 session.send(":"..muc_server.." 001 "..session.nick.." :Welcome in the IRC to MUC XMPP Gateway, "..session.nick);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
134 session.send(":"..muc_server.." 002 "..session.nick.." :Your host is "..muc_server..", running Prosody "..prosody.version);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
135 session.send(":"..muc_server.." 004 "..session.nick.." :"..muc_server.." Prosody("..prosody.version..") i ov");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
136 session.send(":"..muc_server.." 375 "..session.nick.." :- "..muc_server.." Message of the day -");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
137 session.send(":"..muc_server.." 372 "..session.nick.." :-");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
138 session.send(":"..muc_server.." 372 "..session.nick.." :- Please be warned that this is only a partial irc implementation,");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
139 session.send(":"..muc_server.." 372 "..session.nick.." :- it's made to facilitate users transiting away from irc to XMPP.");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
140 session.send(":"..muc_server.." 372 "..session.nick.." :-");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
141 session.send(":"..muc_server.." 372 "..session.nick.." :- Prosody is _NOT_ an IRC Server and it never will.");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
142 session.send(":"..muc_server.." 372 "..session.nick.." :- We also would like to remind you that this plugin is provided as is,");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
143 session.send(":"..muc_server.." 372 "..session.nick.." :- it's still an Alpha and it's still a work in progress, use it at your sole");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
144 session.send(":"..muc_server.." 372 "..session.nick.." :- risk as there's a not so little chance something will break.");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
145 session.send(":"..session.nick.." MODE "..session.nick.." +i");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
146 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
147
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
148 function commands.USER(session, params)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
149 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
150
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
151 function commands.JOIN(session, channel)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
152 local room_jid = irc2muc(channel);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
153 channel = channel:gsub("(%s:)$", "")
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
154 local room, err = c:join_room(room_jid, session.nick, { source = session.full_jid } );
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
155 if not room then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
156 return ":"..session.host.." ERR :Could not join room: "..err
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
157 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
158 session.rooms[channel] = room;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
159 room.channel = channel;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
160 room.session = session;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
161 if room.subject then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
162 session.send(":"..session.host.." 332 "..session.nick.." "..channel.." :"..room.subject);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
163 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
164 commands.NAMES(session, channel)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
165 room:hook("message", function(event)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
166 if not event.body then return end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
167 local nick, body = event.nick, event.body;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
168 if nick ~= session.nick then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
169 if body:sub(1,4) == "/me " then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
170 body = "\1ACTION ".. body:sub(5) .. "\1"
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
171 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
172 session.send(":"..nick.." PRIVMSG "..channel.." :"..body);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
173 --FIXME PM's probably won't work
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
174 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
175 end);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
176 room:hook("subject-changed", function(changed)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
177 session.send((":%s TOPIC %s :%s"):format(changed.by, channel, changed.to or ""));
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
178 end);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
179 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
180
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
181 c:hook("groupchat/joined", function(room)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
182 local session = room.session or jids[room.opts.source];
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
183 local channel = "#"..room.jid:match("^(.*)@");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
184 session.send((":%s!%s JOIN :%s"):format(session.nick, session.nick, channel));
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
185 if room.topic then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
186 session.send((":%s 332 %s :%s"):format(muc_server, channel, room.topic));
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
187 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
188 commands.NAMES(session, channel)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
189 --FIXME Ones own mode get's lost
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
190 --session.send((":%s MODE %s +%s %s"):format(session.host, room.channel, modemap[nick.role], nick.nick));
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
191 room:hook("occupant-joined", function(nick)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
192 session.send((":%s!%s JOIN :%s"):format(nick.nick, nick.nick, channel));
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
193 if nick.role and modemap[nick.role] then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
194 session.send((":%s MODE %s +%s %s"):format(muc_server, channel, modemap[nick.role], nick.nick));
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
195 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
196 end);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
197 room:hook("occupant-left", function(nick)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
198 session.send((":%s!%s PART :%s"):format(nick.nick, nick.nick, channel));
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
199 end);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
200 end);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
201
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
202 function commands.NAMES(session, channel)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
203 local nicks = { };
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
204 channel = channel:gsub("^:", "")
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
205 local room = session.rooms[channel];
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
206 if not room then return end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
207 -- TODO Break this out into commands.NAMES
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
208 for nick, n in pairs(room.occupants) do
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
209 if n.role and rolemap[n.role] then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
210 nick = rolemap[n.role] .. nick;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
211 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
212 table.insert(nicks, nick);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
213 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
214 nicks = table.concat(nicks, " ");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
215 --:molyb.irc.bnfh.org 353 derp = #grill-bit :derp hyamobi walt snuggles_ E-Rock kng grillbit gunnarbot Frink shedma zagabar zash Mrw00t Appiah J10 lectus peck EricJ soso mackt offer hyarion @pettter MMN-o
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
216 session.send((":%s 353 %s = %s :%s"):format(session.host, session.nick, channel, nicks));
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
217 session.send((":%s 366 %s %s :End of /NAMES list."):format(session.host, session.nick, channel));
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
218 session.send(":"..muc_server.." 353 "..session.nick.." = "..channel.." :"..nicks);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
219 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
220
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
221 function commands.PART(session, channel)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
222 local channel, part_message = channel:match("^([^:]+):?(.*)$");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
223 channel = channel:match("^([%S]*)");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
224 session.rooms[channel]:leave(part_message);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
225 session.send(":"..session.nick.." PART :"..channel);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
226 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
227
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
228 function commands.PRIVMSG(session, message)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
229 local channel, message = message:match("^(%S+) :(.+)$");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
230 if message and #message > 0 and session.rooms[channel] then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
231 if message:sub(1,8) == "\1ACTION " then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
232 message = "/me ".. message:sub(9,-2)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
233 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
234 module:log("debug", "%s sending PRIVMSG \"%s\" to %s", session.nick, message, channel);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
235 session.rooms[channel]:send_message(message);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
236 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
237 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
238
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
239 function commands.PING(session, server)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
240 session.send(":"..muc_server..": PONG "..server);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
241 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
242
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
243 function commands.TOPIC(session, message)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
244 if not message then return end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
245 local channel, topic = message:match("^(%S+) :(.*)$");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
246 if not channel then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
247 channel = message:match("^(%S+)");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
248 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
249 if not channel then return end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
250 local room = session.rooms[channel];
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
251 if topic then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
252 room:set_subject(topic)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
253 session.send((":%s TOPIC %s :%s"):format(muc_server, channel, room.subject or ""));
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
254 else
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
255 session.send((":%s TOPIC %s :%s"):format(muc_server, channel, room.subject or ""));
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
256 -- first should be who set it, but verse doesn't provide that yet, so we'll
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
257 -- just say it was the server
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
258 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
259 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
260
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
261 function commands.WHO(session, channel)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
262 channel = channel:gsub("^:", "")
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
263 if session.rooms[channel] then
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
264 local room = session.rooms[channel]
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
265 for nick in pairs(room.occupants) do
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
266 session.send(":"..muc_server.." 352 "..session.nick.." "..channel.." "..nick.." "..nick.." "..muc_server.." "..nick.." H :0 "..nick);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
267 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
268 session.send(":"..muc_server.." 315 "..session.nick.." "..channel.. " :End of /WHO list");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
269 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
270 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
271
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
272 function commands.MODE(session, channel)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
273 session.send(":"..muc_server.." 324 "..session.nick.." "..channel.." +J");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
274 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
275
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
276 function commands.QUIT(session, message)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
277 session.send("ERROR :Closing Link: "..session.nick);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
278 for _, room in pairs(session.rooms) do
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
279 room:leave(message);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
280 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
281 jids[session.full_jid] = nil;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
282 nicks[session.nick] = nil;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
283 sessions[session.conn] = nil;
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
284 session:close();
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
285 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
286
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
287 function commands.RAW(session, data)
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
288 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
289
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
290 local function desetup()
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
291 require "net.connlisteners".deregister("irc");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
292 end
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
293
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
294 require "net.connlisteners".register("irc", irc_listener);
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
295 require "net.connlisteners".start("irc");
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
296
3bf6f102f1cc mod_ircd: added patched plugin file.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
297 module:hook("module-unloaded", desetup)