Update messages

This commit is contained in:
Hri7566 2024-09-19 20:27:13 -04:00
parent 9fcc3864c0
commit 937082694e
5 changed files with 42 additions and 15 deletions

View File

@ -1,6 +1,9 @@
import { Logger } from "~/util/Logger";
import { ChannelList } from "../../../../channel/ChannelList"; import { ChannelList } from "../../../../channel/ChannelList";
import { ServerEventListener, TChannelFlags } from "../../../../util/types"; import { ServerEventListener, TChannelFlags } from "../../../../util/types";
const logger = new Logger("Channel flag input");
export const ch_flag: ServerEventListener<"ch_flag"> = { export const ch_flag: ServerEventListener<"ch_flag"> = {
id: "ch_flag", id: "ch_flag",
callback: async (msg, socket) => { callback: async (msg, socket) => {
@ -17,7 +20,7 @@ export const ch_flag: ServerEventListener<"ch_flag"> = {
if (typeof msg.key !== "string") return; if (typeof msg.key !== "string") return;
if (typeof msg.value === "undefined") return; if (typeof msg.value === "undefined") return;
const ch = ChannelList.getList().find(c => c.getID() == chid); const ch = ChannelList.getChannel(chid);
if (!ch) return; if (!ch) return;
ch.setFlag( ch.setFlag(

View File

@ -1,5 +1,5 @@
import { forceloadChannel } from "../../../../channel/forceLoad"; import { forceloadChannel } from "~/channel/forceload";
import { ServerEventListener } from "../../../../util/types"; import { ServerEventListener } from "~/util/types";
export const forceload: ServerEventListener<"forceload"> = { export const forceload: ServerEventListener<"forceload"> = {
id: "forceload", id: "forceload",

View File

@ -0,0 +1,12 @@
import { forceloadChannel, unforceloadChannel } from "~/channel/forceload";
import { ServerEventListener } from "~/util/types";
export const unforceload: ServerEventListener<"unforceload"> = {
id: "unforceload",
callback: async (msg, socket) => {
// Unforceload channel
if (typeof msg._id !== "string") return;
unforceloadChannel(msg._id);
}
};

View File

@ -1,17 +1,20 @@
import { EventGroup, eventGroups } from "../../events"; import { EventGroup, eventGroups } from "../../events";
import { admin_chat } from "./handlers/admin_chat"; import { admin_chat } from "./handlers/admin_chat";
import { ch_flag } from "./handlers/ch_flag";
import { clear_chat } from "./handlers/clear_chat"; import { clear_chat } from "./handlers/clear_chat";
export const EVENT_GROUP_ADMIN = new EventGroup("admin"); export const EVENT_GROUP_ADMIN = new EventGroup("admin");
import { color } from "./handlers/color"; import { color } from "./handlers/color";
import { eval_msg } from "./handlers/eval"; import { eval_msg } from "./handlers/eval";
import { forceload } from "./handlers/forceload";
import { move } from "./handlers/move"; import { move } from "./handlers/move";
import { name } from "./handlers/name"; import { name } from "./handlers/name";
import { notification } from "./handlers/notification"; import { notification } from "./handlers/notification";
import { rename_channel } from "./handlers/rename_channel"; import { rename_channel } from "./handlers/rename_channel";
import { restart } from "./handlers/restart"; import { restart } from "./handlers/restart";
import { tag } from "./handlers/tag"; import { tag } from "./handlers/tag";
import { unforceload } from "./handlers/unforceload";
import { user_flag } from "./handlers/user_flag"; import { user_flag } from "./handlers/user_flag";
// EVENT_GROUP_ADMIN.add(color); // EVENT_GROUP_ADMIN.add(color);
@ -19,17 +22,20 @@ import { user_flag } from "./handlers/user_flag";
// EVENT_GROUP_ADMIN.add(user_flag); // EVENT_GROUP_ADMIN.add(user_flag);
EVENT_GROUP_ADMIN.addMany( EVENT_GROUP_ADMIN.addMany(
color, color,
name, name,
user_flag, user_flag,
clear_chat, clear_chat,
notification, notification,
restart, restart,
move, move,
rename_channel, rename_channel,
admin_chat, admin_chat,
eval_msg, eval_msg,
tag tag,
ch_flag,
forceload,
unforceload
); );
eventGroups.push(EVENT_GROUP_ADMIN); eventGroups.push(EVENT_GROUP_ADMIN);

View File

@ -17,6 +17,9 @@ import { kickban } from "./handlers/kickban";
import { bye } from "./handlers/bye"; import { bye } from "./handlers/bye";
import { chown } from "./handlers/chown"; import { chown } from "./handlers/chown";
import { unban } from "./handlers/unban"; import { unban } from "./handlers/unban";
import { plus_custom } from "./handlers/+custom";
import { minus_custom } from "./handlers/-custom";
import { custom } from "./handlers/custom";
// Imagine not having an "addMany" function... // Imagine not having an "addMany" function...
@ -48,7 +51,10 @@ EVENTGROUP_USER.addMany(
kickban, kickban,
unban, unban,
bye, bye,
chown chown,
plus_custom,
minus_custom,
custom
); );
eventGroups.push(EVENTGROUP_USER); eventGroups.push(EVENTGROUP_USER);