Support mppclone-like messages

This commit is contained in:
Hri7566 2024-10-26 19:45:17 -04:00
parent 71b74d3b77
commit f2687db64c
4 changed files with 32 additions and 2 deletions

9
src/util/types.d.ts vendored
View File

@ -26,9 +26,10 @@ declare type UserFlags = Partial<{
type TChannelFlags = Partial<{
limit: number;
owner_id: string;
owner_id: string; // brandonism
no_crown: boolean;
rainbow: boolean;
player_colors: boolean;
}>;
declare interface Tag {
@ -223,30 +224,35 @@ declare interface IncomingSocketEvents {
// Admin
color: {
// brandonism
m: "color";
_id: string;
color: string;
};
name: {
// brandonism
m: "name";
_id: string;
name: string;
};
setcolor: {
// mppclone
m: "setcolor";
_id: string;
color: string;
};
setname: {
// mppclone
m: "setname";
_id: string;
color: string;
};
user_flag: {
// brandonism
m: "user_flag";
_id: string;
key: keyof UserFlags;
@ -268,6 +274,7 @@ declare interface IncomingSocketEvents {
};
notification: {
// brandonism
m: "notification";
targetChannel?: string;
targetUser?: string;

View File

@ -0,0 +1,10 @@
import { IncomingSocketEvents, ServerEventListener } from "~/util/types";
export const setcolor: ServerEventListener<"setcolor"> = {
id: "setcolor",
callback: async (msg, socket) => {
// color alias
(msg as unknown as IncomingSocketEvents["color"]).m = "color";
socket.admin.emit("color", msg, socket);
}
};

View File

@ -0,0 +1,9 @@
import { ServerEventListener } from "~/util/types";
export const setname: ServerEventListener<"setname"> = {
id: "setname",
callback: async (msg, socket) => {
// name alias
socket.admin.emit("name", msg, socket);
}
};

View File

@ -13,6 +13,8 @@ import { name } from "./handlers/name";
import { notification } from "./handlers/notification";
import { rename_channel } from "./handlers/rename_channel";
import { restart } from "./handlers/restart";
import { setcolor } from "./handlers/setcolor";
import { setname } from "./handlers/setname";
import { tag } from "./handlers/tag";
import { unforceload } from "./handlers/unforceload";
import { user_flag } from "./handlers/user_flag";
@ -35,7 +37,9 @@ EVENT_GROUP_ADMIN.addMany(
tag,
ch_flag,
forceload,
unforceload
unforceload,
setcolor,
setname
);
eventGroups.push(EVENT_GROUP_ADMIN);