mirror of
https://github.com/thelounge/thelounge
synced 2024-11-24 21:13:06 +00:00
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.
This commit is contained in:
parent
5274fdc21a
commit
071a5afda6
3 changed files with 59 additions and 50 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
57
server/plugins/inputs/ignorelist.ts
Normal file
57
server/plugins/inputs/ignorelist.ts
Normal file
|
@ -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,
|
||||
};
|
|
@ -54,6 +54,7 @@ const builtInInputs = [
|
|||
"ctcp",
|
||||
"disconnect",
|
||||
"ignore",
|
||||
"ignorelist",
|
||||
"invite",
|
||||
"kick",
|
||||
"kill",
|
||||
|
|
Loading…
Reference in a new issue