From: Darren Date: Mon, 18 Jul 2011 16:03:23 +0000 (+0100) Subject: Added NOTICE interface X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e36e767b70a1e050321cf5849819a71a9259c4ca;p=KiwiIRC.git Added NOTICE interface --- diff --git a/js/front.js b/js/front.js index ffaba93..5e21f50 100644 --- a/js/front.js +++ b/js/front.js @@ -221,6 +221,16 @@ var front = { //front.tabviews[destination.toLowerCase()].addMsg(null, ' ', '* '+data.nick+' '+data.msg, 'color:green;'); front.cur_channel.addMsg(null, ' ', '* ' + gateway.nick + ' ' + msg.substring(4), 'action', 'color:#555;'); break; + + case '/notice': + var dest, msg; + dest = parts[1]; + msg = parts.slice(2).join(' '); + + gateway.notice(dest, msg); + this.onNotice({}, {nick:gateway.nick, channel:dest, msg:msg}); + break; + case '/quit': gateway.quit(msg.split(" ",2)[1]); break; diff --git a/js/gateway.js b/js/gateway.js index 46d6e51..97f6800 100644 --- a/js/gateway.js +++ b/js/gateway.js @@ -131,6 +131,19 @@ var gateway = { }, + notice: function (s_target, s_msg, callback) { + var data = { + method: 'notice', + args: { + target: s_target, + msg: s_msg + } + }; + + gateway.sendData(data, callback); + }, + + join: function (s_channel, callback) { var data = { method: 'join', diff --git a/node/kiwi.js b/node/kiwi.js index cdc70f2..05a0e0b 100644 --- a/node/kiwi.js +++ b/node/kiwi.js @@ -272,9 +272,9 @@ var ircSocketDataHandler = function (data, websocket, ircSocket) { //setup websocket listener if (config.listen_ssl) { - var io = ws.listen(config.port, {secure: true, key: fs.readFileSync(__dirname + '/' + config.ssl_key), cert: fs.readFileSync(__dirname + '/' + config.ssl_cert)}); + var io = ws.listen('127.0.0.1:'+config.port.toString(), {secure: true, key: fs.readFileSync(__dirname + '/' + config.ssl_key), cert: fs.readFileSync(__dirname + '/' + config.ssl_cert)}); } else { - var io = ws.listen(config.port, {secure: false}); + var io = ws.listen('127.0.0.1:'+config.port.toString(), {secure: false}); } io.sockets.on('connection', function (websocket) { websocket.on('irc connect', function (nick, host, port, ssl, callback) { @@ -337,6 +337,11 @@ io.sockets.on('connection', function (websocket) { websocket.ircSocket.destroySoon(); websocket.disconnect(); break; + case 'notice': + if ((args.target) && (args.msg)) { + websocket.ircSocket.write('NOTICE ' + args.target + ' :' + args.msg + '\r\n'); + } + break; default: } if ((callback) && (typeof (callback) === 'function')) {