From a9e471deca1dbbec66905c01bfbb7afb78132404 Mon Sep 17 00:00:00 2001 From: Shua-github Date: Fri, 27 Dec 2024 00:24:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Eall=5Fpoke?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/packet/context/operationContext.ts | 4 ++++ src/onebot/action/index.ts | 4 +++- src/onebot/action/packet/AllPoke.ts | 19 +++++++++++++++++++ src/onebot/action/router.ts | 2 ++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/onebot/action/packet/AllPoke.ts diff --git a/src/core/packet/context/operationContext.ts b/src/core/packet/context/operationContext.ts index 3cf21980..fb9aaad1 100644 --- a/src/core/packet/context/operationContext.ts +++ b/src/core/packet/context/operationContext.ts @@ -148,4 +148,8 @@ export class PacketOperationContext { return res.msgInfo; } } + + async AllPoke(uin: number, groupUin?: number) { + await (groupUin ? this.GroupPoke(uin,groupUin) : this.FriendPoke(uin)); + } } diff --git a/src/onebot/action/index.ts b/src/onebot/action/index.ts index 77f07eed..967f24bc 100644 --- a/src/onebot/action/index.ts +++ b/src/onebot/action/index.ts @@ -104,7 +104,8 @@ import { GetGuildList } from './guild/GetGuildList'; import { GetGuildProfile } from './guild/GetGuildProfile'; import { GetClientkey } from './extends/GetClientkey'; import { SendPacket } from './extends/SendPacket'; - +import { AllPoke } from "@/onebot/action/packet/AllPoke"; + export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) { const actionHandlers = [ @@ -220,6 +221,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo new SendGroupAiRecord(obContext, core), new GetAiCharacters(obContext, core), new SendPacket(obContext, core), + new AllPoke(obContext, core), ]; type HandlerUnion = typeof actionHandlers[number]; diff --git a/src/onebot/action/packet/AllPoke.ts b/src/onebot/action/packet/AllPoke.ts new file mode 100644 index 00000000..08fb3af3 --- /dev/null +++ b/src/onebot/action/packet/AllPoke.ts @@ -0,0 +1,19 @@ +import { ActionName } from '@/onebot/action/router'; +import { GetPacketStatusDepends } from "@/onebot/action/packet/GetPacketStatus"; +import { Static, Type } from '@sinclair/typebox'; + +const SchemaData = Type.Object({ + group_id: Type.Optional(Type.Union([Type.Number(), Type.String()])), + user_id: Type.Union([Type.Number(), Type.String()]), +}); + +type Payload = Static; + +export class AllPoke extends GetPacketStatusDepends { + actionName = ActionName.AllPoke; + payloadSchema = SchemaData; + + async _handle(payload: Payload) { + await this.core.apis.PacketApi.pkt.operation.AllPoke(+payload.user_id, payload.group_id ? +payload.group_id : undefined); + } +} \ No newline at end of file diff --git a/src/onebot/action/router.ts b/src/onebot/action/router.ts index 990e6ab2..3e50fbad 100644 --- a/src/onebot/action/router.ts +++ b/src/onebot/action/router.ts @@ -145,4 +145,6 @@ export const ActionName = { SendGroupAiRecord: "send_group_ai_record", GetClientkey: "get_clientkey", + + AllPoke: 'all_poke', } as const;