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<{ type TChannelFlags = Partial<{
limit: number; limit: number;
owner_id: string; owner_id: string; // brandonism
no_crown: boolean; no_crown: boolean;
rainbow: boolean; rainbow: boolean;
player_colors: boolean;
}>; }>;
declare interface Tag { declare interface Tag {
@ -223,30 +224,35 @@ declare interface IncomingSocketEvents {
// Admin // Admin
color: { color: {
// brandonism
m: "color"; m: "color";
_id: string; _id: string;
color: string; color: string;
}; };
name: { name: {
// brandonism
m: "name"; m: "name";
_id: string; _id: string;
name: string; name: string;
}; };
setcolor: { setcolor: {
// mppclone
m: "setcolor"; m: "setcolor";
_id: string; _id: string;
color: string; color: string;
}; };
setname: { setname: {
// mppclone
m: "setname"; m: "setname";
_id: string; _id: string;
color: string; color: string;
}; };
user_flag: { user_flag: {
// brandonism
m: "user_flag"; m: "user_flag";
_id: string; _id: string;
key: keyof UserFlags; key: keyof UserFlags;
@ -268,6 +274,7 @@ declare interface IncomingSocketEvents {
}; };
notification: { notification: {
// brandonism
m: "notification"; m: "notification";
targetChannel?: string; targetChannel?: string;
targetUser?: 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 { 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 { setcolor } from "./handlers/setcolor";
import { setname } from "./handlers/setname";
import { tag } from "./handlers/tag"; import { tag } from "./handlers/tag";
import { unforceload } from "./handlers/unforceload"; import { unforceload } from "./handlers/unforceload";
import { user_flag } from "./handlers/user_flag"; import { user_flag } from "./handlers/user_flag";
@ -35,7 +37,9 @@ EVENT_GROUP_ADMIN.addMany(
tag, tag,
ch_flag, ch_flag,
forceload, forceload,
unforceload unforceload,
setcolor,
setname
); );
eventGroups.push(EVENT_GROUP_ADMIN); eventGroups.push(EVENT_GROUP_ADMIN);