diff --git a/src/onebot/action/extends/SetInputStatus.ts b/src/onebot/action/extends/SetInputStatus.ts index 35114fdb..9890cb40 100644 --- a/src/onebot/action/extends/SetInputStatus.ts +++ b/src/onebot/action/extends/SetInputStatus.ts @@ -1,16 +1,15 @@ import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import BaseAction from '../BaseAction'; -import { ActionName } from '../types'; +import { ActionName, BaseCheckResult } from '../types'; import { ChatType, Peer } from '@/core'; const SchemaData = { type: 'object', properties: { - eventType: { type: 'string' }, - group_id: { type: 'string' }, - user_id: { type: 'string' }, + event_type: { type: 'number' }, + user_id: { type: ['number', 'string'] }, }, - required: ['eventType'], + required: ['event_type','user_id'], } as const satisfies JSONSchema; type Payload = FromSchema; @@ -19,23 +18,12 @@ export class SetInputStatus extends BaseAction { actionName = ActionName.SetInputStatus; async _handle(payload: Payload) { - let peer: Peer; - if (payload.group_id) { - peer = { - chatType: ChatType.KCHATTYPEGROUP, - peerUid: payload.group_id, - }; - } else if (payload.user_id) { - const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id); - if (!uid) throw new Error('uid is empty'); - peer = { - chatType: ChatType.KCHATTYPEC2C, - peerUid: uid, - }; - } else { - throw new Error('请指定 group_id 或 user_id'); - } - - return await this.core.apis.MsgApi.sendShowInputStatusReq(peer, parseInt(payload.eventType)); + const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString()); + if (!uid) throw new Error('uid is empty'); + const peer = { + chatType: ChatType.KCHATTYPEC2C, + peerUid: uid, + }; + return await this.core.apis.MsgApi.sendShowInputStatusReq(peer, payload.event_type); } }