Merge pull request #1330 from MaxLeiter/MaxLeiter/TIME

Add SOURCE CTCP Command
This commit is contained in:
Jérémie Astori 2017-07-19 02:00:50 -04:00 committed by GitHub
commit 03d6f284fb

View File

@ -1,17 +1,17 @@
"use strict"; "use strict";
var Msg = require("../../models/msg"); const Msg = require("../../models/msg");
module.exports = function(irc, network) { module.exports = function(irc, network) {
var client = this; const client = this;
irc.on("ctcp response", function(data) { irc.on("ctcp response", function(data) {
var chan = network.getChannel(data.nick); let chan = network.getChannel(data.nick);
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
chan = network.channels[0]; chan = network.channels[0];
} }
var msg = new Msg({ const msg = new Msg({
type: Msg.Type.CTCP, type: Msg.Type.CTCP,
time: data.time, time: data.time,
from: data.nick, from: data.nick,
@ -21,14 +21,20 @@ module.exports = function(irc, network) {
chan.pushMessage(client, msg); chan.pushMessage(client, msg);
}); });
irc.on("ctcp request", function(data) { irc.on("ctcp request", (data) => {
switch (data.type) { switch (data.type) {
case "PING": case "PING": {
var split = data.message.split(" "); const split = data.message.split(" ");
if (split.length === 2) { if (split.length === 2) {
irc.ctcpResponse(data.nick, "PING", split[1]); irc.ctcpResponse(data.nick, "PING", split[1]);
} }
break; break;
} }
case "SOURCE": {
const packageJson = require("../../../package.json");
irc.ctcpResponse(data.nick, "SOURCE", packageJson.repository.url);
break;
}
}
}); });
}; };