mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
feat: support SetInputStatus
This commit is contained in:
parent
caf23792cb
commit
caaa6ed506
@ -16,6 +16,9 @@ export class NTQQMsgApi {
|
||||
return this.context.session.getMsgService().fetchLongMsg(peer, msgId);
|
||||
}
|
||||
|
||||
async sendShowInputStatusReq(peer: Peer, eventType: number) {
|
||||
return this.context.session.getMsgService().sendShowInputStatusReq(peer.chatType, eventType, peer.peerUid);
|
||||
}
|
||||
async getMsgEmojiLikesList(peer: Peer, msgSeq: string, emojiId: string, emojiType: string, count: number = 20) {
|
||||
//console.log(peer, msgSeq, emojiId, emojiType, count);
|
||||
//注意此处emojiType 可选值一般为1-2 2好像是unicode表情dec值 大部分情况 Taged M likiowa
|
||||
|
44
src/onebot/action/extends/SetInputStatus.ts
Normal file
44
src/onebot/action/extends/SetInputStatus.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { ChatType, Peer } from '@/core';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
eventType: { type: 'string' },
|
||||
group_id: { type: 'string' },
|
||||
user_id: { type: 'string' }
|
||||
},
|
||||
required: ['eventType'],
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class SetInputStatus extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.SetInputStatus;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQUserApi = this.CoreContext.apis.UserApi;
|
||||
const NTQQMsgApi = this.CoreContext.apis.MsgApi;
|
||||
let peer: Peer;
|
||||
if (payload.group_id) {
|
||||
peer = {
|
||||
chatType: ChatType.group,
|
||||
peerUid: payload.group_id
|
||||
}
|
||||
} else if (payload.user_id) {
|
||||
let uid = await NTQQUserApi.getUidByUinV2(payload.user_id);
|
||||
if (!uid) throw new Error('uid is empty');
|
||||
peer = {
|
||||
chatType: ChatType.friend,
|
||||
peerUid: uid
|
||||
}
|
||||
} else {
|
||||
throw new Error('请指定 group_id 或 user_id');
|
||||
}
|
||||
|
||||
const ret = await NTQQMsgApi.sendShowInputStatusReq(peer, parseInt(payload.eventType));
|
||||
return ret;
|
||||
}
|
||||
}
|
@ -78,6 +78,7 @@ import { NapCatCore } from '@/core';
|
||||
import { NapCatOneBot11Adapter } from '@/onebot';
|
||||
import GetGuildProfile from './guild/GetGuildProfile';
|
||||
import SetModelShow from './go-cqhttp/SetModelShow';
|
||||
import { SetInputStatus } from './extends/SetInputStatus';
|
||||
|
||||
export type ActionMap = Map<string, BaseAction<any, any>>;
|
||||
|
||||
@ -165,6 +166,7 @@ export function createActionMap(onebotContext: NapCatOneBot11Adapter, coreContex
|
||||
new GoCQHTTPUploadPrivateFile(onebotContext, coreContext),
|
||||
new GetGuildProfile(onebotContext, coreContext),
|
||||
new SetModelShow(onebotContext, coreContext),
|
||||
new SetInputStatus(onebotContext, coreContext),
|
||||
];
|
||||
const actionMap = new Map();
|
||||
for (const action of actionHandlers) {
|
||||
|
@ -106,5 +106,6 @@ export enum ActionName {
|
||||
TestApi01 = 'test_api_01',
|
||||
FetchEmojiLike = 'fetch_emoji_like',
|
||||
GetGuildProfile = "get_guild_service_profile",
|
||||
SetModelShow = "_set_model_show"
|
||||
SetModelShow = "_set_model_show",
|
||||
SetInputStatus = "set_input_status"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user