thelounge/src/plugins/irc-events/ctcp.js

37 lines
825 B
JavaScript
Raw Normal View History

2014-09-03 21:43:27 +00:00
var pkg = require(process.cwd() + "/package.json");
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
});
chan.pushMessage(client, msg);
});
2014-09-03 21:43:27 +00:00
irc.on("ctcp request", function(data) {
switch (data.type) {
2014-09-03 21:43:27 +00:00
case "VERSION":
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) {
irc.ctcpResponse(data.nick, "PING", split[1]);
2014-09-03 21:43:27 +00:00
}
break;
}
});
};