王一之 9f8f7c8347
Some checks failed
test / Run tests (push) Failing after 9s
build / Build (push) Failing after 16s
gm api通信
2025-01-26 15:39:14 +08:00

25 lines
614 B
TypeScript

import { Message, MessageConnect } from "./server";
export function sendMessage(msg: Message, action: string, data?: any): Promise<any> {
return msg.sendMessage({ action, data });
}
export function connect(msg: Message, action: string, data?: any): Promise<MessageConnect> {
return msg.connect({ action, data });
}
export class Client {
constructor(
private msg: Message,
private prefix: string
) {
if (!this.prefix.endsWith("/")) {
this.prefix += "/";
}
}
do(action: string, params?: any): Promise<any> {
return sendMessage(this.msg, this.prefix + action, params);
}
}