mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
feat: no_cache
This commit is contained in:
@@ -7,6 +7,7 @@ import { Static, Type } from '@sinclair/typebox';
|
|||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
user_id: Type.Union([Type.Number(), Type.String()]),
|
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||||
|
no_cache: Type.Union([Type.Boolean(), Type.String()], { default: false }),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
@@ -16,10 +17,11 @@ export default class GoCQHTTPGetStrangerInfo extends OneBotAction<Payload, OB11U
|
|||||||
override payloadSchema = SchemaData;
|
override payloadSchema = SchemaData;
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const user_id = payload.user_id.toString();
|
const user_id = payload.user_id.toString();
|
||||||
|
const isNocache = typeof payload.no_cache === 'string' ? payload.no_cache === 'true' : !!payload.no_cache;
|
||||||
const extendData = await this.core.apis.UserApi.getUserDetailInfoByUin(user_id);
|
const extendData = await this.core.apis.UserApi.getUserDetailInfoByUin(user_id);
|
||||||
let uid = (await this.core.apis.UserApi.getUidByUinV2(user_id));
|
let uid = (await this.core.apis.UserApi.getUidByUinV2(user_id));
|
||||||
if (!uid) uid = extendData.detail.uid;
|
if (!uid) uid = extendData.detail.uid;
|
||||||
const info = (await this.core.apis.UserApi.getUserDetailInfo(uid));
|
const info = (await this.core.apis.UserApi.getUserDetailInfo(uid, isNocache));
|
||||||
return {
|
return {
|
||||||
...extendData.detail.simpleInfo.coreInfo,
|
...extendData.detail.simpleInfo.coreInfo,
|
||||||
...extendData.detail.commonExt ?? {},
|
...extendData.detail.commonExt ?? {},
|
||||||
|
@@ -32,7 +32,7 @@ class GetGroupMemberInfo extends OneBotAction<Payload, OB11GroupMember> {
|
|||||||
|
|
||||||
const [member, info] = await Promise.all([
|
const [member, info] = await Promise.all([
|
||||||
this.core.apis.GroupApi.getGroupMemberEx(payload.group_id.toString(), uid, isNocache),
|
this.core.apis.GroupApi.getGroupMemberEx(payload.group_id.toString(), uid, isNocache),
|
||||||
this.core.apis.UserApi.getUserDetailInfo(uid),
|
this.core.apis.UserApi.getUserDetailInfo(uid, isNocache),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!member || !groupMember) throw new Error(`群(${payload.group_id})成员${payload.user_id}不存在`);
|
if (!member || !groupMember) throw new Error(`群(${payload.group_id})成员${payload.user_id}不存在`);
|
||||||
|
@@ -16,11 +16,11 @@ export default class GetFriendList extends OneBotAction<Payload, OB11User[]> {
|
|||||||
|
|
||||||
async _handle(_payload: Payload) {
|
async _handle(_payload: Payload) {
|
||||||
const buddyMap = await this.core.apis.FriendApi.getBuddyV2SimpleInfoMap();
|
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(
|
await Promise.all(
|
||||||
Array.from(buddyMap.values()).map(async (buddyInfo) => {
|
Array.from(buddyMap.values()).map(async (buddyInfo) => {
|
||||||
try {
|
try {
|
||||||
const userDetail = await this.core.apis.UserApi.getUserDetailInfo(buddyInfo.coreInfo.uid);
|
const userDetail = await this.core.apis.UserApi.getUserDetailInfo(buddyInfo.coreInfo.uid, isNocache);
|
||||||
const data = buddyMap.get(buddyInfo.coreInfo.uid);
|
const data = buddyMap.get(buddyInfo.coreInfo.uid);
|
||||||
if (data) {
|
if (data) {
|
||||||
data.qqLevel = userDetail.qqLevel;
|
data.qqLevel = userDetail.qqLevel;
|
||||||
|
@@ -100,7 +100,7 @@ export class NapCatOneBot11Adapter {
|
|||||||
const selfInfo = this.core.selfInfo;
|
const selfInfo = this.core.selfInfo;
|
||||||
const ob11Config = this.configLoader.configData;
|
const ob11Config = this.configLoader.configData;
|
||||||
|
|
||||||
this.core.apis.UserApi.getUserDetailInfo(selfInfo.uid)
|
this.core.apis.UserApi.getUserDetailInfo(selfInfo.uid, false)
|
||||||
.then((user) => {
|
.then((user) => {
|
||||||
selfInfo.nick = user.nick;
|
selfInfo.nick = user.nick;
|
||||||
this.context.logger.setLogSelfInfo(selfInfo);
|
this.context.logger.setLogSelfInfo(selfInfo);
|
||||||
|
Reference in New Issue
Block a user