2017-04-22 12:51:21 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const Chan = require("../../models/chan");
|
|
|
|
const Msg = require("../../models/msg");
|
|
|
|
|
|
|
|
module.exports = function(irc, network) {
|
|
|
|
const client = this;
|
|
|
|
|
|
|
|
irc.on("banlist", function(banlist) {
|
|
|
|
const channel = banlist.channel;
|
|
|
|
const bans = banlist.bans;
|
2017-04-24 10:40:53 +00:00
|
|
|
if (!bans || bans.length === 0) {
|
2017-04-22 12:51:21 +00:00
|
|
|
const msg = new Msg({
|
|
|
|
time: Date.now(),
|
|
|
|
type: Msg.Type.ERROR,
|
2017-11-15 06:35:15 +00:00
|
|
|
text: "Banlist empty",
|
2017-04-22 12:51:21 +00:00
|
|
|
});
|
|
|
|
network.getChannel(channel).pushMessage(client, msg, true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const chanName = `Banlist for ${channel}`;
|
|
|
|
let chan = network.getChannel(chanName);
|
|
|
|
if (typeof chan === "undefined") {
|
|
|
|
chan = new Chan({
|
|
|
|
type: Chan.Type.SPECIAL,
|
2017-11-15 06:35:15 +00:00
|
|
|
name: chanName,
|
2017-04-22 12:51:21 +00:00
|
|
|
});
|
|
|
|
network.channels.push(chan);
|
|
|
|
client.emit("join", {
|
|
|
|
network: network.id,
|
2017-12-03 14:29:50 +00:00
|
|
|
chan: chan.getFilteredClone(true),
|
2017-04-22 12:51:21 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
chan.pushMessage(client,
|
|
|
|
new Msg({
|
|
|
|
type: Msg.Type.BANLIST,
|
|
|
|
bans: bans.map((data) => ({
|
|
|
|
hostmask: data.banned,
|
|
|
|
banned_by: data.banned_by,
|
2017-11-15 06:35:15 +00:00
|
|
|
banned_at: data.banned_at * 1000,
|
|
|
|
})),
|
2017-04-22 12:51:21 +00:00
|
|
|
}),
|
|
|
|
true
|
|
|
|
);
|
|
|
|
});
|
|
|
|
};
|