mirror of
https://github.com/thelounge/thelounge
synced 2025-01-09 19:08:49 +00:00
36 lines
825 B
JavaScript
36 lines
825 B
JavaScript
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);
|
|
});
|
|
|
|
irc.on("ctcp request", function(data) {
|
|
switch (data.type) {
|
|
case "VERSION":
|
|
irc.ctcpResponse(data.nick, "VERSION", pkg.name + " " + pkg.version);
|
|
break;
|
|
case "PING":
|
|
var split = data.message.split(" ");
|
|
if (split.length === 2) {
|
|
irc.ctcpResponse(data.nick, "PING", split[1]);
|
|
}
|
|
break;
|
|
}
|
|
});
|
|
};
|