mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
feat:GetUserStatus
This commit is contained in:
25
src/onebot/action/extends/GetUserStatus.ts
Normal file
25
src/onebot/action/extends/GetUserStatus.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
// no_cache get时传字符串
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
user_id: { type: ['number', 'string'] },
|
||||
},
|
||||
required: ['user_id'],
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GetUserStatus extends BaseAction<Payload, { status: number; ext_status: number; } | undefined> {
|
||||
actionName = ActionName.GetUserStatus;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
if (!this.core.apis.PacketApi.PacketClient?.isConnected) {
|
||||
throw new Error('PacketClient is not init');
|
||||
}
|
||||
return await this.core.apis.PacketApi.sendStatusPacket(+payload.user_id);
|
||||
}
|
||||
}
|
@@ -85,6 +85,7 @@ import { GetGroupRootFiles } from '@/onebot/action/go-cqhttp/GetGroupRootFiles';
|
||||
import { GetGroupFilesByFolder } from '@/onebot/action/go-cqhttp/GetGroupFilesByFolder';
|
||||
import { GetGroupSystemMsg } from './system/GetSystemMsg';
|
||||
import { GroupPoke } from './group/GroupPoke';
|
||||
import { GetUserStatus } from './extends/GetUserStatus';
|
||||
|
||||
|
||||
export type ActionMap = Map<string, BaseAction<any, any>>;
|
||||
@@ -182,6 +183,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
||||
new GetGroupSystemMsg(obContext, core),
|
||||
new FetchUserProfileLike(obContext, core),
|
||||
new GroupPoke(obContext, core),
|
||||
new GetUserStatus(obContext, core),
|
||||
];
|
||||
const actionMap = new Map();
|
||||
for (const action of actionHandlers) {
|
||||
|
@@ -120,4 +120,5 @@ export enum ActionName {
|
||||
GetGroupInfoEx = "get_group_info_ex",
|
||||
GetGroupSystemMsg = 'get_group_system_msg',
|
||||
FetchUserProfileLike = "fetch_user_profile_like",
|
||||
GetUserStatus = "nc_get_user_status",
|
||||
}
|
||||
|
Reference in New Issue
Block a user