mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-27 11:21:21 +08:00
29 lines
888 B
TypeScript
29 lines
888 B
TypeScript
import { OB11Group } from '@/onebot';
|
|
import { OB11Entities } from '@/onebot/entities';
|
|
import BaseAction from '../BaseAction';
|
|
import { ActionName } from '../types';
|
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
|
|
const SchemaData = {
|
|
type: 'object',
|
|
properties: {
|
|
group_id: { type: ['number', 'string'] },
|
|
},
|
|
required: ['group_id'],
|
|
} as const satisfies JSONSchema;
|
|
|
|
type Payload = FromSchema<typeof SchemaData>;
|
|
|
|
class GetGroupInfo extends BaseAction<Payload, OB11Group> {
|
|
actionName = ActionName.GetGroupInfo;
|
|
payloadSchema = SchemaData;
|
|
|
|
async _handle(payload: Payload) {
|
|
const group = (await this.core.apis.GroupApi.getGroups()).find(e => e.groupCode == payload.group_id.toString());
|
|
if (!group) throw `群${payload.group_id}不存在`;
|
|
return OB11Entities.group(group);
|
|
}
|
|
}
|
|
|
|
export default GetGroupInfo;
|