mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
feat: send_packet
This commit is contained in:
@@ -23,7 +23,9 @@ export class PacketClientSession {
|
|||||||
get operation() {
|
get operation() {
|
||||||
return this.context.operation;
|
return this.context.operation;
|
||||||
}
|
}
|
||||||
|
get client() {
|
||||||
|
return this.context.client;
|
||||||
|
}
|
||||||
// TODO: global message element adapter (?
|
// TODO: global message element adapter (?
|
||||||
get msgConverter() {
|
get msgConverter() {
|
||||||
return this.context.msgConverter;
|
return this.context.msgConverter;
|
||||||
|
21
src/onebot/action/extends/SendPacket.ts
Normal file
21
src/onebot/action/extends/SendPacket.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { GetPacketStatusDepends } from '@/onebot/action/packet/GetPacketStatus';
|
||||||
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
|
const SchemaData = Type.Object({
|
||||||
|
cmd: Type.String(),
|
||||||
|
data: Type.String(),
|
||||||
|
rsp: Type.Union([Type.String(), Type.Boolean()], { default: true }),
|
||||||
|
});
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
|
export class SendPacket extends GetPacketStatusDepends<Payload, any> {
|
||||||
|
payloadSchema = SchemaData;
|
||||||
|
actionName = ActionName.SendPacket;
|
||||||
|
async _handle(payload: Payload) {
|
||||||
|
const rsp = typeof payload.rsp === 'boolean' ? payload.rsp : payload.rsp === 'true';
|
||||||
|
const data = await this.core.apis.PacketApi.pkt.client.sendOidbPacket({ cmd: payload.cmd, data: payload.data as any }, rsp);
|
||||||
|
return typeof data === 'object' ? data.toString('hex') : undefined;
|
||||||
|
}
|
||||||
|
}
|
@@ -103,6 +103,7 @@ import { GetAiCharacters } from "@/onebot/action/extends/GetAiCharacters";
|
|||||||
import { GetGuildList } from './guild/GetGuildList';
|
import { GetGuildList } from './guild/GetGuildList';
|
||||||
import { GetGuildProfile } from './guild/GetGuildProfile';
|
import { GetGuildProfile } from './guild/GetGuildProfile';
|
||||||
import { GetClientkey } from './extends/GetClientkey';
|
import { GetClientkey } from './extends/GetClientkey';
|
||||||
|
import { SendPacket } from './extends/SendPacket';
|
||||||
|
|
||||||
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) {
|
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) {
|
||||||
|
|
||||||
@@ -218,6 +219,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
|||||||
new GetAiRecord(obContext, core),
|
new GetAiRecord(obContext, core),
|
||||||
new SendGroupAiRecord(obContext, core),
|
new SendGroupAiRecord(obContext, core),
|
||||||
new GetAiCharacters(obContext, core),
|
new GetAiCharacters(obContext, core),
|
||||||
|
new SendPacket(obContext, core),
|
||||||
];
|
];
|
||||||
|
|
||||||
type HandlerUnion = typeof actionHandlers[number];
|
type HandlerUnion = typeof actionHandlers[number];
|
||||||
|
@@ -137,7 +137,7 @@ export const ActionName = {
|
|||||||
|
|
||||||
SetGroupSign: "set_group_sign",
|
SetGroupSign: "set_group_sign",
|
||||||
SendGroupSign: "send_group_sign",
|
SendGroupSign: "send_group_sign",
|
||||||
|
SendPacket: "send_packet",
|
||||||
GetMiniAppArk: "get_mini_app_ark",
|
GetMiniAppArk: "get_mini_app_ark",
|
||||||
// UploadForwardMsg : "upload_forward_msg",
|
// UploadForwardMsg : "upload_forward_msg",
|
||||||
GetAiRecord: "get_ai_record",
|
GetAiRecord: "get_ai_record",
|
||||||
|
Reference in New Issue
Block a user