Skip to content

Commit

Permalink
Merge pull request #662 from Shua-github/main
Browse files Browse the repository at this point in the history
新增send_poke
  • Loading branch information
MliKiowa authored Dec 27, 2024
2 parents 9cd15ae + d5e7e89 commit d78409f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/onebot/action/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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];
Expand Down
23 changes: 23 additions & 0 deletions src/onebot/action/packet/SendPoke.ts
Original file line number Diff line number Diff line change
@@ -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<typeof SchemaData>;

export class SendPoke extends GetPacketStatusDepends<Payload, any> {
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);
}
}
}
2 changes: 2 additions & 0 deletions src/onebot/action/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,6 @@ export const ActionName = {
SendGroupAiRecord: "send_group_ai_record",

GetClientkey: "get_clientkey",

SendPoke: 'send_poke',
} as const;

0 comments on commit d78409f

Please sign in to comment.