mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
feat:GetUserStatus
This commit is contained in:
parent
30e594ae5f
commit
b4e22a345d
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",
|
||||
}
|
||||
|
@ -541,26 +541,26 @@ export class NapCatOneBot11Adapter {
|
||||
if (isSelfMsg) {
|
||||
ob11Msg.target_id = parseInt(message.peerUin);
|
||||
}
|
||||
if (ob11Msg.raw_message.startsWith('!status')) {
|
||||
console.log('status', message.peerUin, message.senderUin);
|
||||
let delMsg: string[] = [];
|
||||
let peer = {
|
||||
peerUid: message.peerUin,
|
||||
chatType: 2,
|
||||
};
|
||||
this.core.apis.PacketApi.sendStatusPacket(+message.senderUin).then(async e => {
|
||||
if (e) {
|
||||
const { sendElements } = await this.apis.MsgApi.createSendElements([{
|
||||
type: OB11MessageDataType.text,
|
||||
data: {
|
||||
text: 'status ' + JSON.stringify(e, null, 2),
|
||||
}
|
||||
}], peer)
|
||||
// if (ob11Msg.raw_message.startsWith('!status')) {
|
||||
// console.log('status', message.peerUin, message.senderUin);
|
||||
// let delMsg: string[] = [];
|
||||
// let peer = {
|
||||
// peerUid: message.peerUin,
|
||||
// chatType: 2,
|
||||
// };
|
||||
// this.core.apis.PacketApi.sendStatusPacket(+message.senderUin).then(async e => {
|
||||
// if (e) {
|
||||
// const { sendElements } = await this.apis.MsgApi.createSendElements([{
|
||||
// type: OB11MessageDataType.text,
|
||||
// data: {
|
||||
// text: 'status ' + JSON.stringify(e, null, 2),
|
||||
// }
|
||||
// }], peer)
|
||||
|
||||
this.apis.MsgApi.sendMsgWithOb11UniqueId(peer, sendElements, delMsg)
|
||||
}
|
||||
})
|
||||
}
|
||||
// this.apis.MsgApi.sendMsgWithOb11UniqueId(peer, sendElements, delMsg)
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
this.networkManager.emitEvent(ob11Msg);
|
||||
}).catch(e => this.context.logger.logError.bind(this.context.logger)('constructMessage error: ', e));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user