From a9e471deca1dbbec66905c01bfbb7afb78132404 Mon Sep 17 00:00:00 2001 From: Shua-github Date: Fri, 27 Dec 2024 00:24:35 +0800 Subject: [PATCH 1/3] =?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; From fb405a5c1cbf2d668d5fd40611325785fcb8f705 Mon Sep 17 00:00:00 2001 From: Shua-github Date: Fri, 27 Dec 2024 13:15:10 +0800 Subject: [PATCH 2/3] =?UTF-8?q?all=5Fpoke=E6=9B=BF=E6=8D=A2=E6=88=90send?= =?UTF-8?q?=5Fpoke?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/packet/context/operationContext.ts | 2 +- src/onebot/action/index.ts | 4 ++-- src/onebot/action/packet/{AllPoke.ts => SendPoke.ts} | 6 +++--- src/onebot/action/router.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) rename src/onebot/action/packet/{AllPoke.ts => SendPoke.ts} (66%) diff --git a/src/core/packet/context/operationContext.ts b/src/core/packet/context/operationContext.ts index fb9aaad1..4b32e158 100644 --- a/src/core/packet/context/operationContext.ts +++ b/src/core/packet/context/operationContext.ts @@ -149,7 +149,7 @@ export class PacketOperationContext { } } - async AllPoke(uin: number, groupUin?: number) { + async SendPoke(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 967f24bc..81f31882 100644 --- a/src/onebot/action/index.ts +++ b/src/onebot/action/index.ts @@ -104,7 +104,7 @@ 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"; +import { SendPoke } from "@/onebot/action/packet/SendPoke"; export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) { @@ -221,7 +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), + new SendPoke(obContext, core), ]; type HandlerUnion = typeof actionHandlers[number]; diff --git a/src/onebot/action/packet/AllPoke.ts b/src/onebot/action/packet/SendPoke.ts similarity index 66% rename from src/onebot/action/packet/AllPoke.ts rename to src/onebot/action/packet/SendPoke.ts index 08fb3af3..ed403adb 100644 --- a/src/onebot/action/packet/AllPoke.ts +++ b/src/onebot/action/packet/SendPoke.ts @@ -9,11 +9,11 @@ const SchemaData = Type.Object({ type Payload = Static; -export class AllPoke extends GetPacketStatusDepends { - actionName = ActionName.AllPoke; +export class SendPoke extends GetPacketStatusDepends { + actionName = ActionName.SendPoke; payloadSchema = SchemaData; async _handle(payload: Payload) { - await this.core.apis.PacketApi.pkt.operation.AllPoke(+payload.user_id, payload.group_id ? +payload.group_id : undefined); + await this.core.apis.PacketApi.pkt.operation.SendPoke(+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 3e50fbad..7b79c50f 100644 --- a/src/onebot/action/router.ts +++ b/src/onebot/action/router.ts @@ -146,5 +146,5 @@ export const ActionName = { GetClientkey: "get_clientkey", - AllPoke: 'all_poke', + SendPoke: 'send_poke', } as const; From d5e7e8944fcd58de5e372cc863febabc560a84e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Fri, 27 Dec 2024 15:14:57 +0800 Subject: [PATCH 3/3] feat: send_poke --- src/core/packet/context/operationContext.ts | 4 ---- src/onebot/action/packet/SendPoke.ts | 6 +++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/packet/context/operationContext.ts b/src/core/packet/context/operationContext.ts index 4b32e158..3cf21980 100644 --- a/src/core/packet/context/operationContext.ts +++ b/src/core/packet/context/operationContext.ts @@ -148,8 +148,4 @@ export class PacketOperationContext { return res.msgInfo; } } - - async SendPoke(uin: number, groupUin?: number) { - await (groupUin ? this.GroupPoke(uin,groupUin) : this.FriendPoke(uin)); - } } diff --git a/src/onebot/action/packet/SendPoke.ts b/src/onebot/action/packet/SendPoke.ts index ed403adb..13819a66 100644 --- a/src/onebot/action/packet/SendPoke.ts +++ b/src/onebot/action/packet/SendPoke.ts @@ -14,6 +14,10 @@ export class SendPoke extends GetPacketStatusDepends { payloadSchema = SchemaData; async _handle(payload: Payload) { - await this.core.apis.PacketApi.pkt.operation.SendPoke(+payload.user_id, payload.group_id ? +payload.group_id : undefined); + if (payload.group_id) { + this.core.apis.PacketApi.pkt.operation.GroupPoke(+payload.group_id, +payload.user_id); + } else { + this.core.apis.PacketApi.pkt.operation.FriendPoke(+payload.user_id); + } } } \ No newline at end of file