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

33 lines
672 B
JavaScript
Raw Normal View History

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 23:43:27 +02:00
irc.on("ctcp request", function(data) {
switch (data.type) {
2014-09-03 23:43:27 +02:00
case "PING":
2016-03-15 10:41:11 +01:00
var split = data.message.split(" ");
2015-10-01 00:39:57 +02:00
if (split.length === 2) {
irc.ctcpResponse(data.nick, "PING", split[1]);
2014-09-03 23:43:27 +02:00
}
break;
}
});
};