mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix: 初始化问题
This commit is contained in:
parent
056e0adddf
commit
9e05e086eb
@ -3,7 +3,7 @@ import fs from 'node:fs';
|
|||||||
import { systemPlatform } from '@/common/utils/system';
|
import { systemPlatform } from '@/common/utils/system';
|
||||||
import { getDefaultQQVersionConfigInfo, getQQVersionConfigPath } from './helper';
|
import { getDefaultQQVersionConfigInfo, getQQVersionConfigPath } from './helper';
|
||||||
import AppidTable from '@/core/external/appid.json';
|
import AppidTable from '@/core/external/appid.json';
|
||||||
import { logNotice } from '@/onebot11/log';
|
import { log } from './log';
|
||||||
|
|
||||||
//基础目录获取
|
//基础目录获取
|
||||||
export let QQMainPath = process.execPath;
|
export let QQMainPath = process.execPath;
|
||||||
@ -11,9 +11,9 @@ export let QQPackageInfoPath: string = path.join(path.dirname(QQMainPath), 'reso
|
|||||||
export let QQVersionConfigPath: string | undefined = getQQVersionConfigPath(QQMainPath);
|
export let QQVersionConfigPath: string | undefined = getQQVersionConfigPath(QQMainPath);
|
||||||
|
|
||||||
//基础信息获取 无快更则启用默认模板填充
|
//基础信息获取 无快更则启用默认模板填充
|
||||||
export let { appid: QQVersionAppid, qua: QQVersionQua } = getAppidV2();
|
|
||||||
export let isQuickUpdate: boolean = !!QQVersionConfigPath;
|
export let isQuickUpdate: boolean = !!QQVersionConfigPath;
|
||||||
export let QQVersionConfig: QQVersionConfigType = isQuickUpdate ? JSON.parse(fs.readFileSync(QQVersionConfigPath!).toString()) : getDefaultQQVersionConfigInfo();
|
export let QQVersionConfig: QQVersionConfigType = isQuickUpdate ? JSON.parse(fs.readFileSync(QQVersionConfigPath!).toString()) : getDefaultQQVersionConfigInfo();
|
||||||
|
export let { appid: QQVersionAppid, qua: QQVersionQua } = getAppidV2();
|
||||||
export let QQPackageInfo: QQPackageInfoType = JSON.parse(fs.readFileSync(QQPackageInfoPath).toString());
|
export let QQPackageInfo: QQPackageInfoType = JSON.parse(fs.readFileSync(QQPackageInfoPath).toString());
|
||||||
|
|
||||||
//基础函数
|
//基础函数
|
||||||
@ -39,7 +39,7 @@ export function getAppidV2(): { appid: string, qua: string } {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logNotice('[QQ版本兼容性检测] 版本兼容性不佳,可能会导致一些功能无法正常使用');
|
log('[QQ版本兼容性检测] 版本兼容性不佳,可能会导致一些功能无法正常使用', e);
|
||||||
}
|
}
|
||||||
// 以下是兜底措施
|
// 以下是兜底措施
|
||||||
return { appid: systemPlatform === 'linux' ? '537237950' : '537237765', qua: getQUAInternal() };
|
return { appid: systemPlatform === 'linux' ? '537237950' : '537237765', qua: getQUAInternal() };
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
import { FriendRequest, User } from '@/core/entities';
|
import { FriendRequest, User } from '@/core/entities';
|
||||||
import { BuddyListReqType, napCatCore, OnBuddyChangeParams } from '@/core';
|
import { BuddyListReqType, napCatCore, NodeIKernelBuddyListener, OnBuddyChangeParams } from '@/core';
|
||||||
import { NTEventDispatch } from '@/common/utils/EventTask';
|
import { NTEventDispatch } from '@/common/utils/EventTask';
|
||||||
|
|
||||||
export class NTQQFriendApi {
|
export class NTQQFriendApi {
|
||||||
static async getBuddyV2(refresh = false) {
|
static async getBuddyV2(refresh = false) {
|
||||||
|
NTEventDispatch.RegisterListen<NodeIKernelBuddyListener['onBuddyListChange']>('NodeIKernelBuddyListener/onBuddyListChange', 1, 5000, (arg: OnBuddyChangeParams) => {
|
||||||
|
console.log(arg);
|
||||||
|
return true;
|
||||||
|
}).catch().then();
|
||||||
if (!refresh) {
|
if (!refresh) {
|
||||||
return await napCatCore.session.getBuddyService().getBuddyListFromCache('0');
|
return await napCatCore.session.getBuddyService().getBuddyListFromCache('0');
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import { ActionName, BaseCheckResult } from '@/onebot11/action/types';
|
|||||||
import { getGroup } from '@/core/data';
|
import { getGroup } from '@/core/data';
|
||||||
import { ChatType, ElementType, Group, NTQQFileApi, NTQQFriendApi, NTQQMsgApi, NTQQUserApi, Peer, SendMessageElement, } from '@/core';
|
import { ChatType, ElementType, Group, NTQQFileApi, NTQQFriendApi, NTQQMsgApi, NTQQUserApi, Peer, SendMessageElement, } from '@/core';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
|
import fsPromise from 'node:fs/promises';
|
||||||
import { logDebug, logError } from '@/common/utils/log';
|
import { logDebug, logError } from '@/common/utils/log';
|
||||||
import { decodeCQCode } from '@/onebot11/cqcode';
|
import { decodeCQCode } from '@/onebot11/cqcode';
|
||||||
import createSendElements from './create-send-elements';
|
import createSendElements from './create-send-elements';
|
||||||
@ -71,14 +72,7 @@ export async function sendMsg(peer: Peer, sendElements: SendMessageElement[], de
|
|||||||
logDebug('发送消息id获取失败', e);
|
logDebug('发送消息id获取失败', e);
|
||||||
returnMsg!.id = 0;
|
returnMsg!.id = 0;
|
||||||
}
|
}
|
||||||
|
deleteAfterSentFiles.map((f) => { fsPromise.unlink(f).then().catch(e => logError('发送消息删除文件失败', e)); });
|
||||||
deleteAfterSentFiles.map((f) => {
|
|
||||||
try {
|
|
||||||
fs.unlinkSync(f);
|
|
||||||
} catch (e) {
|
|
||||||
logError('发送消息删除文件失败', e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return returnMsg;
|
return returnMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ export default class GetFriendList extends BaseAction<Payload, OB11User[]> {
|
|||||||
actionName = ActionName.GetFriendList;
|
actionName = ActionName.GetFriendList;
|
||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
|
let data = await NTQQFriendApi.getBuddyV2(payload?.no_cache === true || payload?.no_cache=== 'true');
|
||||||
if (friends.size === 0 || payload?.no_cache === true || payload?.no_cache === 'true') {
|
if (friends.size === 0 || payload?.no_cache === true || payload?.no_cache === 'true') {
|
||||||
const _friends = await NTQQFriendApi.getFriends(true);
|
const _friends = await NTQQFriendApi.getFriends(true);
|
||||||
// log('强制刷新好友列表,结果: ', _friends)
|
// log('强制刷新好友列表,结果: ', _friends)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user