2014-09-03 21:43:27 +00:00
|
|
|
var pkg = require(process.cwd() + "/package.json");
|
2016-03-27 15:57:59 +00:00
|
|
|
var Msg = require("../../models/msg");
|
|
|
|
|
|
|
|
module.exports = function(irc, network) {
|
|
|
|
var client = this;
|
|
|
|
|
|
|
|
irc.on("ctcp response", function(data) {
|
|
|
|
var chan = network.getChannel(data.nick);
|
|
|
|
if (typeof chan === "undefined") {
|
|
|
|
chan = network.channels[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
var msg = new Msg({
|
|
|
|
type: Msg.Type.CTCP,
|
|
|
|
time: data.time,
|
|
|
|
from: data.nick,
|
|
|
|
ctcpType: data.type,
|
|
|
|
ctcpMessage: data.message
|
|
|
|
});
|
2016-04-19 10:20:18 +00:00
|
|
|
chan.pushMessage(client, msg);
|
2016-03-27 15:57:59 +00:00
|
|
|
});
|
2014-09-03 21:43:27 +00:00
|
|
|
|
2016-03-07 21:09:42 +00:00
|
|
|
irc.on("ctcp request", function(data) {
|
|
|
|
switch (data.type) {
|
2014-09-03 21:43:27 +00:00
|
|
|
case "VERSION":
|
2016-03-27 15:57:59 +00:00
|
|
|
irc.ctcpResponse(data.nick, "VERSION", pkg.name + " " + pkg.version);
|
2014-09-03 21:43:27 +00:00
|
|
|
break;
|
|
|
|
case "PING":
|
2016-03-15 09:41:11 +00:00
|
|
|
var split = data.message.split(" ");
|
2015-09-30 22:39:57 +00:00
|
|
|
if (split.length === 2) {
|
2016-03-27 15:57:59 +00:00
|
|
|
irc.ctcpResponse(data.nick, "PING", split[1]);
|
2014-09-03 21:43:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|