hardlounge/src/plugins/irc-events/whois.js

37 lines
711 B
JavaScript
Raw Normal View History

2014-09-13 17:29:45 -04:00
var Chan = require("../../models/chan");
var Msg = require("../../models/msg");
module.exports = function(irc, network) {
var client = this;
2016-03-09 03:27:01 -05:00
irc.on("whois", function(data) {
2016-03-20 10:28:47 -04:00
var chan = network.getChannel(data.nick);
2014-09-13 17:29:45 -04:00
if (typeof chan === "undefined") {
chan = new Chan({
type: Chan.Type.QUERY,
2016-03-09 03:27:01 -05:00
name: data.nick
2014-09-13 17:29:45 -04:00
});
network.channels.push(chan);
client.emit("join", {
shouldOpen: true,
2014-09-13 17:29:45 -04:00
network: network.id,
chan: chan
});
}
2016-03-09 03:27:01 -05:00
var msg;
if (data.error) {
msg = new Msg({
type: Msg.Type.ERROR,
text: "No such nick: " + data.nick
});
} else {
msg = new Msg({
type: Msg.Type.WHOIS,
whois: data
});
}
chan.pushMessage(client, msg);
2014-09-13 17:29:45 -04:00
});
};