Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1009 from thelounge/yamanickill/1008-banlist
Add support for banlist messages
- Loading branch information
Showing
9 changed files
with
101 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<table class="ban-list"> | ||
<thead> | ||
<tr> | ||
<th class="hostmask">Banned</th> | ||
<th class="banned_by">Banned By</th> | ||
<th class="banned_at">Banned At</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each bans}} | ||
<tr> | ||
<td class="hostmask">{{hostmask}}</td> | ||
<td class="banned_by">{{{parse banned_by}}}</td> | ||
<td class="banned_at">{{{localetime banned_at}}}</td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ var id = 0; | |
var events = [ | ||
"connection", | ||
"unhandled", | ||
"banlist", | ||
"ctcp", | ||
"error", | ||
"invite", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"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; | ||
if (!bans) { | ||
const msg = new Msg({ | ||
time: Date.now(), | ||
type: Msg.Type.ERROR, | ||
text: "Banlist empty" | ||
}); | ||
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, | ||
name: chanName | ||
}); | ||
network.channels.push(chan); | ||
client.emit("join", { | ||
network: network.id, | ||
chan: chan | ||
}); | ||
} | ||
|
||
chan.pushMessage(client, | ||
new Msg({ | ||
type: Msg.Type.BANLIST, | ||
bans: bans.map((data) => ({ | ||
hostmask: data.banned, | ||
banned_by: data.banned_by, | ||
banned_at: data.banned_at * 1000 | ||
})) | ||
}), | ||
true | ||
); | ||
}); | ||
}; |