diff --git a/src/onebot/action/index.ts b/src/onebot/action/index.ts index 77f07eedf..81f31882a 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 { SendPoke } from "@/onebot/action/packet/SendPoke"; + 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 SendPoke(obContext, core), ]; type HandlerUnion = typeof actionHandlers[number]; diff --git a/src/onebot/action/packet/SendPoke.ts b/src/onebot/action/packet/SendPoke.ts new file mode 100644 index 000000000..13819a668 --- /dev/null +++ b/src/onebot/action/packet/SendPoke.ts @@ -0,0 +1,23 @@ +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 SendPoke extends GetPacketStatusDepends { + actionName = ActionName.SendPoke; + payloadSchema = SchemaData; + + async _handle(payload: Payload) { + 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 diff --git a/src/onebot/action/router.ts b/src/onebot/action/router.ts index 990e6ab20..7b79c50f2 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", + + SendPoke: 'send_poke', } as const;