diff --git a/package.json b/package.json index 1af3e0b2..0986d085 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "shout", "description": "A web IRC client", - "version": "0.13.0", + "version": "0.14.0", "author": "Mattias Erming", "preferGlobal": true, "bin": { @@ -30,7 +30,7 @@ "mkdirp": "^0.5.0", "moment": "~2.7.0", "read": "^1.0.5", - "slate-irc": "~0.6.0", + "slate-irc": "~0.7.0", "socket.io": "~1.0.6", "superagent": "^0.18.2" }, diff --git a/src/client.js b/src/client.js index 1982396d..7011d186 100644 --- a/src/client.js +++ b/src/client.js @@ -9,6 +9,7 @@ module.exports = Client; var id = 0; var events = [ + "ctcp", "error", "image", "join", diff --git a/src/plugins/irc-events/ctcp.js b/src/plugins/irc-events/ctcp.js new file mode 100644 index 00000000..7174cfba --- /dev/null +++ b/src/plugins/irc-events/ctcp.js @@ -0,0 +1,24 @@ +var pkg = require(process.cwd() + "/package.json"); + +module.exports = function(irc, network) { + irc.on("message", function(data) { + if (data.message.indexOf("\001") !== 0) { + return; + } + var msg = data.message.replace(/\001/g, ""); + var split = msg.split(" "); + switch (split[0]) { + case "VERSION": + irc.ctcp( + data.from, + "VERSION " + pkg.name + " " + pkg.version + ); + break; + case "PING": + if (split.length == 2) { + irc.ctcp(data.from, "PING " + split[1]); + } + break; + } + }); +};