2016-10-09 19:14:02 +00:00
|
|
|
"use strict";
|
|
|
|
|
2014-09-13 21:29:45 +00:00
|
|
|
var Chan = require("../../models/chan");
|
|
|
|
var Msg = require("../../models/msg");
|
|
|
|
|
|
|
|
module.exports = function(irc, network) {
|
|
|
|
var client = this;
|
2016-03-09 08:27:01 +00:00
|
|
|
irc.on("whois", function(data) {
|
2016-03-20 14:28:47 +00:00
|
|
|
var chan = network.getChannel(data.nick);
|
2014-09-13 21:29:45 +00:00
|
|
|
if (typeof chan === "undefined") {
|
|
|
|
chan = new Chan({
|
|
|
|
type: Chan.Type.QUERY,
|
2016-03-09 08:27:01 +00:00
|
|
|
name: data.nick
|
2014-09-13 21:29:45 +00:00
|
|
|
});
|
|
|
|
network.channels.push(chan);
|
|
|
|
client.emit("join", {
|
2016-05-30 19:38:53 +00:00
|
|
|
shouldOpen: true,
|
2014-09-13 21:29:45 +00:00
|
|
|
network: network.id,
|
|
|
|
chan: chan
|
|
|
|
});
|
|
|
|
}
|
2016-03-09 08:27:01 +00:00
|
|
|
|
|
|
|
var msg;
|
|
|
|
if (data.error) {
|
|
|
|
msg = new Msg({
|
|
|
|
type: Msg.Type.ERROR,
|
|
|
|
text: "No such nick: " + data.nick
|
|
|
|
});
|
|
|
|
} else {
|
2016-10-27 03:46:14 +00:00
|
|
|
// Absolute datetime in milliseconds since nick is idle
|
|
|
|
data.idleTime = Date.now() - data.idle * 1000;
|
|
|
|
|
2016-03-09 08:27:01 +00:00
|
|
|
msg = new Msg({
|
|
|
|
type: Msg.Type.WHOIS,
|
|
|
|
whois: data
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-04-19 10:20:18 +00:00
|
|
|
chan.pushMessage(client, msg);
|
2014-09-13 21:29:45 +00:00
|
|
|
});
|
|
|
|
};
|