diff --git a/server/plugins/inputs/ignore.ts b/server/plugins/inputs/ignore.ts index 0ad761e6..d7e88c3f 100644 --- a/server/plugins/inputs/ignore.ts +++ b/server/plugins/inputs/ignore.ts @@ -3,9 +3,8 @@ import Helper from "../../helper"; import {PluginInputHandler} from "./index"; import {IgnoreListItem} from "../../models/network"; import {MessageType} from "../../../shared/types/msg"; -import {ChanType, SpecialChanType} from "../../../shared/types/chan"; -const commands = ["ignore", "unignore", "ignorelist"]; +const commands = ["ignore", "unignore"]; const input: PluginInputHandler = function (network, chan, cmd, args) { const client = this; @@ -104,54 +103,6 @@ const input: PluginInputHandler = function (network, chan, cmd, args) { }\u000f from ignorelist`, }) ); - - return; - } - - case "ignorelist": { - 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, - }); - - break; } } }; diff --git a/server/plugins/inputs/ignorelist.ts b/server/plugins/inputs/ignorelist.ts new file mode 100644 index 00000000..6bc5ef0f --- /dev/null +++ b/server/plugins/inputs/ignorelist.ts @@ -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, +}; diff --git a/server/plugins/inputs/index.ts b/server/plugins/inputs/index.ts index 95141b5f..af5c0739 100644 --- a/server/plugins/inputs/index.ts +++ b/server/plugins/inputs/index.ts @@ -54,6 +54,7 @@ const builtInInputs = [ "ctcp", "disconnect", "ignore", + "ignorelist", "invite", "kick", "kill",