26 包 monorepo(TS 全源码): - snowcat-core: NT 内核 API 封装 + listener(含 9.9.37 六回调适配)+ Packet 发包 - snowcat-onebot: OneBot v11 全动作 + MCP Streamable HTTP 适配器 + 稳定线 - snowcat-webui-frontend/backend: 雪猫控制台(React+HeroUI) - snowcat-shell: 单文件 bundle 出口(vite inlineDynamicImports) - snowcat-native: napi2native / MoeHoo / ffmpeg / pty 运行时 - 56 项 SnowLuma 独门动作移植(qzone 全家桶/群相册/装扮/闪照/收藏) - 工具件: 解包器/启动器/便携制作器/doctor GitHub 关联已全量指向 DandanLLab/SnowCatQQ
47 lines
2.0 KiB
TypeScript
47 lines
2.0 KiB
TypeScript
import { OB11Construct } from '@/snowcat-onebot/helper/data';
|
|
import { OneBotAction } from '@/snowcat-onebot/action/OneBotAction';
|
|
import { ActionName } from '@/snowcat-onebot/action/router';
|
|
import { Static, Type } from '@sinclair/typebox';
|
|
import { OB11UserSchema } from '../schemas';
|
|
import { UserActionsExamples } from '@/snowcat-onebot/action/example/UserActionsExamples';
|
|
|
|
const PayloadSchema = Type.Object({
|
|
no_cache: Type.Optional(Type.Union([Type.Boolean(), Type.String()], { description: '是否不使用缓存' })),
|
|
});
|
|
|
|
type PayloadType = Static<typeof PayloadSchema>;
|
|
|
|
const ReturnSchema = Type.Array(OB11UserSchema, { description: '好友列表' });
|
|
|
|
type ReturnType = Static<typeof ReturnSchema>;
|
|
|
|
export default class GetFriendList extends OneBotAction<PayloadType, ReturnType> {
|
|
override actionName = ActionName.GetFriendList;
|
|
override payloadSchema = PayloadSchema;
|
|
override returnSchema = ReturnSchema;
|
|
override actionSummary = '获取好友列表';
|
|
override actionDescription = '获取当前帐号的好友列表';
|
|
override actionTags = ['用户接口'];
|
|
override payloadExample = UserActionsExamples.GetFriendList.payload;
|
|
override returnExample = UserActionsExamples.GetFriendList.response;
|
|
|
|
async _handle (_payload: PayloadType) {
|
|
const buddyMap = await this.core.apis.FriendApi.getBuddyV2SimpleInfoMap();
|
|
const isNocache = typeof _payload.no_cache === 'string' ? _payload.no_cache === 'true' : !!_payload.no_cache;
|
|
await Promise.all(
|
|
Array.from(buddyMap.values()).map(async (buddyInfo) => {
|
|
try {
|
|
const userDetail = await this.core.apis.UserApi.getUserDetailInfo(buddyInfo.coreInfo.uid, isNocache);
|
|
const data = buddyMap.get(buddyInfo.coreInfo.uid);
|
|
if (data) {
|
|
data.qqLevel = userDetail.qqLevel;
|
|
}
|
|
} catch (error) {
|
|
this.core.context.logger.logError('获取好友详细信息失败', error);
|
|
}
|
|
})
|
|
);
|
|
return OB11Construct.friends(Array.from(buddyMap.values()));
|
|
}
|
|
}
|