Mercurial > prosody-modules
comparison mod_ircd/mod_ircd.in.lua @ 483:f4ada087c743
mod_ircd: added listener port configuration, added utf8 checks to TOPIC, added check so that module wonn't get loaded if conference_server is unset.
author | Marco Cirillo <maranda@lightwitch.org> |
---|---|
date | Mon, 28 Nov 2011 15:28:10 +0000 |
parents | 9d62586e7aae |
children | 0b75c7d41b82 |
comparison
equal
deleted
inserted
replaced
482:9d62586e7aae | 483:f4ada087c743 |
---|---|
6 -- http://tools.ietf.org/html/rfc2812 | 6 -- http://tools.ietf.org/html/rfc2812 |
7 local _module = module | 7 local _module = module |
8 module = _G.module | 8 module = _G.module |
9 local module = _module | 9 local module = _module |
10 -- | 10 -- |
11 local component_jid, component_secret, muc_server = | 11 local component_jid, component_secret, muc_server, port_number = |
12 module.host, nil, module:get_option("conference_server"); | 12 module.host, nil, module:get_option_string("conference_server"), module:get_option_number("listener_port", 7000); |
13 | |
14 if not muc_server then | |
15 module:log ("error", "You need to set the MUC server! halting.") | |
16 return false; | |
17 end | |
13 | 18 |
14 package.loaded["util.sha1"] = require "util.encodings"; | 19 package.loaded["util.sha1"] = require "util.encodings"; |
15 local verse = require "verse" | 20 local verse = require "verse" |
16 require "verse.component" | 21 require "verse.component" |
17 require "socket" | 22 require "socket" |
152 administrator = "a", | 157 administrator = "a", |
153 member = "v", | 158 member = "v", |
154 none = "" | 159 none = "" |
155 } | 160 } |
156 | 161 |
157 local irc_listener = { default_port = 7000, default_mode = "*l" }; | 162 local irc_listener = { default_port = port_number, default_mode = "*l" }; |
158 | 163 |
159 local sessions = {}; | 164 local sessions = {}; |
160 local jids = {}; | 165 local jids = {}; |
161 local commands = {}; | 166 local commands = {}; |
162 | 167 |
445 session.send{from=muc_server, "PONG", args[1]}; | 450 session.send{from=muc_server, "PONG", args[1]}; |
446 end | 451 end |
447 | 452 |
448 function commands.TOPIC(session, message) | 453 function commands.TOPIC(session, message) |
449 if not message then return end | 454 if not message then return end |
450 local channel, topic = message[1], message[2]; | 455 local channel, topic = message[1], message[2]; |
456 channel = utf8_clean(channel); | |
457 topic = utf8_clean(topic); | |
451 if not channel then return end | 458 if not channel then return end |
452 local room = session.rooms[channel]; | 459 local room = session.rooms[channel]; |
453 | 460 |
454 if topic then | 461 if topic then |
455 room:set_subject(topic) | 462 room:set_subject(topic) |