mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
chore: reformat code style
This commit is contained in:
@@ -6,6 +6,7 @@ export type ListenerClassBase = Record<string, string>;
|
||||
export interface ListenerIBase {
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-new
|
||||
new(listener: any): ListenerClassBase;
|
||||
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
@@ -122,7 +123,7 @@ export class NTEventChannel extends EventEmitter {
|
||||
|
||||
async callEvent<EventType extends (...args: any[]) => Promise<any> | any>(
|
||||
EventName = '', timeout: number = 3000, ...args: Parameters<EventType>) {
|
||||
return new Promise<Awaited<ReturnType<EventType>>>(async (resolve, reject) => {
|
||||
return new Promise<Awaited<ReturnType<EventType>>>(async (resolve) => {
|
||||
const EventFunc = this.createEventFunction<EventType>(EventName);
|
||||
const retData = await EventFunc!(...args);
|
||||
resolve(retData);
|
||||
|
@@ -13,6 +13,7 @@ export function isGIF(path: string) {
|
||||
fs.closeSync(fd);
|
||||
return buffer.toString() === 'GIF8';
|
||||
}
|
||||
|
||||
// 定义一个异步函数来检查文件是否存在
|
||||
export function checkFileReceived(path: string, timeout: number = 3000): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -123,15 +124,14 @@ export interface HttpDownloadOptions {
|
||||
}
|
||||
|
||||
export async function httpDownload(options: string | HttpDownloadOptions): Promise<Buffer> {
|
||||
const chunks: Buffer[] = [];
|
||||
// const chunks: Buffer[] = [];
|
||||
let url: string;
|
||||
let headers: Record<string, string> = {
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36',
|
||||
};
|
||||
if (typeof options === 'string') {
|
||||
url = options;
|
||||
const host = new URL(url).hostname;
|
||||
headers['Host'] = host;
|
||||
headers['Host'] = new URL(url).hostname;
|
||||
} else {
|
||||
url = options.url;
|
||||
if (options.headers) {
|
||||
@@ -269,4 +269,4 @@ export async function uri2local(dir: string, uri: string, filename: string | und
|
||||
return { success: true, errMsg: '', fileName: filename, ext: fileExt, path: filePath, isLocal: true };
|
||||
}
|
||||
return { success: false, errMsg: '未知文件类型', fileName: '', ext: '', path: '', isLocal: false };
|
||||
}
|
||||
}
|
||||
|
@@ -18,11 +18,12 @@ export async function solveAsyncProblem<T extends (...args: any[]) => Promise<an
|
||||
return new Promise<Awaited<ReturnType<T>> | undefined>((resolve) => {
|
||||
func(...args).then((result) => {
|
||||
resolve(result);
|
||||
}).catch((e) => {
|
||||
}).catch(() => {
|
||||
resolve(undefined);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//下面这个类是用于将uid+msgid合并的类
|
||||
export class UUIDConverter {
|
||||
static encode(highStr: string, lowStr: string): string {
|
||||
@@ -31,11 +32,10 @@ export class UUIDConverter {
|
||||
const highHex = high.toString(16).padStart(16, '0');
|
||||
const lowHex = low.toString(16).padStart(16, '0');
|
||||
const combinedHex = highHex + lowHex;
|
||||
const uuid = `${combinedHex.substring(0, 8)}-${combinedHex.substring(8, 12)}-${combinedHex.substring(
|
||||
return `${combinedHex.substring(0, 8)}-${combinedHex.substring(8, 12)}-${combinedHex.substring(
|
||||
12,
|
||||
16,
|
||||
)}-${combinedHex.substring(16, 20)}-${combinedHex.substring(20)}`;
|
||||
return uuid;
|
||||
}
|
||||
|
||||
static decode(uuid: string): { high: string; low: string } {
|
||||
|
@@ -177,12 +177,12 @@ export function rawMessageToText(msg: RawMessage, recursiveLevel = 0): string {
|
||||
|
||||
if (element.replyElement) {
|
||||
const recordMsgOrNull = msg.records.find(
|
||||
record => element.replyElement!.sourceMsgIdInRecords === record.msgId
|
||||
record => element.replyElement!.sourceMsgIdInRecords === record.msgId,
|
||||
);
|
||||
return `[回复消息 ${
|
||||
recordMsgOrNull &&
|
||||
recordMsgOrNull.peerUin != '284840486' // 非转发消息; 否则定位不到
|
||||
?
|
||||
?
|
||||
rawMessageToText(recordMsgOrNull, recursiveLevel + 1) :
|
||||
`未找到消息记录 (MsgId = ${element.replyElement.sourceMsgIdInRecords})`
|
||||
}]`;
|
||||
|
File diff suppressed because one or more lines are too long
@@ -97,9 +97,13 @@ export class NTQQFileApi {
|
||||
async createValidSendFileElement(
|
||||
filePath: string,
|
||||
fileName: string = '',
|
||||
folderId: string = ''
|
||||
folderId: string = '',
|
||||
): Promise<SendFileElement> {
|
||||
const { fileName: _fileName, path, fileSize } = await this.core.apis.FileApi.uploadFile(filePath, ElementType.FILE);
|
||||
const {
|
||||
fileName: _fileName,
|
||||
path,
|
||||
fileSize,
|
||||
} = await this.core.apis.FileApi.uploadFile(filePath, ElementType.FILE);
|
||||
if (fileSize === 0) {
|
||||
throw new Error('文件异常,大小为0');
|
||||
}
|
||||
@@ -118,9 +122,14 @@ export class NTQQFileApi {
|
||||
async createValidSendPicElement(
|
||||
picPath: string,
|
||||
summary: string = '',
|
||||
subType: 0 | 1 = 0
|
||||
subType: 0 | 1 = 0,
|
||||
): Promise<SendPicElement> {
|
||||
const { md5, fileName, path, fileSize } = await this.core.apis.FileApi.uploadFile(picPath, ElementType.PIC, subType);
|
||||
const {
|
||||
md5,
|
||||
fileName,
|
||||
path,
|
||||
fileSize,
|
||||
} = await this.core.apis.FileApi.uploadFile(picPath, ElementType.PIC, subType);
|
||||
if (fileSize === 0) {
|
||||
throw new Error('文件异常,大小为0');
|
||||
}
|
||||
@@ -153,7 +162,12 @@ export class NTQQFileApi {
|
||||
diyThumbPath: string = '',
|
||||
): Promise<SendVideoElement> {
|
||||
const logger = this.core.context.logger;
|
||||
const { fileName: _fileName, path, fileSize, md5 } = await this.core.apis.FileApi.uploadFile(filePath, ElementType.VIDEO);
|
||||
const {
|
||||
fileName: _fileName,
|
||||
path,
|
||||
fileSize,
|
||||
md5,
|
||||
} = await this.core.apis.FileApi.uploadFile(filePath, ElementType.VIDEO);
|
||||
if (fileSize === 0) {
|
||||
throw new Error('文件异常,大小为0');
|
||||
}
|
||||
@@ -200,7 +214,7 @@ export class NTQQFileApi {
|
||||
const thumbSize = _thumbPath ? (await fsPromises.stat(_thumbPath)).size : 0;
|
||||
// log("生成缩略图", _thumbPath)
|
||||
thumbPath.set(0, _thumbPath);
|
||||
const thumbMd5 = _thumbPath ? await calculateFileMD5(_thumbPath) : "";
|
||||
const thumbMd5 = _thumbPath ? await calculateFileMD5(_thumbPath) : '';
|
||||
// "fileElement": {
|
||||
// "fileMd5": "",
|
||||
// "fileName": "1.mp4",
|
||||
@@ -427,14 +441,14 @@ export class NTQQFileApi {
|
||||
buddyChatInfo: any[],
|
||||
discussChatInfo: any[],
|
||||
groupChatInfo:
|
||||
{
|
||||
groupCode: string,
|
||||
isConf: boolean,
|
||||
hasModifyConfGroupFace: boolean,
|
||||
hasModifyConfGroupName: boolean,
|
||||
groupName: string,
|
||||
remark: string
|
||||
}[],
|
||||
{
|
||||
groupCode: string,
|
||||
isConf: boolean,
|
||||
hasModifyConfGroupFace: boolean,
|
||||
hasModifyConfGroupName: boolean,
|
||||
groupName: string,
|
||||
remark: string
|
||||
}[],
|
||||
dataLineChatInfo: any[],
|
||||
tmpChatInfo: any[],
|
||||
msgId: string,
|
||||
@@ -450,22 +464,21 @@ export class NTQQFileApi {
|
||||
filePath: string,
|
||||
fileName: string,
|
||||
hits:
|
||||
{
|
||||
start: number,
|
||||
end: number
|
||||
}[]
|
||||
{
|
||||
start: number,
|
||||
end: number
|
||||
}[]
|
||||
}[]
|
||||
}
|
||||
|
||||
const Event = this.core.eventWrapper.createEventFunction<EventType>('NodeIKernelSearchService/searchFileWithKeywords');
|
||||
let id = '';
|
||||
const Listener = this.core.eventWrapper.RegisterListen<(params: OnListener) => void>
|
||||
(
|
||||
const Listener = this.core.eventWrapper.RegisterListen<(params: OnListener) => void>(
|
||||
'NodeIKernelSearchListener/onSearchFileKeywordsResult',
|
||||
1,
|
||||
20000,
|
||||
(params) => id !== '' && params.searchId == id,
|
||||
);
|
||||
1,
|
||||
20000,
|
||||
(params) => id !== '' && params.searchId == id,
|
||||
);
|
||||
id = await Event!(keys, 12);
|
||||
const [ret] = (await Listener);
|
||||
return ret;
|
||||
|
@@ -19,6 +19,7 @@ export class NTQQGroupApi {
|
||||
groupCache: Map<string, Group> = new Map<string, Group>();
|
||||
groupMemberCache: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>();
|
||||
groups: Group[] = [];
|
||||
|
||||
constructor(context: InstanceContext, core: NapCatCore) {
|
||||
this.context = context;
|
||||
this.core = core;
|
||||
@@ -26,6 +27,7 @@ export class NTQQGroupApi {
|
||||
this.initCache().then().catch(context.logger.logError);
|
||||
});
|
||||
}
|
||||
|
||||
async initCache() {
|
||||
this.groups = await this.getGroups();
|
||||
for (const group of this.groups) {
|
||||
@@ -35,12 +37,13 @@ export class NTQQGroupApi {
|
||||
}
|
||||
this.context.logger.logDebug(`加载${this.groups.length}个群组缓存完成`);
|
||||
}
|
||||
|
||||
async setGroupAvatar(gc: string, filePath: string) {
|
||||
return this.context.session.getGroupService().setHeader(gc, filePath);
|
||||
}
|
||||
|
||||
async getGroups(forced = false) {
|
||||
const [,, groupList] = await this.core.eventWrapper.callNormalEventV2(
|
||||
const [, , groupList] = await this.core.eventWrapper.callNormalEventV2(
|
||||
'NodeIKernelGroupService/getGroupList',
|
||||
'NodeIKernelGroupListener/onGroupListUpdate',
|
||||
[forced],
|
||||
@@ -135,8 +138,7 @@ export class NTQQGroupApi {
|
||||
members = await this.getGroupMembers(groupCodeStr);
|
||||
// 更新群成员列表
|
||||
this.groupMemberCache.set(groupCodeStr, members);
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -215,21 +217,25 @@ export class NTQQGroupApi {
|
||||
// GetMsgByShoretID(ShoretID); -> MsgService.getMsgs(Peer,MsgId,1,false); -> 组出参数
|
||||
return this.context.session.getGroupService().addGroupEssence(param);
|
||||
}
|
||||
|
||||
async kickMemberV2Inner(param: KickMemberV2Req) {
|
||||
return this.context.session.getGroupService().kickMemberV2(param);
|
||||
}
|
||||
|
||||
async deleteGroupBulletin(GroupCode: string, noticeId: string) {
|
||||
const _Pskey = (await this.core.apis.UserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!;
|
||||
return this.context.session.getGroupService().deleteGroupBulletin(GroupCode, _Pskey, noticeId);
|
||||
}
|
||||
|
||||
async quitGroupV2(GroupCode: string, needDeleteLocalMsg: boolean) {
|
||||
const param = {
|
||||
groupCode: GroupCode,
|
||||
needDeleteLocalMsg: needDeleteLocalMsg
|
||||
needDeleteLocalMsg: needDeleteLocalMsg,
|
||||
};
|
||||
//应该是直接返回不需要Listener的 未经测试 需测试再发布
|
||||
return this.context.session.getGroupService().quitGroupV2(param);
|
||||
}
|
||||
|
||||
async removeGroupEssence(GroupCode: string, msgId: string) {
|
||||
// 代码没测过
|
||||
// 需要 ob11msgid->msgId + (peer) -> msgSeq + msgRandom
|
||||
@@ -248,13 +254,13 @@ export class NTQQGroupApi {
|
||||
}
|
||||
|
||||
async getSingleScreenNotifies(num: number) {
|
||||
const [,,, notifies] = await this.core.eventWrapper.callNormalEventV2(
|
||||
const [, , , notifies] = await this.core.eventWrapper.callNormalEventV2(
|
||||
'NodeIKernelGroupService/getSingleScreenNotifies',
|
||||
'NodeIKernelGroupListener/onGroupSingleScreenNotifies',
|
||||
[
|
||||
false,
|
||||
'',
|
||||
num
|
||||
num,
|
||||
],
|
||||
);
|
||||
return notifies;
|
||||
|
@@ -18,6 +18,7 @@ export class NTQQMsgApi {
|
||||
async sendShowInputStatusReq(peer: Peer, eventType: number) {
|
||||
return this.context.session.getMsgService().sendShowInputStatusReq(peer.chatType, eventType, peer.peerUid);
|
||||
}
|
||||
|
||||
async getMsgEmojiLikesList(peer: Peer, msgSeq: string, emojiId: string, emojiType: string, count: number = 20) {
|
||||
//console.log(peer, msgSeq, emojiId, emojiType, count);
|
||||
//注意此处emojiType 可选值一般为1-2 2好像是unicode表情dec值 大部分情况 Taged M likiowa
|
||||
@@ -39,6 +40,7 @@ export class NTQQMsgApi {
|
||||
emojiId = emojiId.toString();
|
||||
return this.context.session.getMsgService().setMsgEmojiLikes(peer, msgSeq, emojiId, emojiId.length > 3 ? '2' : '1', set);
|
||||
}
|
||||
|
||||
async getMultiMsg(peer: Peer, rootMsgId: string, parentMsgId: string): Promise<GeneralCallResult & {
|
||||
msgList: RawMessage[]
|
||||
} | undefined> {
|
||||
@@ -93,6 +95,7 @@ export class NTQQMsgApi {
|
||||
async getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, z: boolean) {
|
||||
return await this.context.session.getMsgService().getMsgsBySeqAndCount(peer, seq, count, desc, z);
|
||||
}
|
||||
|
||||
async getMsgExBySeq(peer: Peer, msgSeq: string) {
|
||||
const DateNow = Math.floor(Date.now() / 1000);
|
||||
const filterMsgFromTime = (DateNow - 300).toString();
|
||||
@@ -108,6 +111,7 @@ export class NTQQMsgApi {
|
||||
pageLimit: 100,
|
||||
});
|
||||
}
|
||||
|
||||
async setMsgRead(peer: Peer) {
|
||||
return this.context.session.getMsgService().setMsgRead(peer);
|
||||
}
|
||||
@@ -118,7 +122,7 @@ export class NTQQMsgApi {
|
||||
'NodeIKernelMsgListener/onGroupFileInfoUpdate',
|
||||
[
|
||||
GroupCode,
|
||||
params
|
||||
params,
|
||||
],
|
||||
() => true,
|
||||
( /* groupFileListResult: GroupFileInfoUpdateParamType */) => {
|
||||
@@ -142,29 +146,32 @@ export class NTQQMsgApi {
|
||||
peerUid: peer.peerUid,
|
||||
}, msgIds);
|
||||
}
|
||||
|
||||
async PrepareTempChat(toUserUid: string, GroupCode: string, nickname: string) {
|
||||
//By Jadx/Ida Mlikiowa
|
||||
const TempGameSession = {
|
||||
nickname: "",
|
||||
gameAppId: "",
|
||||
selfTinyId: "",
|
||||
peerRoleId: "",
|
||||
peerOpenId: "",
|
||||
nickname: '',
|
||||
gameAppId: '',
|
||||
selfTinyId: '',
|
||||
peerRoleId: '',
|
||||
peerOpenId: '',
|
||||
};
|
||||
return this.context.session.getMsgService().prepareTempChat({
|
||||
chatType: ChatType.KCHATTYPETEMPC2CFROMGROUP,
|
||||
peerUid: toUserUid,
|
||||
peerNickname: nickname,
|
||||
fromGroupCode: GroupCode,
|
||||
sig: "",
|
||||
selfPhone: "",
|
||||
sig: '',
|
||||
selfPhone: '',
|
||||
selfUid: this.core.selfInfo.uid,
|
||||
gameSession: TempGameSession
|
||||
gameSession: TempGameSession,
|
||||
});
|
||||
}
|
||||
|
||||
async getTempChatInfo(chatType: ChatType, peerUid: string) {
|
||||
return this.context.session.getMsgService().getTempChatInfo(chatType, peerUid);
|
||||
}
|
||||
|
||||
async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
||||
//唉? !我有个想法
|
||||
if (peer.chatType === ChatType.KCHATTYPETEMPC2CFROMGROUP && peer.guildId && peer.guildId !== '') {
|
||||
@@ -182,7 +189,7 @@ export class NTQQMsgApi {
|
||||
'0',
|
||||
peer,
|
||||
msgElements,
|
||||
new Map()
|
||||
new Map(),
|
||||
],
|
||||
() => true,
|
||||
msgRecords => {
|
||||
@@ -244,7 +251,7 @@ export class NTQQMsgApi {
|
||||
if (!arkElement) {
|
||||
continue;
|
||||
}
|
||||
const forwardData: any = JSON.parse(arkElement.arkElement?.bytesData ?? "");
|
||||
const forwardData: any = JSON.parse(arkElement.arkElement?.bytesData ?? '');
|
||||
if (forwardData.app != 'com.tencent.multimsg') {
|
||||
continue;
|
||||
}
|
||||
|
@@ -28,18 +28,14 @@ export class NTQQSystemApi {
|
||||
|
||||
//1-2-162b9b42-65b9-4405-a8ed-2e256ec8aa50
|
||||
async getArkJsonCollection(cid: string) {
|
||||
const ret = await this.core.eventWrapper.callNoListenerEvent<(cid: string) => Promise<GeneralCallResult & {
|
||||
return await this.core.eventWrapper.callNoListenerEvent<(cid: string) => Promise<GeneralCallResult & {
|
||||
arkJson: string
|
||||
}>>(
|
||||
'NodeIKernelCollectionService/collectionArkShare',
|
||||
'1717662698058',
|
||||
);
|
||||
return ret;
|
||||
}>>('NodeIKernelCollectionService/collectionArkShare', '1717662698058');
|
||||
}
|
||||
|
||||
async BootMiniApp(appfile: string, params: string) {
|
||||
await this.context.session.getNodeMiscService().setMiniAppVersion('2.16.4');
|
||||
const c = await this.context.session.getNodeMiscService().getMiniAppPath();
|
||||
// const c = await this.context.session.getNodeMiscService().getMiniAppPath();
|
||||
|
||||
return this.context.session.getNodeMiscService().startNewMiniApp(appfile, params);
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ export class NTQQUserApi {
|
||||
'BuddyProfileStore',
|
||||
uids,
|
||||
UserDetailSource.KSERVER,
|
||||
[ProfileBizType.KALL]
|
||||
[ProfileBizType.KALL],
|
||||
],
|
||||
() => true,
|
||||
(profile) => {
|
||||
@@ -106,7 +106,7 @@ export class NTQQUserApi {
|
||||
'BuddyProfileStore',
|
||||
[uid],
|
||||
mode,
|
||||
[ProfileBizType.KALL]
|
||||
[ProfileBizType.KALL],
|
||||
],
|
||||
() => true,
|
||||
(profile) => profile.uid === uid,
|
||||
|
@@ -3,7 +3,7 @@ import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
import { InstanceContext } from './wrapper';
|
||||
import { proxiedListenerOf } from '@/common/utils/proxy-handler';
|
||||
import { NodeIKernelMsgListener, NodeIKernelGroupListener, NodeIKernelProfileListener } from './listeners';
|
||||
import { NodeIKernelGroupListener, NodeIKernelMsgListener, NodeIKernelProfileListener } from './listeners';
|
||||
import { DataSource, GroupMember, SelfInfo } from './entities';
|
||||
import { LegacyNTEventWrapper } from '@/common/framework/event-legacy';
|
||||
import { NTQQFileApi, NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQSystemApi, NTQQUserApi, NTQQWebApi } from './apis';
|
||||
@@ -98,7 +98,7 @@ export class NapCatCore {
|
||||
};
|
||||
//await sleep(2500);
|
||||
this.context.session.getMsgService().addKernelMsgListener(
|
||||
proxiedListenerOf(msgListener, this.context.logger) as any
|
||||
proxiedListenerOf(msgListener, this.context.logger) as any,
|
||||
);
|
||||
|
||||
const profileListener = new NodeIKernelProfileListener();
|
||||
@@ -125,8 +125,7 @@ export class NapCatCore {
|
||||
//群成员数量变化 应该刷新缓存
|
||||
if (existGroup && g.memberCount === existGroup.memberCount) {
|
||||
Object.assign(existGroup, g);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.apis.GroupApi.groupCache.set(g.groupCode, g);
|
||||
// 获取群成员
|
||||
}
|
||||
@@ -149,8 +148,7 @@ export class NapCatCore {
|
||||
const existMember = existMembers.get(uid);
|
||||
if (existMember) {
|
||||
Object.assign(existMember, member);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
existMembers!.set(uid, member);
|
||||
}
|
||||
//移除成员
|
||||
@@ -158,8 +156,7 @@ export class NapCatCore {
|
||||
existMembers.delete(uid);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.apis.GroupApi.groupMemberCache.set(groupCode, arg.infos);
|
||||
}
|
||||
// console.log('onMemberListChange', groupCode, arg);
|
||||
@@ -182,8 +179,7 @@ export class NapCatCore {
|
||||
member.isChangeRole = this.checkAdminEvent(groupCode, member, existMember);
|
||||
// 更新成员信息
|
||||
Object.assign(existMember, member);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
existMembers.set(uid, member);
|
||||
}
|
||||
//移除成员
|
||||
@@ -191,15 +187,15 @@ export class NapCatCore {
|
||||
existMembers.delete(uid);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.apis.GroupApi.groupMemberCache.set(groupCode, members);
|
||||
}
|
||||
};
|
||||
this.context.session.getGroupService().addKernelGroupListener(
|
||||
proxiedListenerOf(groupListener, this.context.logger) as any
|
||||
proxiedListenerOf(groupListener, this.context.logger) as any,
|
||||
);
|
||||
}
|
||||
|
||||
checkAdminEvent(groupCode: string, memberNew: GroupMember, memberOld: GroupMember | undefined): boolean {
|
||||
if (memberNew.role !== memberOld?.role) {
|
||||
this.context.logger.logDebug(`群 ${groupCode} ${memberNew.nick} 角色变更为 ${memberNew.role === 3 ? '管理员' : '群员'}`);
|
||||
|
@@ -1,34 +1,40 @@
|
||||
import { QQLevel, Sex, User } from './user';
|
||||
import { QQLevel, Sex } from './user';
|
||||
|
||||
export interface KickMemberInfo {
|
||||
optFlag: number,
|
||||
optOperate: number,
|
||||
optMemberUid: string,
|
||||
optBytesMsg: string,
|
||||
}
|
||||
export interface KickMemberV2Req{
|
||||
|
||||
export interface KickMemberV2Req {
|
||||
groupCode: string,
|
||||
kickFlag: number,
|
||||
kickList: Array<KickMemberInfo>,
|
||||
kickListUids: Array<string>,
|
||||
kickMsg: string
|
||||
}
|
||||
|
||||
export enum DataSource {
|
||||
LOCAL,
|
||||
REMOTE
|
||||
}
|
||||
|
||||
export enum GroupListUpdateType {
|
||||
REFRESHALL,
|
||||
GETALL,
|
||||
MODIFIED,
|
||||
REMOVE
|
||||
}
|
||||
|
||||
export interface GroupMemberCache {
|
||||
group: {
|
||||
data: GroupMember[];
|
||||
isExpired: boolean;
|
||||
}
|
||||
};
|
||||
isExpired: boolean;
|
||||
}
|
||||
|
||||
export interface Group {
|
||||
groupCode: string,
|
||||
createTime?: string,//高版本才有
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { GroupMemberRole } from './group';
|
||||
import { GroupMemberRole } from '@/core';
|
||||
|
||||
export interface Peer {
|
||||
chatType: ChatType;
|
||||
@@ -145,6 +145,7 @@ export interface TaskTopMsgElement {
|
||||
iconUrl: string;
|
||||
topMsgType: number;
|
||||
}
|
||||
|
||||
export enum NTMsgType {
|
||||
KMSGTYPEARKSTRUCT = 11,
|
||||
KMSGTYPEFACEBUBBLE = 24,
|
||||
@@ -168,6 +169,7 @@ export enum NTMsgType {
|
||||
KMSGTYPEVIDEO = 7,
|
||||
KMSGTYPEWALLET = 10
|
||||
}
|
||||
|
||||
export interface SendTaskTopMsgElement {
|
||||
elementType: ElementType.TASKTOPMSG;
|
||||
elementId: string;
|
||||
@@ -355,6 +357,7 @@ export enum NTMsgAtType {
|
||||
ATTYPESUMMONROLE = 256,
|
||||
ATTYPEUNKNOWN = 0
|
||||
}
|
||||
|
||||
export interface SendPicElement {
|
||||
elementType: ElementType.PIC;
|
||||
elementId: string;
|
||||
@@ -511,6 +514,7 @@ export enum AtType {
|
||||
atAll = 1,
|
||||
atUser = 2
|
||||
}
|
||||
|
||||
// 来自Android分析
|
||||
export enum ChatType {
|
||||
KCHATTYPEADELIE = 42,
|
||||
@@ -626,6 +630,7 @@ export enum NTGrayTipElementSubTypeV2 {
|
||||
GRAYTIP_ELEMENT_SUBTYPE_WALLET = 16,
|
||||
GRAYTIP_ELEMENT_SUBTYPE_XMLMSG = 12,
|
||||
}
|
||||
|
||||
export interface GrayTipElement {
|
||||
subElementType: NTGrayTipElementSubTypeV2;
|
||||
revokeElement: {
|
||||
@@ -848,12 +853,14 @@ export interface MultiForwardMsgElement {
|
||||
resId: string;
|
||||
fileName: string;
|
||||
}
|
||||
|
||||
export enum SendStatusType {
|
||||
KSEND_STATUS_FAILED = 0,
|
||||
KSEND_STATUS_SENDING = 1,
|
||||
KSEND_STATUS_SUCCESS = 2,
|
||||
KSEND_STATUS_SUCCESS_NOSEQ = 3
|
||||
}
|
||||
|
||||
export interface RawMessage {
|
||||
parentMsgPeer: Peer;
|
||||
|
||||
@@ -923,4 +930,4 @@ export interface RawMessage {
|
||||
records: RawMessage[];
|
||||
|
||||
elements: MessageElement[];
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ export enum GroupNotifyMsgType {
|
||||
TRANSFER_GROUP_NOTIFY_OLDOWNER,
|
||||
TRANSFER_GROUP_NOTIFY_ADMIN
|
||||
}
|
||||
|
||||
export interface GroupNotifies {
|
||||
doubt: boolean;
|
||||
nextStartSeq: string;
|
||||
@@ -29,17 +30,20 @@ export enum GroupNotifyMsgStatus {
|
||||
KREFUSED,//拒绝
|
||||
KIGNORED//忽略
|
||||
}
|
||||
|
||||
export enum GroupInviteStatus {
|
||||
INIT,
|
||||
WAIT_TO_APPROVE,
|
||||
JOINED,
|
||||
REFUSED_BY_ADMINI_STRATOR
|
||||
}
|
||||
|
||||
export enum GroupInviteType {
|
||||
BYBUDDY,
|
||||
BYGROUPMEMBER,
|
||||
BYDISCUSSMEMBER
|
||||
}
|
||||
|
||||
export interface GroupNotify {
|
||||
seq: string; // 通知序列号
|
||||
type: GroupNotifyMsgType;
|
||||
|
10
src/core/external/appid.json
vendored
10
src/core/external/appid.json
vendored
@@ -7,19 +7,19 @@
|
||||
"appid": 537240645,
|
||||
"qua": "V1_LNX_NQ_3.2.12_27206_GW_B"
|
||||
},
|
||||
"3.2.12-27254":{
|
||||
"3.2.12-27254": {
|
||||
"appid": 537240795,
|
||||
"qua": "V1_LNX_NQ_3.2.12_27254_GW_B"
|
||||
},
|
||||
"9.9.15-27187":{
|
||||
"9.9.15-27187": {
|
||||
"appid": 537240610,
|
||||
"qua": "V1_WIN_NQ_9.9.15_27187_GW_B"
|
||||
},
|
||||
"9.9.15-27206":{
|
||||
"9.9.15-27206": {
|
||||
"appid": 537240610,
|
||||
"qua": "V1_WIN_NQ_9.9.15_27206_GW_B"
|
||||
},
|
||||
"9.9.15-27254":{
|
||||
"9.9.15-27254": {
|
||||
"appid": 537240709,
|
||||
"qua": "V1_WIN_NQ_9.9.15_27254_GW_B"
|
||||
},
|
||||
@@ -27,4 +27,4 @@
|
||||
"appid": 537240709,
|
||||
"qua": "V1_WIN_NQ_9.9.15_27333_GW_B"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { ConfigBase } from "@/common/utils/config-base";
|
||||
import { ConfigBase } from '@/common/utils/config-base';
|
||||
import napCatDefaultConfig from '@/core/external/napcat.json';
|
||||
import { NapCatCore } from '@/core';
|
||||
|
||||
|
@@ -1,4 +1,3 @@
|
||||
|
||||
export class NodeIKernelFileAssistantListener {
|
||||
onFileStatusChanged(...args: unknown[]) {
|
||||
}
|
||||
|
@@ -1,4 +1,3 @@
|
||||
|
||||
export class NodeIKernelLoginListener {
|
||||
onLoginConnected(...args: any[]): void {
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
export class NodeIKernelRobotListener{
|
||||
export class NodeIKernelRobotListener {
|
||||
onRobotFriendListChanged(...args: unknown[]) {
|
||||
|
||||
}
|
||||
|
@@ -11,16 +11,16 @@ export * from './NodeIKernelStorageCleanListener';
|
||||
export * from './NodeIKernelFileAssistantListener';
|
||||
|
||||
import type {
|
||||
NodeIKernelSessionListener,
|
||||
NodeIKernelBuddyListener,
|
||||
NodeIKernelFileAssistantListener,
|
||||
NodeIKernelGroupListener,
|
||||
NodeIKernelLoginListener,
|
||||
NodeIKernelMsgListener,
|
||||
NodeIKernelGroupListener,
|
||||
NodeIKernelBuddyListener,
|
||||
NodeIKernelProfileListener,
|
||||
NodeIKernelRobotListener,
|
||||
NodeIKernelTicketListener,
|
||||
NodeIKernelSessionListener,
|
||||
NodeIKernelStorageCleanListener,
|
||||
NodeIKernelFileAssistantListener,
|
||||
NodeIKernelTicketListener,
|
||||
} from '.';
|
||||
|
||||
export type ListenerNamingMapping = {
|
||||
|
@@ -5,7 +5,7 @@ import {
|
||||
GroupMemberRole,
|
||||
GroupNotifyMsgType,
|
||||
GroupRequestOperateTypes,
|
||||
KickMemberV2Req
|
||||
KickMemberV2Req,
|
||||
} from '@/core/entities';
|
||||
import { GeneralCallResult } from '@/core/services/common';
|
||||
|
||||
@@ -13,6 +13,7 @@ import { GeneralCallResult } from '@/core/services/common';
|
||||
|
||||
export interface NodeIKernelGroupService {
|
||||
kickMemberV2(param: KickMemberV2Req): Promise<GeneralCallResult>;
|
||||
|
||||
quitGroupV2(param: { groupCode: string; needDeleteLocalMsg: boolean; }): Promise<GeneralCallResult>;
|
||||
|
||||
getMemberCommonInfo(Req: {
|
||||
|
@@ -12,6 +12,7 @@ export interface QueryMsgsParams {
|
||||
isReverseOrder: boolean,
|
||||
isIncludeCurrent: boolean
|
||||
}
|
||||
|
||||
export interface TmpChatInfoApi {
|
||||
errMsg: string;
|
||||
result: number;
|
||||
@@ -511,11 +512,11 @@ export interface NodeIKernelMsgService {
|
||||
result: number,
|
||||
errMsg: string,
|
||||
emojiLikesList:
|
||||
Array<{
|
||||
tinyId: string,
|
||||
nickName: string,
|
||||
headUrl: string
|
||||
}>,
|
||||
Array<{
|
||||
tinyId: string,
|
||||
nickName: string,
|
||||
headUrl: string
|
||||
}>,
|
||||
cookie: string,
|
||||
isLastPage: boolean,
|
||||
isFirstPage: boolean
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { AnyCnameRecord } from 'node:dns';
|
||||
import { BizKey, ModifyProfileParams, SimpleInfo, UserDetailInfoByUin } from '../entities';
|
||||
import { NodeIKernelProfileListener } from '../listeners';
|
||||
import { BizKey, ModifyProfileParams, SimpleInfo, UserDetailInfoByUin } from '@/core';
|
||||
import { NodeIKernelProfileListener } from '@/core';
|
||||
import { GeneralCallResult } from '@/core/services/common';
|
||||
|
||||
export enum UserDetailSource {
|
||||
|
@@ -1,7 +1,5 @@
|
||||
import { NodeIDependsAdapter, NodeIDispatcherAdapter, NodeIGlobalAdapter } from '../adapters';
|
||||
import {
|
||||
NodeIKernelSessionListener
|
||||
} from '../listeners';
|
||||
import { NodeIKernelSessionListener } from '@/core';
|
||||
import {
|
||||
NodeIKernelAvatarService,
|
||||
NodeIKernelBuddyService,
|
||||
@@ -13,9 +11,9 @@ import {
|
||||
NodeIKernelRichMediaService,
|
||||
NodeIKernelTicketService,
|
||||
NodeIKernelTipOffService,
|
||||
} from '../services';
|
||||
import { NodeIKernelStorageCleanService } from '../services/NodeIKernelStorageCleanService';
|
||||
import { NodeIKernelRobotService } from '../services/NodeIKernelRobotService';
|
||||
} from '@/core';
|
||||
import { NodeIKernelStorageCleanService } from '@/core';
|
||||
import { NodeIKernelRobotService } from '@/core';
|
||||
import { NodeIKernelNodeMiscService } from '../services/NodeIKernelNodeMiscService';
|
||||
import { NodeIKernelUixConvertService } from '../services/NodeIKernelUixConvertService';
|
||||
import { NodeIKernelMsgBackupService } from '../services/NodeIKernelMsgBackupService';
|
||||
@@ -31,6 +29,7 @@ import { NodeIKernelECDHService } from '../services/NodeIKernelECDHService';
|
||||
|
||||
export interface NodeQQNTWrapperUtil {
|
||||
get(): unknown;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-new
|
||||
new(): NodeQQNTWrapperUtil;
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
//LiteLoader需要提供部分IPC接口,以便于其他插件调用
|
||||
const { ipcMain } = require('electron');
|
||||
const napcat= require('./napcat.cjs');
|
||||
ipcMain.handle("napcat_get_webtoken", async (event, arg) => {
|
||||
const napcat = require('./napcat.cjs');
|
||||
ipcMain.handle('napcat_get_webtoken', async (event, arg) => {
|
||||
return napcat.NCgetWebUiUrl();
|
||||
});
|
||||
|
@@ -14,8 +14,9 @@ import { NapCatOneBot11Adapter } from '@/onebot';
|
||||
//Framework ES入口文件
|
||||
export async function getWebUiUrl() {
|
||||
const WebUiConfigData = (await WebUiConfig.GetWebUIConfig());
|
||||
return "http://127.0.0.1:" + WebUiConfigData.port + '/webui/?token=' + WebUiConfigData.token;
|
||||
return 'http://127.0.0.1:' + WebUiConfigData.port + '/webui/?token=' + WebUiConfigData.token;
|
||||
}
|
||||
|
||||
export async function NCoreInitFramework(
|
||||
session: NodeIQQNTWrapperSession,
|
||||
loginService: NodeIKernelLoginService,
|
||||
|
@@ -1,11 +1,10 @@
|
||||
|
||||
const { contextBridge } = require('electron')
|
||||
const { ipcRenderer } = require('electron')
|
||||
const { contextBridge } = require('electron');
|
||||
const { ipcRenderer } = require('electron');
|
||||
|
||||
const napcat = {
|
||||
getWebUiUrl: async () => {
|
||||
return ipcRenderer.invoke("napcat_get_webtoken")
|
||||
}
|
||||
}
|
||||
return ipcRenderer.invoke('napcat_get_webtoken');
|
||||
},
|
||||
};
|
||||
// 在window对象下导出只读对象
|
||||
contextBridge.exposeInMainWorld('napcat', napcat)
|
||||
contextBridge.exposeInMainWorld('napcat', napcat);
|
||||
|
@@ -1,6 +1,5 @@
|
||||
|
||||
export const onSettingWindowCreated = async (view) => {
|
||||
|
||||
|
||||
// view.style.width = "100%";
|
||||
// view.style.height = "100%";
|
||||
// //添加iframe
|
||||
@@ -14,7 +13,7 @@ export const onSettingWindowCreated = async (view) => {
|
||||
// //有滚动条何尝不是一种美
|
||||
// view.appendChild(iframe);
|
||||
let webui = await window.napcat.getWebUiUrl();
|
||||
let panel = `
|
||||
view.innerHTML = `
|
||||
<setting-section data-title="">
|
||||
<setting-panel>
|
||||
<setting-list data-direction="column">
|
||||
@@ -30,9 +29,8 @@ export const onSettingWindowCreated = async (view) => {
|
||||
</setting-panel>
|
||||
</setting-section>
|
||||
`;
|
||||
view.innerHTML = panel;
|
||||
view.querySelector(".nc_openwebui").addEventListener("click", () => {
|
||||
window.open(webui, "_blank");
|
||||
view.querySelector('.nc_openwebui').addEventListener('click', () => {
|
||||
window.open(webui, '_blank');
|
||||
});
|
||||
view.querySelector(".nc_webui").innerText = webui;
|
||||
};
|
||||
view.querySelector('.nc_webui').innerText = webui;
|
||||
};
|
||||
|
@@ -1,4 +1,7 @@
|
||||
# NewWebui
|
||||
|
||||
基于Vue3实现的现代化轻量化NapCat管理面板
|
||||
|
||||
## 进度
|
||||
画饼
|
||||
|
||||
画饼
|
||||
|
@@ -22,6 +22,7 @@ type Payload = FromSchema<typeof SchemaData>;
|
||||
export class FetchEmojiLike extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.FetchEmojiLike;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQMsgApi = this.core.apis.MsgApi;
|
||||
const msgIdPeer = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString()));
|
||||
|
@@ -16,6 +16,7 @@ type Payload = FromSchema<typeof SchemaData>;
|
||||
export class GetCollectionList extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.GetCollectionList;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQCollectionApi = this.core.apis.CollectionApi;
|
||||
return await NTQQCollectionApi.getAllCollection(parseInt(payload.category.toString()), +(payload.count ?? 1));
|
||||
|
@@ -4,6 +4,7 @@ import { ActionName } from '../types';
|
||||
|
||||
export class GetFriendWithCategory extends BaseAction<void, any> {
|
||||
actionName = ActionName.GetFriendsWithCategory;
|
||||
|
||||
async _handle(payload: void) {
|
||||
return (await this.core.apis.FriendApi.getBuddyV2ExWithCate(true)).map(category => ({
|
||||
...category,
|
||||
|
@@ -3,6 +3,7 @@ import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
||||
import fs from 'fs';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
@@ -19,7 +20,7 @@ export class OCRImage extends BaseAction<Payload, any> {
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQSystemApi = this.core.apis.SystemApi;
|
||||
const { path, isLocal, errMsg, success } = (await uri2local(this.core.NapCatTempPath, payload.image));
|
||||
const { path, isLocal, success } = (await uri2local(this.core.NapCatTempPath, payload.image));
|
||||
if (!success) {
|
||||
throw `OCR ${payload.image}失败,image字段可能格式不正确`;
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ const SchemaData = {
|
||||
properties: {
|
||||
eventType: { type: 'string' },
|
||||
group_id: { type: 'string' },
|
||||
user_id: { type: 'string' }
|
||||
user_id: { type: 'string' },
|
||||
},
|
||||
required: ['eventType'],
|
||||
} as const satisfies JSONSchema;
|
||||
@@ -25,20 +25,19 @@ export class SetInputStatus extends BaseAction<Payload, any> {
|
||||
if (payload.group_id) {
|
||||
peer = {
|
||||
chatType: ChatType.KCHATTYPEGROUP,
|
||||
peerUid: payload.group_id
|
||||
peerUid: payload.group_id,
|
||||
};
|
||||
} else if (payload.user_id) {
|
||||
const uid = await NTQQUserApi.getUidByUinV2(payload.user_id);
|
||||
if (!uid) throw new Error('uid is empty');
|
||||
peer = {
|
||||
chatType: ChatType.KCHATTYPEC2C,
|
||||
peerUid: uid
|
||||
peerUid: uid,
|
||||
};
|
||||
} else {
|
||||
throw new Error('请指定 group_id 或 user_id');
|
||||
}
|
||||
|
||||
const ret = await NTQQMsgApi.sendShowInputStatusReq(peer, parseInt(payload.eventType));
|
||||
return ret;
|
||||
return await NTQQMsgApi.sendShowInputStatusReq(peer, parseInt(payload.eventType));
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ export class SetOnlineStatus extends BaseAction<Payload, null> {
|
||||
const ret = await NTQQUserApi.setSelfOnlineStatus(
|
||||
parseInt(payload.status.toString()),
|
||||
parseInt(payload.extStatus.toString()),
|
||||
parseInt(payload.batteryStatus.toString())
|
||||
parseInt(payload.batteryStatus.toString()),
|
||||
);
|
||||
if (ret.result !== 0) {
|
||||
throw new Error('设置在线状态失败');
|
||||
|
@@ -24,7 +24,7 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11Use
|
||||
const extendData = await NTQQUserApi.getUserDetailInfoByUinV2(user_id);
|
||||
const uid = (await NTQQUserApi.getUidByUinV2(user_id))!;
|
||||
if (!uid || uid.indexOf('*') != -1) {
|
||||
const ret = {
|
||||
return {
|
||||
...extendData.detail.simpleInfo.coreInfo,
|
||||
...extendData.detail.commonExt,
|
||||
...extendData.detail.simpleInfo.baseInfo,
|
||||
@@ -36,9 +36,8 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11Use
|
||||
qid: extendData.detail.simpleInfo.baseInfo.qid,
|
||||
level: calcQQLevel(extendData.detail.commonExt?.qqLevel ?? 0) || 0,
|
||||
login_days: 0,
|
||||
uid: ''
|
||||
uid: '',
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
const data = { ...extendData, ...(await NTQQUserApi.getUserDetailInfo(uid)) };
|
||||
return OB11Entities.stranger(data);
|
||||
|
@@ -22,13 +22,16 @@ export class SetQQProfile extends BaseAction<Payload, any | null> {
|
||||
const NTQQUserApi = this.core.apis.UserApi;
|
||||
const self = this.core.selfInfo;
|
||||
const OldProfile = await NTQQUserApi.getUserDetailInfo(self.uid);
|
||||
const ret = await NTQQUserApi.modifySelfProfile({
|
||||
return await NTQQUserApi.modifySelfProfile({
|
||||
nick: payload.nickname,
|
||||
longNick: (payload?.personal_note ?? OldProfile?.longNick) || '',
|
||||
sex: parseInt(payload?.sex ? payload?.sex.toString() : OldProfile?.sex!.toString()),
|
||||
birthday: { birthday_year: OldProfile?.birthday_year!.toString(), birthday_month: OldProfile?.birthday_month!.toString(), birthday_day: OldProfile?.birthday_day!.toString() },
|
||||
birthday: {
|
||||
birthday_year: OldProfile?.birthday_year!.toString(),
|
||||
birthday_month: OldProfile?.birthday_month!.toString(),
|
||||
birthday_day: OldProfile?.birthday_day!.toString(),
|
||||
},
|
||||
location: undefined,
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ export default class GoCQHTTPUploadPrivateFile extends BaseAction<Payload, null>
|
||||
const isBuddy = await NTQQFriendApi.isBuddy(peerUid);
|
||||
return { chatType: isBuddy ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid };
|
||||
}
|
||||
throw new Error( '缺少参数 user_id');
|
||||
throw new Error('缺少参数 user_id');
|
||||
}
|
||||
|
||||
async _handle(payload: Payload): Promise<null> {
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import { WebApiGroupNoticeFeed } from '@/core';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
@@ -10,7 +9,7 @@ const SchemaData = {
|
||||
group_id: { type: ['number', 'string'] },
|
||||
notice_id: { type: 'string' },
|
||||
},
|
||||
required: ['group_id','notice_id'],
|
||||
required: ['group_id', 'notice_id'],
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
@@ -26,14 +26,14 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
const isNocache = typeof payload.no_cache === 'string' ? payload.no_cache === 'true' : !!payload.no_cache;
|
||||
const uid = await NTQQUserApi.getUidByUinV2(payload.user_id.toString());
|
||||
if (!uid) throw new Error (`Uin2Uid Error ${payload.user_id}不存在`);
|
||||
if (!uid) throw new Error(`Uin2Uid Error ${payload.user_id}不存在`);
|
||||
const [member, info] = await Promise.allSettled([
|
||||
NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), uid, isNocache),
|
||||
NTQQUserApi.getUserDetailInfo(uid),
|
||||
]);
|
||||
if (member.status !== 'fulfilled') throw new Error (`群(${payload.group_id})成员${payload.user_id}不存在 ${member.reason}`);
|
||||
if (member.status !== 'fulfilled') throw new Error(`群(${payload.group_id})成员${payload.user_id}不存在 ${member.reason}`);
|
||||
if (info.status === 'fulfilled') {
|
||||
this.core.context.logger.logDebug("群成员详细信息结果", info.value);
|
||||
this.core.context.logger.logDebug('群成员详细信息结果', info.value);
|
||||
Object.assign(member, info.value);
|
||||
} else {
|
||||
this.core.context.logger.logDebug(`获取群成员详细信息失败, 只能返回基础信息 ${info.reason}`);
|
||||
|
@@ -63,7 +63,7 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_groupMembers = Array.from(MemberMap.values());
|
||||
return _groupMembers;
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ class DeleteMsg extends BaseAction<Payload, void> {
|
||||
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||
1,
|
||||
5000,
|
||||
(msgs) => !!msgs.find(m => m.msgId === msg.MsgId && m.recallTime !== '0')
|
||||
(msgs) => !!msgs.find(m => m.msgId === msg.MsgId && m.recallTime !== '0'),
|
||||
).catch(() => new Promise<undefined>((resolve) => {
|
||||
resolve(undefined);
|
||||
}));
|
||||
|
@@ -26,7 +26,7 @@ class MarkMsgAsRead extends BaseAction<PlayloadType, null> {
|
||||
return { chatType: isBuddy ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid };
|
||||
}
|
||||
if (!payload.group_id) {
|
||||
throw new Error( '缺少参数 group_id 或 user_id');
|
||||
throw new Error('缺少参数 group_id 或 user_id');
|
||||
}
|
||||
return { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() };
|
||||
}
|
||||
|
@@ -113,7 +113,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
|
||||
const messages = normalize(
|
||||
payload.message,
|
||||
typeof payload.auto_escape === 'string' ? payload.auto_escape === 'true' : !!payload.auto_escape
|
||||
typeof payload.auto_escape === 'string' ? payload.auto_escape === 'true' : !!payload.auto_escape,
|
||||
);
|
||||
|
||||
if (getSpecialMsgNum(payload, OB11MessageDataType.node)) {
|
||||
|
@@ -4,6 +4,7 @@ import CanSendRecord from './CanSendRecord';
|
||||
interface ReturnType {
|
||||
yes: boolean;
|
||||
}
|
||||
|
||||
export default class CanSendImage extends CanSendRecord {
|
||||
actionName = ActionName.CanSendImage;
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ export class GetCSRF extends BaseAction<any, any> {
|
||||
|
||||
async _handle(payload: any) {
|
||||
return {
|
||||
token: "",
|
||||
token: '',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -105,9 +105,9 @@ export enum ActionName {
|
||||
GOCQHTTP_UploadPrivateFile = 'upload_private_file',
|
||||
TestApi01 = 'test_api_01',
|
||||
FetchEmojiLike = 'fetch_emoji_like',
|
||||
GetGuildProfile = "get_guild_service_profile",
|
||||
SetModelShow = "_set_model_show",
|
||||
SetInputStatus = "set_input_status",
|
||||
GetCSRF = "get_csrf_token",
|
||||
DelGroupNotice = "_del_group_notice",
|
||||
GetGuildProfile = 'get_guild_service_profile',
|
||||
SetModelShow = '_set_model_show',
|
||||
SetInputStatus = 'set_input_status',
|
||||
GetCSRF = 'get_csrf_token',
|
||||
DelGroupNotice = '_del_group_notice',
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ export class OneBotFriendApi {
|
||||
this.obContext = obContext;
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
//使用前预先判断 busiId 1061
|
||||
async parsePrivatePokeEvent(grayTipElement: GrayTipElement) {
|
||||
const NTQQUserApi = this.core.apis.UserApi;
|
||||
@@ -24,7 +25,7 @@ export class OneBotFriendApi {
|
||||
this.core,
|
||||
parseInt((await NTQQUserApi.getUinByUidV2(pokedetail[0].uid))!),
|
||||
parseInt((await NTQQUserApi.getUinByUidV2(pokedetail[1].uid))!),
|
||||
pokedetail
|
||||
pokedetail,
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
|
@@ -15,6 +15,7 @@ export class OneBotGroupApi {
|
||||
this.obContext = obContext;
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
async parseGroupBanEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
||||
const groupElement = grayTipElement?.groupElement;
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
@@ -40,11 +41,12 @@ export class OneBotGroupApi {
|
||||
parseInt(memberUin),
|
||||
parseInt(adminUin),
|
||||
duration,
|
||||
subType
|
||||
subType,
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async parseGroupIncreaseEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
||||
this.core.context.logger.logDebug('收到新人被邀请进群消息', grayTipElement);
|
||||
const xmlElement = grayTipElement.xmlElement;
|
||||
@@ -65,12 +67,13 @@ export class OneBotGroupApi {
|
||||
parseInt(GroupCode),
|
||||
parseInt(invitee),
|
||||
parseInt(inviter),
|
||||
'invite'
|
||||
'invite',
|
||||
);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async parseGroupMemberIncreaseEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
const groupElement = grayTipElement?.groupElement;
|
||||
@@ -84,11 +87,12 @@ export class OneBotGroupApi {
|
||||
this.core,
|
||||
parseInt(GroupCode),
|
||||
parseInt(memberUin),
|
||||
parseInt(operatorUin)
|
||||
parseInt(operatorUin),
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async parseGroupKickEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
const NTQQUserApi = this.core.apis.UserApi;
|
||||
@@ -101,11 +105,12 @@ export class OneBotGroupApi {
|
||||
parseInt(GroupCode),
|
||||
parseInt(this.core.selfInfo.uin),
|
||||
parseInt(adminUin),
|
||||
'kick_me'
|
||||
'kick_me',
|
||||
);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async parseGroupEmjioLikeEvent(GroupCode: string, grayTipElement: GrayTipElement) {
|
||||
const NTQQMsgApi = this.core.apis.MsgApi;
|
||||
const emojiLikeData = new fastXmlParser.XMLParser({
|
||||
@@ -120,7 +125,7 @@ export class OneBotGroupApi {
|
||||
const peer = {
|
||||
chatType: ChatType.KCHATTYPEGROUP,
|
||||
guildId: '',
|
||||
peerUid: GroupCode
|
||||
peerUid: GroupCode,
|
||||
};
|
||||
const replyMsgList = (await NTQQMsgApi.getMsgExBySeq(peer, msgSeq)).msgList;
|
||||
if (replyMsgList.length < 1) {
|
||||
|
@@ -36,7 +36,7 @@ type RawToOb11Converters = {
|
||||
[Key in keyof MessageElement as Key extends `${string}Element` ? Key : never]: (
|
||||
element: Exclude<MessageElement[Key], null | undefined>,
|
||||
msg: RawMessage,
|
||||
elementWrapper: MessageElement
|
||||
elementWrapper: MessageElement,
|
||||
) => PromiseLike<OB11MessageData | null>
|
||||
}
|
||||
|
||||
@@ -73,12 +73,12 @@ export class OneBotMsgApi {
|
||||
}
|
||||
return {
|
||||
type: OB11MessageDataType.text,
|
||||
data: { text }
|
||||
data: { text },
|
||||
};
|
||||
} else {
|
||||
let qq: string = 'all';
|
||||
if (element.atType !== AtType.atAll) {
|
||||
const { atNtUid, /* content */ } = element;
|
||||
const { atNtUid /* content */ } = element;
|
||||
let atQQ = element.atUid;
|
||||
if (!atQQ || atQQ === '0') {
|
||||
atQQ = await this.core.apis.UserApi.getUinByUidV2(atNtUid);
|
||||
@@ -138,7 +138,7 @@ export class OneBotMsgApi {
|
||||
url: element.filePath,
|
||||
file_id: UUIDConverter.encode(msg.peerUin, msg.msgId),
|
||||
file_size: element.fileSize,
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@@ -149,21 +149,21 @@ export class OneBotMsgApi {
|
||||
type: OB11MessageDataType.dice,
|
||||
data: {
|
||||
result: element.resultId!,
|
||||
}
|
||||
},
|
||||
};
|
||||
} else if (faceIndex === FaceIndex.RPS) {
|
||||
return {
|
||||
type: OB11MessageDataType.RPS,
|
||||
data: {
|
||||
result: element.resultId!,
|
||||
}
|
||||
},
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
type: OB11MessageDataType.face,
|
||||
data: {
|
||||
id: element.faceIndex.toString()
|
||||
}
|
||||
id: element.faceIndex.toString(),
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
@@ -190,7 +190,7 @@ export class OneBotMsgApi {
|
||||
file_id: UUIDConverter.encode(msg.peerUin, msg.msgId),
|
||||
path: elementWrapper.elementId,
|
||||
url: elementWrapper.elementId,
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@@ -239,8 +239,8 @@ export class OneBotMsgApi {
|
||||
peerUid: msg.peerUid,
|
||||
guildId: '',
|
||||
chatType: msg.chatType,
|
||||
}, replyMsg.msgId).toString()
|
||||
}
|
||||
}, replyMsg.msgId).toString(),
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@@ -303,7 +303,7 @@ export class OneBotMsgApi {
|
||||
url: videoDownUrl,
|
||||
file_id: UUIDConverter.encode(msg.peerUin, msg.msgId),
|
||||
file_size: element.fileSize,
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@@ -329,7 +329,7 @@ export class OneBotMsgApi {
|
||||
path: element.filePath,
|
||||
file_id: UUIDConverter.encode(msg.peerUin, msg.msgId),
|
||||
file_size: element.fileSize,
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@@ -366,9 +366,9 @@ export class OneBotMsgApi {
|
||||
multiMsgItem.parentMsgIdList = msg.parentMsgIdList;
|
||||
multiMsgItem.id = MessageUnique.createMsg(parentMsgPeer, multiMsgItem.msgId); //该ID仅用查看 无法调用
|
||||
return await this.parseMessage(multiMsgItem);
|
||||
}
|
||||
},
|
||||
))).filter(item => item !== undefined),
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@@ -376,8 +376,8 @@ export class OneBotMsgApi {
|
||||
return {
|
||||
type: OB11MessageDataType.json,
|
||||
data: {
|
||||
data: element.bytesData
|
||||
}
|
||||
data: element.bytesData,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@@ -385,10 +385,10 @@ export class OneBotMsgApi {
|
||||
return {
|
||||
type: OB11MessageDataType.markdown,
|
||||
data: {
|
||||
content: element.content
|
||||
}
|
||||
content: element.content,
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
ob11ToRawConverters: Ob11ToRawConverters = {
|
||||
@@ -716,11 +716,11 @@ export class OneBotMsgApi {
|
||||
// @ts-ignore
|
||||
element[key],
|
||||
msg,
|
||||
element
|
||||
element,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
))).filter(entry => {
|
||||
if (entry.status === 'fulfilled') {
|
||||
return !!entry.value;
|
||||
@@ -822,7 +822,7 @@ export class OneBotMsgApi {
|
||||
this.core.context.logger.logError('文件消息缺少参数', inputdata);
|
||||
throw Error('文件消息缺少参数');
|
||||
}
|
||||
const fileOrUrl = (isBlankUrl ? inputdata.file : inputdata.url) ?? "";
|
||||
const fileOrUrl = (isBlankUrl ? inputdata.file : inputdata.url) ?? '';
|
||||
const {
|
||||
path,
|
||||
isLocal,
|
||||
|
@@ -1,10 +1,14 @@
|
||||
import {
|
||||
NapCatOneBot11Adapter,
|
||||
OB11Message, OB11MessageAt,
|
||||
OB11Message,
|
||||
OB11MessageAt,
|
||||
OB11MessageData,
|
||||
OB11MessageReply,
|
||||
QuickAction,
|
||||
QuickActionEvent, QuickActionFriendRequest, QuickActionGroupMessage, QuickActionGroupRequest,
|
||||
QuickActionEvent,
|
||||
QuickActionFriendRequest,
|
||||
QuickActionGroupMessage,
|
||||
QuickActionGroupRequest,
|
||||
} from '@/onebot';
|
||||
import { ChatType, GroupRequestOperateTypes, NapCatCore, Peer } from '@/core';
|
||||
import { OB11FriendRequestEvent } from '@/onebot/event/request/OB11FriendRequest';
|
||||
@@ -15,8 +19,9 @@ import { isNull } from '@/common/utils/helper';
|
||||
export class OneBotQuickActionApi {
|
||||
constructor(
|
||||
public obContext: NapCatOneBot11Adapter,
|
||||
public core: NapCatCore
|
||||
) {}
|
||||
public core: NapCatCore,
|
||||
) {
|
||||
}
|
||||
|
||||
async handleQuickOperation(eventContext: QuickActionEvent, quickAction: QuickAction) {
|
||||
if (eventContext.post_type === 'message') {
|
||||
@@ -72,7 +77,10 @@ export class OneBotQuickActionApi {
|
||||
}
|
||||
}
|
||||
replyMessage = replyMessage.concat(normalize(reply, quickAction.auto_escape));
|
||||
const { sendElements, deleteAfterSentFiles } = await this.obContext.apis.MsgApi.createSendElements(replyMessage, peer);
|
||||
const {
|
||||
sendElements,
|
||||
deleteAfterSentFiles,
|
||||
} = await this.obContext.apis.MsgApi.createSendElements(replyMessage, peer);
|
||||
this.obContext.apis.MsgApi.sendMsgWithOb11UniqueId(peer, sendElements, deleteAfterSentFiles, false).then().catch(this.core.context.logger.logError);
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
import { NapCatOneBot11Adapter } from "..";
|
||||
import { OB11BaseNoticeEvent } from "../event/notice/OB11BaseNoticeEvent";
|
||||
import { OB11FriendAddNoticeEvent } from "../event/notice/OB11FriendAddNoticeEvent";
|
||||
import { OB11GroupNoticeEvent } from "../event/notice/OB11GroupNoticeEvent";
|
||||
import { OB11GroupCardEvent } from "../event/notice/OB11GroupCardEvent";
|
||||
import { OB11GroupDecreaseEvent } from "../event/notice/OB11GroupDecreaseEvent";
|
||||
import { OB11GroupUploadNoticeEvent } from "../event/notice/OB11GroupUploadNoticeEvent";
|
||||
import { OB11GroupPokeEvent } from "../event/notice/OB11PokeEvent";
|
||||
import { OB11GroupEssenceEvent } from "../event/notice/OB11GroupEssenceEvent";
|
||||
import { MessageUnique } from "@/common/utils/message-unique";
|
||||
import { OB11GroupTitleEvent } from "../event/notice/OB11GroupTitleEvent";
|
||||
import { NapCatOneBot11Adapter } from '..';
|
||||
import { OB11BaseNoticeEvent } from '../event/notice/OB11BaseNoticeEvent';
|
||||
import { OB11FriendAddNoticeEvent } from '../event/notice/OB11FriendAddNoticeEvent';
|
||||
import { OB11GroupNoticeEvent } from '../event/notice/OB11GroupNoticeEvent';
|
||||
import { OB11GroupCardEvent } from '../event/notice/OB11GroupCardEvent';
|
||||
import { OB11GroupDecreaseEvent } from '../event/notice/OB11GroupDecreaseEvent';
|
||||
import { OB11GroupUploadNoticeEvent } from '../event/notice/OB11GroupUploadNoticeEvent';
|
||||
import { OB11GroupPokeEvent } from '../event/notice/OB11PokeEvent';
|
||||
import { OB11GroupEssenceEvent } from '../event/notice/OB11GroupEssenceEvent';
|
||||
import { MessageUnique } from '@/common/utils/message-unique';
|
||||
import { OB11GroupTitleEvent } from '../event/notice/OB11GroupTitleEvent';
|
||||
import { NapCatCore, RawMessage, ChatType, NTGrayTipElementSubTypeV2, TipGroupElementType, Peer } from '@/core';
|
||||
|
||||
export async function NT2PrivateEvent(core: NapCatCore, obContext: NapCatOneBot11Adapter, msg: RawMessage): Promise<OB11BaseNoticeEvent | undefined> {
|
||||
@@ -72,7 +72,7 @@ export async function NT2GroupEvent(core: NapCatCore, obContext: NapCatOneBot11A
|
||||
parseInt(msg.peerUid),
|
||||
parseInt(core.selfInfo.uin),
|
||||
0,
|
||||
'leave'
|
||||
'leave',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ export async function NT2GroupEvent(core: NapCatCore, obContext: NapCatOneBot11A
|
||||
name: element.fileElement.fileName,
|
||||
size: parseInt(element.fileElement.fileSize),
|
||||
busid: element.fileElement.fileBizId || 0,
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
if (element.grayTipElement) {
|
||||
@@ -113,7 +113,7 @@ export async function NT2GroupEvent(core: NapCatCore, obContext: NapCatOneBot11A
|
||||
parseInt(msg.peerUid),
|
||||
parseInt((await NTQQUserApi.getUinByUidV2(poke_uid[0].uid))!),
|
||||
parseInt((await NTQQUserApi.getUinByUidV2(poke_uid[1].uid))!),
|
||||
pokedetail
|
||||
pokedetail,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ export async function NT2GroupEvent(core: NapCatCore, obContext: NapCatOneBot11A
|
||||
core,
|
||||
parseInt(msg.peerUid),
|
||||
MessageUnique.getShortIdByMsgId(msgData.msgList[0].msgId)!,
|
||||
parseInt(msgData.msgList[0].senderUin)
|
||||
parseInt(msgData.msgList[0].senderUin),
|
||||
);
|
||||
// 获取MsgSeq+Peer可获取具体消息
|
||||
}
|
||||
@@ -145,7 +145,7 @@ export async function NT2GroupEvent(core: NapCatCore, obContext: NapCatOneBot11A
|
||||
core,
|
||||
parseInt(msg.peerUid),
|
||||
parseInt(memberUin),
|
||||
title
|
||||
title,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -94,13 +94,13 @@ export class NapCatOneBot11Adapter {
|
||||
//创建NetWork服务
|
||||
if (ob11Config.http.enable) {
|
||||
this.networkManager.registerAdapter(new OB11PassiveHttpAdapter(
|
||||
ob11Config.http.port, ob11Config.token, this.core, this.actions
|
||||
ob11Config.http.port, ob11Config.token, this.core, this.actions,
|
||||
));
|
||||
}
|
||||
if (ob11Config.http.enablePost) {
|
||||
ob11Config.http.postUrls.forEach(url => {
|
||||
this.networkManager.registerAdapter(new OB11ActiveHttpAdapter(
|
||||
url, ob11Config.token, this.core, this
|
||||
url, ob11Config.token, this.core, this,
|
||||
));
|
||||
});
|
||||
}
|
||||
@@ -113,7 +113,7 @@ export class NapCatOneBot11Adapter {
|
||||
if (ob11Config.reverseWs.enable) {
|
||||
ob11Config.reverseWs.urls.forEach(url => {
|
||||
this.networkManager.registerAdapter(new OB11ActiveWebSocketAdapter(
|
||||
url, 5000, ob11Config.heartInterval, ob11Config.token, this.core, this.actions
|
||||
url, 5000, ob11Config.heartInterval, ob11Config.token, this.core, this.actions,
|
||||
));
|
||||
});
|
||||
}
|
||||
@@ -134,9 +134,10 @@ export class NapCatOneBot11Adapter {
|
||||
await this.reloadNetwork(prev, newConfig);
|
||||
});
|
||||
}
|
||||
|
||||
initRecentContactListener() {
|
||||
const recentContactListener = new NodeIKernelRecentContactListener();
|
||||
recentContactListener.onRecentContactNotification = function (msgList: any[], /* arg0: { msgListUnreadCnt: string }, arg1: number */) {
|
||||
recentContactListener.onRecentContactNotification = function(msgList: any[] /* arg0: { msgListUnreadCnt: string }, arg1: number */) {
|
||||
msgList.forEach((msg) => {
|
||||
if (msg.chatType == ChatType.KCHATTYPEGROUP) {
|
||||
// log("recent contact", msgList, arg0, arg1);
|
||||
@@ -157,10 +158,10 @@ export class NapCatOneBot11Adapter {
|
||||
if (prev.http.enable !== now.http.enable) {
|
||||
if (now.http.enable) {
|
||||
await this.networkManager.registerAdapterAndOpen(new OB11PassiveHttpAdapter(
|
||||
now.http.port, now.token, this.core, this.actions
|
||||
now.http.port, now.token, this.core, this.actions,
|
||||
));
|
||||
} else {
|
||||
await this.networkManager.closeAdapterByPredicate(adapter => adapter instanceof OB11PassiveHttpAdapter,);
|
||||
await this.networkManager.closeAdapterByPredicate(adapter => adapter instanceof OB11PassiveHttpAdapter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,7 +170,7 @@ export class NapCatOneBot11Adapter {
|
||||
if (now.http.enablePost) {
|
||||
now.http.postUrls.forEach(url => {
|
||||
this.networkManager.registerAdapterAndOpen(new OB11ActiveHttpAdapter(
|
||||
url, now.token, this.core, this
|
||||
url, now.token, this.core, this,
|
||||
));
|
||||
});
|
||||
} else {
|
||||
@@ -183,7 +184,7 @@ export class NapCatOneBot11Adapter {
|
||||
);
|
||||
for (const url of added) {
|
||||
await this.networkManager.registerAdapterAndOpen(new OB11ActiveHttpAdapter(
|
||||
url, now.token, this.core, this
|
||||
url, now.token, this.core, this,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -197,7 +198,7 @@ export class NapCatOneBot11Adapter {
|
||||
));
|
||||
} else {
|
||||
await this.networkManager.closeAdapterByPredicate(
|
||||
adapter => adapter instanceof OB11PassiveWebSocketAdapter
|
||||
adapter => adapter instanceof OB11PassiveWebSocketAdapter,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -207,12 +208,12 @@ export class NapCatOneBot11Adapter {
|
||||
if (now.reverseWs.enable) {
|
||||
now.reverseWs.urls.forEach(url => {
|
||||
this.networkManager.registerAdapterAndOpen(new OB11ActiveWebSocketAdapter(
|
||||
url, 5000, now.heartInterval, now.token, this.core, this.actions
|
||||
url, 5000, now.heartInterval, now.token, this.core, this.actions,
|
||||
));
|
||||
});
|
||||
} else {
|
||||
await this.networkManager.closeAdapterByPredicate(
|
||||
adapter => adapter instanceof OB11ActiveWebSocketAdapter
|
||||
adapter => adapter instanceof OB11ActiveWebSocketAdapter,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -223,7 +224,7 @@ export class NapCatOneBot11Adapter {
|
||||
);
|
||||
for (const url of added) {
|
||||
await this.networkManager.registerAdapterAndOpen(new OB11ActiveWebSocketAdapter(
|
||||
url, 5000, now.heartInterval, now.token, this.core, this.actions
|
||||
url, 5000, now.heartInterval, now.token, this.core, this.actions,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -300,7 +301,7 @@ export class NapCatOneBot11Adapter {
|
||||
};
|
||||
|
||||
this.context.session.getMsgService().addKernelMsgListener(
|
||||
proxiedListenerOf(msgListener, this.context.logger) as any
|
||||
proxiedListenerOf(msgListener, this.context.logger) as any,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -335,7 +336,7 @@ export class NapCatOneBot11Adapter {
|
||||
};
|
||||
|
||||
this.context.session.getBuddyService().addKernelBuddyListener(
|
||||
proxiedListenerOf(buddyListener, this.context.logger) as any
|
||||
proxiedListenerOf(buddyListener, this.context.logger) as any,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -377,7 +378,7 @@ export class NapCatOneBot11Adapter {
|
||||
parseInt(member1.uin),
|
||||
[
|
||||
GroupNotifyMsgType.CANCEL_ADMIN_NOTIFY_CANCELED,
|
||||
GroupNotifyMsgType.CANCEL_ADMIN_NOTIFY_ADMIN
|
||||
GroupNotifyMsgType.CANCEL_ADMIN_NOTIFY_ADMIN,
|
||||
].includes(notify.type) ? 'unset' : 'set',
|
||||
);
|
||||
this.networkManager.emitEvent(groupAdminNoticeEvent)
|
||||
@@ -471,7 +472,7 @@ export class NapCatOneBot11Adapter {
|
||||
};
|
||||
|
||||
this.context.session.getGroupService().addKernelGroupListener(
|
||||
proxiedListenerOf(groupListener, this.context.logger)
|
||||
proxiedListenerOf(groupListener, this.context.logger),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ export class OB11ActiveHttpAdapter implements IOB11NetworkAdapter {
|
||||
public url: string,
|
||||
public secret: string | undefined,
|
||||
public core: NapCatCore,
|
||||
public obContext: NapCatOneBot11Adapter
|
||||
public obContext: NapCatOneBot11Adapter,
|
||||
) {
|
||||
this.logger = core.context.logger;
|
||||
}
|
||||
|
@@ -119,6 +119,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
connectEvent(core: NapCatCore) {
|
||||
try {
|
||||
this.checkStateAndReply<any>(new OB11LifeCycleEvent(core, LifeCycleSubType.CONNECT));
|
||||
@@ -126,6 +127,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter {
|
||||
this.logger.logError('[OneBot] [WebSocket Client] 发送生命周期失败', e);
|
||||
}
|
||||
}
|
||||
|
||||
private async handleMessage(message: any) {
|
||||
let receiveData: { action: ActionName, params?: any, echo?: any } = { action: ActionName.Unknown, params: {} };
|
||||
let echo = undefined;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { IOB11NetworkAdapter, OB11EmitEventContent } from './index';
|
||||
import { IOB11NetworkAdapter } from './index';
|
||||
import express, { Express, Request, Response } from 'express';
|
||||
import http from 'http';
|
||||
import { NapCatCore } from '@/core';
|
||||
@@ -44,6 +44,7 @@ export class OB11PassiveHttpAdapter implements IOB11NetworkAdapter {
|
||||
this.server?.close();
|
||||
this.app = undefined;
|
||||
}
|
||||
|
||||
private initializeServer() {
|
||||
this.app = express();
|
||||
this.server = http.createServer(this.app);
|
||||
|
@@ -28,7 +28,7 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter {
|
||||
heartbeatInterval: number,
|
||||
token: string,
|
||||
core: NapCatCore,
|
||||
public actions: ActionMap
|
||||
public actions: ActionMap,
|
||||
) {
|
||||
this.core = core;
|
||||
this.logger = core.context.logger;
|
||||
|
@@ -2,7 +2,7 @@ import type { SelfInfo } from '@/core/entities';
|
||||
|
||||
import { LogWrapper } from '@/common/utils/log';
|
||||
import { NodeIKernelLoginListener, NodeIKernelSessionListener } from '@/core/listeners';
|
||||
import { NodeIDispatcherAdapter, NodeIDependsAdapter, NodeIGlobalAdapter } from '@/core/adapters';
|
||||
import { NodeIDependsAdapter, NodeIDispatcherAdapter, NodeIGlobalAdapter } from '@/core/adapters';
|
||||
import { NapCatPathWrapper } from '@/common/framework/napcat';
|
||||
import {
|
||||
InstanceContext,
|
||||
@@ -92,7 +92,7 @@ export async function NCoreInitShell() {
|
||||
}
|
||||
}
|
||||
|
||||
const selfInfo = await new Promise<SelfInfo>((resolve, reject) => {
|
||||
const selfInfo = await new Promise<SelfInfo>((resolve) => {
|
||||
const loginListener = new NodeIKernelLoginListener();
|
||||
|
||||
// from constructor
|
||||
@@ -129,7 +129,7 @@ export async function NCoreInitShell() {
|
||||
};
|
||||
loginListener.onQRCodeSessionFailed = (errType: number, errCode: number, errMsg: string) => {
|
||||
//logger.logError('登录失败(onQRCodeSessionFailed)', errCode, errMsg);
|
||||
logger.logError('[Core] [Login] Login Error,ErrCode: ', errCode, " ErrMsg:", errMsg);
|
||||
logger.logError('[Core] [Login] Login Error,ErrCode: ', errCode, ' ErrMsg:', errMsg);
|
||||
if (errType == 1 && errCode == 3) {
|
||||
// 二维码过期刷新
|
||||
}
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import express from 'express';
|
||||
import { resolve } from 'node:path';
|
||||
import { ALLRouter } from './src/router';
|
||||
import { LogWrapper } from '@/common/utils/log';
|
||||
import { NapCatPathWrapper } from '@/common/framework/napcat';
|
||||
|
@@ -6,7 +6,7 @@ import { SettingSelect } from './components/SettingSelect';
|
||||
import { OB11Config, OB11ConfigWrapper } from './components/WebUiApiOB11Config';
|
||||
|
||||
async function onSettingWindowCreated(view: Element) {
|
||||
const isEmpty = (value: any) => value === undefined || value === undefined || value === '';
|
||||
const isEmpty = (value: any) => value === undefined || false || value === '';
|
||||
await OB11ConfigWrapper.Init(localStorage.getItem('auth') as string);
|
||||
const ob11Config: OB11Config = await OB11ConfigWrapper.GetOB11Config();
|
||||
const setOB11Config = (key: string, value: any) => {
|
||||
@@ -69,8 +69,7 @@ async function onSettingWindowCreated(view: Element) {
|
||||
<setting-text>HTTP 事件上报密钥</setting-text>
|
||||
</div>
|
||||
<div class="q-input">
|
||||
<input id="config-ob11-http-secret" class="q-input__inner" data-config-key="ob11.http.secret" type="text" value="${ob11Config.http.secret
|
||||
}" placeholder="未设置" />
|
||||
<input id="config-ob11-http-secret" class="q-input__inner" data-config-key="ob11.http.secret" type="text" value="${ob11Config.http.secret}" placeholder="未设置" />
|
||||
</div>
|
||||
</setting-item>
|
||||
<setting-item data-direction="row">
|
||||
@@ -174,17 +173,17 @@ async function onSettingWindowCreated(view: Element) {
|
||||
'https://github.com/NapNeko/NapCatQQ',
|
||||
SettingButton('点个星星', 'open-github'),
|
||||
),
|
||||
SettingItem('NapCat 文档', '', SettingButton('看看文档', 'open-docs'))
|
||||
SettingItem('NapCat 文档', '', SettingButton('看看文档', 'open-docs')),
|
||||
]),
|
||||
SettingItem(
|
||||
'Telegram 群',
|
||||
'https://t.me/+nLZEnpne-pQ1OWFl',
|
||||
SettingButton('进去逛逛', 'open-telegram')
|
||||
SettingButton('进去逛逛', 'open-telegram'),
|
||||
),
|
||||
SettingItem(
|
||||
'QQ 群',
|
||||
'518662028',
|
||||
SettingButton('我要进去', 'open-qq-group')
|
||||
SettingButton('我要进去', 'open-qq-group'),
|
||||
),
|
||||
'</div>',
|
||||
].join(''),
|
||||
|
Reference in New Issue
Block a user