Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ignore: move ignorelist to its own command
ignorelist shares no logic with /ignore or /unignore so it shouldn't share a file. That just makes typing awkward.
- Loading branch information
Showing
3 changed files
with
59 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import {PluginInputHandler} from "./index"; | ||
import Msg from "../../models/msg"; | ||
import {ChanType, SpecialChanType} from "../../../shared/types/chan"; | ||
import {MessageType} from "../../../shared/types/msg"; | ||
|
||
const commands = ["ignorelist"]; | ||
|
||
const input: PluginInputHandler = function (network, chan, cmd, args) { | ||
const client = this; | ||
|
||
if (network.ignoreList.length === 0) { | ||
chan.pushMessage( | ||
client, | ||
new Msg({ | ||
type: MessageType.ERROR, | ||
text: "Ignorelist is empty", | ||
}) | ||
); | ||
return; | ||
} | ||
|
||
const chanName = "Ignored users"; | ||
const ignored = network.ignoreList.map((data) => ({ | ||
hostmask: `${data.nick}!${data.ident}@${data.hostname}`, | ||
when: data.when, | ||
})); | ||
let newChan = network.getChannel(chanName); | ||
|
||
if (typeof newChan === "undefined") { | ||
newChan = client.createChannel({ | ||
type: ChanType.SPECIAL, | ||
special: SpecialChanType.IGNORELIST, | ||
name: chanName, | ||
data: ignored, | ||
}); | ||
client.emit("join", { | ||
network: network.uuid, | ||
chan: newChan.getFilteredClone(true), | ||
shouldOpen: false, | ||
index: network.addChannel(newChan), | ||
}); | ||
return; | ||
} | ||
|
||
// TODO: add type for this chan/event | ||
newChan.data = ignored; | ||
|
||
client.emit("msg:special", { | ||
chan: newChan.id, | ||
data: ignored, | ||
}); | ||
}; | ||
|
||
export default { | ||
commands, | ||
input, | ||
}; |
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 |
---|---|---|
|
@@ -54,6 +54,7 @@ const builtInInputs = [ | |
"ctcp", | ||
"disconnect", | ||
"ignore", | ||
"ignorelist", | ||
"invite", | ||
"kick", | ||
"kill", | ||
|