annotate mod_ircd/mod_ircd.lua @ 329:febfb59502fc

mod_ircd: Add QUIT command.
author Kim Alvefur <zash@zash.se>
date Thu, 03 Feb 2011 23:57:37 +0100
parents 282abba844e8
children 8b81257c9dc5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
1 -- README
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
2 -- Squish verse into this dir, then squish them into one, which you move
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
3 -- and rename to mod_ircd.lua in your prosody modules/plugins dir.
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
4 --
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
5 -- IRC spec:
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
6 -- http://tools.ietf.org/html/rfc2812
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
7 local _module = module
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
8 module = _G.module
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
9 local module = _module
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
10 --
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
11 local component_jid, component_secret, muc_server =
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
12 module.host, nil, module:get_option("conference_server");
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
13
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
14 package.loaded["util.sha1"] = require "util.encodings";
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
15 local verse = require "verse"
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
16 require "verse.component"
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
17 require "socket"
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
18 c = verse.new();--verse.logger())
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
19 c:add_plugin("groupchat");
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
20
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
21 local function verse2prosody(e)
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
22 return c:event("stanza", e.stanza) or true;
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
23 end
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
24 module:hook("message/bare", verse2prosody);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
25 module:hook("message/full", verse2prosody);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
26 module:hook("presence/bare", verse2prosody);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
27 module:hook("presence/full", verse2prosody);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
28 c.type = "component";
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
29 c.send = core_post_stanza;
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
30
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
31 -- This plugin is actually a verse based component, but that mode is currently commented out
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
32
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
33 -- Add some hooks for debugging
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
34 --c:hook("opened", function () print("Stream opened!") end);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
35 --c:hook("closed", function () print("Stream closed!") end);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
36 --c:hook("stanza", function (stanza) print("Stanza:", stanza) end);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
37
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
38 -- This one prints all received data
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
39 --c:hook("incoming-raw", print, 1000);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
40 --c:hook("stanza", print, 1000);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
41 --c:hook("outgoing-raw", print, 1000);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
42
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
43 -- Print a message after authentication
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
44 --c:hook("authentication-success", function () print("Logged in!"); end);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
45 --c:hook("authentication-failure", function (err) print("Failed to log in! Error: "..tostring(err.condition)); end);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
46
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
47 -- Print a message and exit when disconnected
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
48 --c:hook("disconnected", function () print("Disconnected!"); os.exit(); end);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
49
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
50 -- Now, actually start the connection:
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
51 --c.connect_host = "127.0.0.1"
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
52 --c:connect_component(component_jid, component_secret);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
53
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
54 local jid = require "util.jid";
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
55
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
56 local function irc2muc(channel, nick)
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
57 return jid.join(channel:gsub("^#", ""), muc_server, nick)
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
58 end
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
59 local function muc2irc(room)
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
60 local channel, _, nick = jid.split(room);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
61 return "#"..channel, nick;
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
62 end
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
63
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
64 local irc_listener = { default_port = 6667, default_mode = "*l" };
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
65
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 local sessions = {};
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
67 local jids = {};
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68 local commands = {};
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
70 local nicks = {};
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72 local st = require "util.stanza";
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
73
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
74 local conference_server = muc_server;
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
75
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
76 local function irc_close_session(session)
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
77 session.conn:close();
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
78 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
79
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
80 function irc_listener.onincoming(conn, data)
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
81 local session = sessions[conn];
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
82 if not session then
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
83 session = { conn = conn, host = component_jid, reset_stream = function () end,
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84 close = irc_close_session, log = logger.init("irc"..(conn.id or "1")),
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
85 rooms = {},
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
86 roster = {} };
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
87 sessions[conn] = session;
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
88 function session.data(data)
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
89 local command, args = data:match("^%s*([^ ]+) *(.*)%s*$");
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
90 if not command then
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
91 return;
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
92 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
93 command = command:upper();
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
94 if commands[command] then
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
95 local ret = commands[command](session, args);
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
96 if ret then
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
97 session.send(ret.."\r\n");
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
98 end
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
99 else
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
100 module:log("debug", "Unknown command: %s", command);
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
101 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
102 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
103 function session.send(data)
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
104 return conn:write(data.."\r\n");
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
105 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
106 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
107 if data then
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
108 session.data(data);
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
109 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
110 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
112 function irc_listener.ondisconnect(conn, error)
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
113 local session = sessions[conn];
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
114 for _, room in pairs(session.rooms) do
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
115 room:leave("Disconnected");
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
116 end
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
117 sessions[conn] = nil;
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
118 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
119
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
120 function commands.NICK(session, nick)
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
121 if session.nick then
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
122 session.send(":"..session.host.." 484 * "..nick.." :I'm afraid I can't let you do that, "..nick);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
123 return;
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
124 end
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125 nick = nick:match("^[%w_]+");
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
126 if nicks[nick] then
236
24582ea48471 mod_ircd: Fix "nickname in use" reply
Matthew Wild <mwild1@gmail.com>
parents: 212
diff changeset
127 session.send(":"..session.host.." 433 * "..nick.." :The nickname "..nick.." is already in use");
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128 return;
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
129 end
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
130 local full_jid = jid.join(nick, component_jid, "ircd");
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
131 jids[full_jid] = session;
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
132 nicks[nick] = session;
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
133 session.nick = nick;
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
134 session.full_jid = full_jid;
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
135 session.type = "c2s";
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136 session.send(":"..session.host.." 001 "..session.nick.." :Welcome to XMPP via the "..session.host.." gateway "..session.nick);
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
138
329
febfb59502fc mod_ircd: Add QUIT command.
Kim Alvefur <zash@zash.se>
parents: 326
diff changeset
139 function commands.USER(session, params)
febfb59502fc mod_ircd: Add QUIT command.
Kim Alvefur <zash@zash.se>
parents: 326
diff changeset
140 -- FIXME
febfb59502fc mod_ircd: Add QUIT command.
Kim Alvefur <zash@zash.se>
parents: 326
diff changeset
141 -- Empty command for now
febfb59502fc mod_ircd: Add QUIT command.
Kim Alvefur <zash@zash.se>
parents: 326
diff changeset
142 end
febfb59502fc mod_ircd: Add QUIT command.
Kim Alvefur <zash@zash.se>
parents: 326
diff changeset
143
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
144 local joined_mucs = {};
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
145 function commands.JOIN(session, channel)
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
146 if not session.nick then
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
147 return ":"..session.host.." 451 :You have not registered";
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
148 end
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
149
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
150 if not joined_mucs[channel] then
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
151 joined_mucs[channel] = { occupants = {}, sessions = {} };
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
152 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
153 joined_mucs[channel].sessions[session] = true;
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
154 local room_jid = irc2muc(channel);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
155 print(session.full_jid);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
156 local room, err = c:join_room(room_jid, session.nick, { source = session.full_jid } );
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
157 if not room then
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
158 return ":"..session.host.." ERR :Could not join room: "..err
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
159 end
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
160 session.rooms[channel] = room;
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
161 room.channel = channel;
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
162 room.session = session;
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
163 session.send(":"..session.nick.." JOIN :"..channel);
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
164 session.send(":"..session.host.." 332 "..session.nick.." "..channel.." :Connection in progress...");
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
165 room:hook("message", function(event)
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
166 if not event.body then return end
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
167 local nick, body = event.nick, event.body;
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
168 if nick ~= session.nick then
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
169 if body:sub(1,4) == "/me " then
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
170 body = "\1ACTION ".. body:sub(5) .. "\1"
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
171 end
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
172 session.send(":"..nick.." PRIVMSG "..channel.." :"..body);
329
febfb59502fc mod_ircd: Add QUIT command.
Kim Alvefur <zash@zash.se>
parents: 326
diff changeset
173 --FIXME PM's probably won't work
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
174 end
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
175 end);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
176 end
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
177
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
178 c:hook("groupchat/joined", function(room)
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
179 local session = room.session or jids[room.opts.source];
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
180 local channel = muc2irc(room.jid);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
181 local nicks = session.nick;
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
182 -- TODO Break this out into commands.NAMES
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
183 for nick in pairs(room.occupants) do
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
184 if nick ~= session.nick then
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
185 nicks = nicks.." "..nick;
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
186 end
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
187 end
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
188 session.send(":"..session.host.." 366 "..session.nick.." "..channel.." :End of /NAMES list.");
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
189 session.send(":"..session.host.." 353 "..session.nick.." = "..channel.." :"..nicks);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
190 room:hook("occupant-joined", function(nick)
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
191 session.send(":"..nick.nick.."!"..nick.nick.." JOIN :"..room.channel);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
192 end);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
193 room:hook("occupant-left", function(nick)
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
194 session.send(":"..nick.nick.."!"..nick.nick.." PART "..room.channel.." :");
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
195 end);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
196 end);
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
197
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
198 function commands.PART(session, channel)
132
d4ff1cd414e5 mod_ircd: Add PING command / Echo PART back
Florian Zeitz <florob@babelmonkeys.de>
parents: 111
diff changeset
199 local channel, part_message = channel:match("^([^:]+):?(.*)$");
d4ff1cd414e5 mod_ircd: Add PING command / Echo PART back
Florian Zeitz <florob@babelmonkeys.de>
parents: 111
diff changeset
200 channel = channel:match("^([%S]*)");
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
201 session.rooms[channel]:leave(part_message);
132
d4ff1cd414e5 mod_ircd: Add PING command / Echo PART back
Florian Zeitz <florob@babelmonkeys.de>
parents: 111
diff changeset
202 session.send(":"..session.nick.." PART :"..channel);
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
203 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
204
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
205 function commands.PRIVMSG(session, message)
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
206 local channel, message = message:match("^(%S+) :(.+)$");
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
207 if message and #message > 0 and session.rooms[channel] then
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
208 if message:sub(1,8) == "\1ACTION " then
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
209 message = "/me ".. message:sub(9,-2)
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
210 end
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
211 module:log("debug", "%s sending PRIVMSG \"%s\" to %s", session.nick, message, channel);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
212 session.rooms[channel]:send_message(message);
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
213 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
214 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
215
132
d4ff1cd414e5 mod_ircd: Add PING command / Echo PART back
Florian Zeitz <florob@babelmonkeys.de>
parents: 111
diff changeset
216 function commands.PING(session, server)
d4ff1cd414e5 mod_ircd: Add PING command / Echo PART back
Florian Zeitz <florob@babelmonkeys.de>
parents: 111
diff changeset
217 session.send(":"..session.host..": PONG "..server);
d4ff1cd414e5 mod_ircd: Add PING command / Echo PART back
Florian Zeitz <florob@babelmonkeys.de>
parents: 111
diff changeset
218 end
d4ff1cd414e5 mod_ircd: Add PING command / Echo PART back
Florian Zeitz <florob@babelmonkeys.de>
parents: 111
diff changeset
219
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
220 function commands.WHO(session, channel)
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
221 if session.rooms[channel] then
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
222 local room = session.rooms[channel]
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
223 for nick in pairs(room.occupants) do
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
224 --n=MattJ 91.85.191.50 irc.freenode.net MattJ H :0 Matthew Wild
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
225 session.send(":"..session.host.." 352 "..session.nick.." "..channel.." "..nick.." "..nick.." "..session.host.." "..nick.." H :0 "..nick);
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
226 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
227 session.send(":"..session.host.." 315 "..session.nick.." "..channel.. " :End of /WHO list");
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
228 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
229 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
230
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
231 function commands.MODE(session, channel)
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
232 session.send(":"..session.host.." 324 "..session.nick.." "..channel.." +J");
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
233 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
234
329
febfb59502fc mod_ircd: Add QUIT command.
Kim Alvefur <zash@zash.se>
parents: 326
diff changeset
235 function commands.QUIT(session, message)
febfb59502fc mod_ircd: Add QUIT command.
Kim Alvefur <zash@zash.se>
parents: 326
diff changeset
236 session.send("ERROR :Closing Link: "..session.nick);
febfb59502fc mod_ircd: Add QUIT command.
Kim Alvefur <zash@zash.se>
parents: 326
diff changeset
237 for _, room in pairs(session.rooms) do
febfb59502fc mod_ircd: Add QUIT command.
Kim Alvefur <zash@zash.se>
parents: 326
diff changeset
238 room:leave(message);
febfb59502fc mod_ircd: Add QUIT command.
Kim Alvefur <zash@zash.se>
parents: 326
diff changeset
239 end
febfb59502fc mod_ircd: Add QUIT command.
Kim Alvefur <zash@zash.se>
parents: 326
diff changeset
240 session:close();
febfb59502fc mod_ircd: Add QUIT command.
Kim Alvefur <zash@zash.se>
parents: 326
diff changeset
241 end
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
242
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
243 function commands.RAW(session, data)
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
244 --c:send(data)
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
245 end
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
246
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
247 --c:hook("ready", function ()
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
248 require "net.connlisteners".register("irc", irc_listener);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
249 require "net.connlisteners".start("irc");
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
250 --end);
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
251
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
252 --print("Starting loop...")
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
253 --verse.loop()
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
254
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
255 --[[ TODO
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
256
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
257 This is so close to working as a Prosody plugin you know ^^
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
258 Zash: :D
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
259 MattJ: That component function can go
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
260 Prosody fires events now
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
261 but verse fires "message" where Prosody fires "message/bare"
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
262 [20:59:50]
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
263 Easy... don't connect_component
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
264 hook "message/*" and presence, and whatever
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
265 and call c:event("message", ...)
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
266 module:hook("message/bare", function (e) c:event("message", e.stanza) end)
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
267 as an example
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
268 That's so bad ^^
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
269 and override c:send() to core_post_stanza...
111
3de60860adca mod_ircd: Initial commit of a wonderfully hacky but working IRC->XMPP interface for Prosody
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
270
326
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
271 --]]
282abba844e8 mod_ircd: Partial rewrite, use verse for MUC
Kim Alvefur <zash@zash.se>
parents: 282
diff changeset
272