mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
daf42c8203 | ||
![]() |
0a18bae3b5 | ||
![]() |
919705966c | ||
![]() |
2c54aee63e | ||
![]() |
3f80bdf2a3 | ||
![]() |
1c429b8dd3 | ||
![]() |
5669e2b0b7 |
@@ -4,7 +4,7 @@
|
|||||||
"name": "NapCatQQ",
|
"name": "NapCatQQ",
|
||||||
"slug": "NapCat.Framework",
|
"slug": "NapCat.Framework",
|
||||||
"description": "高性能的 OneBot 11 协议实现",
|
"description": "高性能的 OneBot 11 协议实现",
|
||||||
"version": "2.4.0",
|
"version": "2.4.2",
|
||||||
"icon": "./logo.png",
|
"icon": "./logo.png",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
"name": "napcat",
|
"name": "napcat",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "2.4.0",
|
"version": "2.4.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:framework": "vite build --mode framework",
|
"build:framework": "vite build --mode framework",
|
||||||
"build:shell": "vite build --mode shell",
|
"build:shell": "vite build --mode shell",
|
||||||
|
@@ -216,7 +216,7 @@ export async function checkUriType(Uri: string) {
|
|||||||
return { Uri: filePath, Type: FileUriType.Local };
|
return { Uri: filePath, Type: FileUriType.Local };
|
||||||
}
|
}
|
||||||
if (uri.startsWith('data:')) {
|
if (uri.startsWith('data:')) {
|
||||||
let data = uri.split(',')[1];
|
const data = uri.split(',')[1];
|
||||||
if (data) return { Uri: data, Type: FileUriType.Base64 };
|
if (data) return { Uri: data, Type: FileUriType.Base64 };
|
||||||
}
|
}
|
||||||
}, Uri);
|
}, Uri);
|
||||||
|
@@ -1 +1 @@
|
|||||||
export const napCatVersion = '2.4.0';
|
export const napCatVersion = '2.4.2';
|
||||||
|
@@ -32,6 +32,10 @@ export class NTQQGroupApi {
|
|||||||
for (const group of this.groups) {
|
for (const group of this.groups) {
|
||||||
this.groupCache.set(group.groupCode, group);
|
this.groupCache.set(group.groupCode, group);
|
||||||
}
|
}
|
||||||
|
// let text = await this.context.session.getMsgService().sendSsoCmdReqByContend(
|
||||||
|
// 'LightAppSvc.mini_app_share.AdaptShareInfo',
|
||||||
|
// JSON.stringify({ data: 'test' }));
|
||||||
|
// console.log(text);
|
||||||
this.context.logger.logDebug(`加载${this.groups.length}个群组缓存完成`);
|
this.context.logger.logDebug(`加载${this.groups.length}个群组缓存完成`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -153,7 +153,10 @@ interface CommonExt {
|
|||||||
labels: any[];
|
labels: any[];
|
||||||
qqLevel: QQLevel;
|
qqLevel: QQLevel;
|
||||||
}
|
}
|
||||||
|
export enum BuddyListReqType {
|
||||||
|
KNOMAL,
|
||||||
|
KLETTER
|
||||||
|
}
|
||||||
interface Pic {
|
interface Pic {
|
||||||
picId: string;
|
picId: string;
|
||||||
picTime: number;
|
picTime: number;
|
||||||
@@ -375,8 +378,4 @@ export enum ProfileBizType {
|
|||||||
KVAS,
|
KVAS,
|
||||||
KQZONE,
|
KQZONE,
|
||||||
KOTHER
|
KOTHER
|
||||||
}export enum BuddyListReqType {
|
}
|
||||||
KNOMAL,
|
|
||||||
KLETTER
|
|
||||||
}
|
|
||||||
|
|
@@ -14,7 +14,7 @@ export interface NodeIKernelBuddyService {
|
|||||||
}>
|
}>
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
getBuddyListFromCache(callFrom: string): Promise<Array<
|
getBuddyListFromCache(reqType: BuddyListReqType): Promise<Array<
|
||||||
{
|
{
|
||||||
categoryId: number,//9999应该跳过 那是兜底数据吧
|
categoryId: number,//9999应该跳过 那是兜底数据吧
|
||||||
categorySortId: number,//排序方式
|
categorySortId: number,//排序方式
|
||||||
@@ -23,7 +23,7 @@ export interface NodeIKernelBuddyService {
|
|||||||
onlineCount: number,//在线数目
|
onlineCount: number,//在线数目
|
||||||
buddyUids: Array<string>//Uids
|
buddyUids: Array<string>//Uids
|
||||||
}>>;
|
}>>;
|
||||||
|
|
||||||
addKernelBuddyListener(listener: NodeIKernelBuddyListener): number;
|
addKernelBuddyListener(listener: NodeIKernelBuddyListener): number;
|
||||||
|
|
||||||
getAllBuddyCount(): number;
|
getAllBuddyCount(): number;
|
||||||
|
@@ -59,6 +59,7 @@ export interface QuickLoginResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface NodeIKernelLoginService {
|
export interface NodeIKernelLoginService {
|
||||||
|
connect(): boolean;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-misused-new
|
// eslint-disable-next-line @typescript-eslint/no-misused-new
|
||||||
new(): NodeIKernelLoginService;
|
new(): NodeIKernelLoginService;
|
||||||
|
|
||||||
|
@@ -3,6 +3,11 @@ import { BizKey, ModifyProfileParams, NodeIKernelProfileListener, ProfileBizType
|
|||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
|
|
||||||
export interface NodeIKernelProfileService {
|
export interface NodeIKernelProfileService {
|
||||||
|
getOtherFlag(callfrom: string, uids: string[]): Promise<Map<string, any>>;
|
||||||
|
|
||||||
|
getVasInfo(callfrom: string, uids: string[]): Promise<Map<string, any>>;
|
||||||
|
|
||||||
|
getRelationFlag(callfrom: string, uids: string[]): Promise<Map<string, any>>;
|
||||||
|
|
||||||
getUidByUin(callfrom: string, uin: Array<string>): Promise<Map<string, string>>;
|
getUidByUin(callfrom: string, uin: Array<string>): Promise<Map<string, string>>;
|
||||||
|
|
||||||
|
@@ -51,7 +51,7 @@ export class GetGroupEssence extends BaseAction<Payload, any> {
|
|||||||
operator_nick: msg.add_digest_nick,
|
operator_nick: msg.add_digest_nick,
|
||||||
message_id: message_id,
|
message_id: message_id,
|
||||||
operator_time: msg.add_digest_time,
|
operator_time: msg.add_digest_time,
|
||||||
content: (await this.obContext.apis.MsgApi.parseMessage(rawMessage, 'array'))?.message
|
content: (await this.obContext.apis.MsgApi.parseMessage(rawMessage))?.message
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const msgTempData = JSON.stringify({
|
const msgTempData = JSON.stringify({
|
||||||
|
@@ -35,7 +35,7 @@ class GetMsg extends BaseAction<Payload, OB11Message> {
|
|||||||
const msg = await this.core.apis.MsgApi.getMsgsByMsgId(
|
const msg = await this.core.apis.MsgApi.getMsgsByMsgId(
|
||||||
peer,
|
peer,
|
||||||
[msgIdWithPeer?.MsgId || payload.message_id.toString()]);
|
[msgIdWithPeer?.MsgId || payload.message_id.toString()]);
|
||||||
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg.msgList[0], 'array');
|
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg.msgList[0]);
|
||||||
if (!retMsg) throw Error('消息为空');
|
if (!retMsg) throw Error('消息为空');
|
||||||
try {
|
try {
|
||||||
retMsg.message_id = MessageUnique.createUniqueMsgId(peer, msg.msgList[0].msgId)!;
|
retMsg.message_id = MessageUnique.createUniqueMsgId(peer, msg.msgList[0].msgId)!;
|
||||||
|
@@ -21,7 +21,7 @@ export default class GetRecentContact extends BaseAction<Payload, any> {
|
|||||||
const FastMsg = await this.core.apis.MsgApi.getMsgsByMsgId({ chatType: t.chatType, peerUid: t.peerUid }, [t.msgId]);
|
const FastMsg = await this.core.apis.MsgApi.getMsgsByMsgId({ chatType: t.chatType, peerUid: t.peerUid }, [t.msgId]);
|
||||||
if (FastMsg.msgList.length > 0) {
|
if (FastMsg.msgList.length > 0) {
|
||||||
//扩展ret.info.changedList
|
//扩展ret.info.changedList
|
||||||
const lastestMsg = await this.obContext.apis.MsgApi.parseMessage(FastMsg.msgList[0], 'array');
|
const lastestMsg = await this.obContext.apis.MsgApi.parseMessage(FastMsg.msgList[0]);
|
||||||
return {
|
return {
|
||||||
lastestMsg: lastestMsg,
|
lastestMsg: lastestMsg,
|
||||||
peerUin: t.peerUin,
|
peerUin: t.peerUin,
|
||||||
|
@@ -19,6 +19,7 @@ import { OB11GroupPokeEvent } from '@/onebot/event/notice/OB11PokeEvent';
|
|||||||
import { OB11GroupEssenceEvent } from '@/onebot/event/notice/OB11GroupEssenceEvent';
|
import { OB11GroupEssenceEvent } from '@/onebot/event/notice/OB11GroupEssenceEvent';
|
||||||
import { OB11GroupTitleEvent } from '@/onebot/event/notice/OB11GroupTitleEvent';
|
import { OB11GroupTitleEvent } from '@/onebot/event/notice/OB11GroupTitleEvent';
|
||||||
import { FileNapCatOneBotUUID } from '@/common/helper';
|
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||||
|
import { pathToFileURL } from 'node:url';
|
||||||
|
|
||||||
export class OneBotGroupApi {
|
export class OneBotGroupApi {
|
||||||
obContext: NapCatOneBot11Adapter;
|
obContext: NapCatOneBot11Adapter;
|
||||||
@@ -77,7 +78,8 @@ export class OneBotGroupApi {
|
|||||||
id: FileNapCatOneBotUUID.encode({
|
id: FileNapCatOneBotUUID.encode({
|
||||||
chatType: ChatType.KCHATTYPEGROUP,
|
chatType: ChatType.KCHATTYPEGROUP,
|
||||||
peerUid: msg.peerUid,
|
peerUid: msg.peerUid,
|
||||||
}, msg.msgId, element.elementId, element.fileElement.fileName),
|
}, msg.msgId, element.elementId, "." + element.fileElement.fileName),
|
||||||
|
url: pathToFileURL(element.fileElement.filePath).href,
|
||||||
name: element.fileElement.fileName,
|
name: element.fileElement.fileName,
|
||||||
size: parseInt(element.fileElement.fileSize),
|
size: parseInt(element.fileElement.fileSize),
|
||||||
busid: element.fileElement.fileBizId || 0,
|
busid: element.fileElement.fileBizId || 0,
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { FileNapCatOneBotUUID } from '@/common/helper';
|
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
|
import { pathToFileURL } from 'node:url';
|
||||||
import {
|
import {
|
||||||
AtType,
|
AtType,
|
||||||
ChatType,
|
ChatType,
|
||||||
@@ -106,7 +107,7 @@ export class OneBotMsgApi {
|
|||||||
peerUid: msg.peerUid,
|
peerUid: msg.peerUid,
|
||||||
guildId: '',
|
guildId: '',
|
||||||
};
|
};
|
||||||
const encodedFileId = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, element.fileName);
|
const encodedFileId = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "."+element.fileName);
|
||||||
return {
|
return {
|
||||||
type: OB11MessageDataType.image,
|
type: OB11MessageDataType.image,
|
||||||
data: {
|
data: {
|
||||||
@@ -114,6 +115,7 @@ export class OneBotMsgApi {
|
|||||||
sub_type: element.picSubType,
|
sub_type: element.picSubType,
|
||||||
file_id: encodedFileId,
|
file_id: encodedFileId,
|
||||||
url: await this.core.apis.FileApi.getImageUrl(element),
|
url: await this.core.apis.FileApi.getImageUrl(element),
|
||||||
|
path: element.filePath,
|
||||||
file_size: element.fileSize,
|
file_size: element.fileSize,
|
||||||
file_unique: element.fileName
|
file_unique: element.fileName
|
||||||
},
|
},
|
||||||
@@ -135,8 +137,8 @@ export class OneBotMsgApi {
|
|||||||
data: {
|
data: {
|
||||||
file: element.fileName,
|
file: element.fileName,
|
||||||
path: element.filePath,
|
path: element.filePath,
|
||||||
url: element.filePath,
|
url: pathToFileURL(element.filePath).href,
|
||||||
file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, element.fileName),
|
file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "."+element.fileName),
|
||||||
file_size: element.fileSize,
|
file_size: element.fileSize,
|
||||||
file_unique: element.fileName,
|
file_unique: element.fileName,
|
||||||
},
|
},
|
||||||
@@ -175,13 +177,16 @@ export class OneBotMsgApi {
|
|||||||
peerUid: msg.peerUid,
|
peerUid: msg.peerUid,
|
||||||
guildId: '',
|
guildId: '',
|
||||||
};
|
};
|
||||||
|
const { emojiId } = _;
|
||||||
|
const dir = emojiId.substring(0, 2);
|
||||||
|
const url = `https://gxh.vip.qq.com/club/item/parcel/item/${dir}/${emojiId}/raw300.gif`;
|
||||||
return {
|
return {
|
||||||
type: OB11MessageDataType.image,
|
type: OB11MessageDataType.image,
|
||||||
data: {
|
data: {
|
||||||
file: 'marketface',
|
file: 'marketface',
|
||||||
file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, ".jpg"),
|
file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "."+_.key+".jpg"),
|
||||||
path: elementWrapper.elementId,
|
path: elementWrapper.elementId,
|
||||||
url: elementWrapper.elementId,
|
url: url,
|
||||||
file_unique: _.key
|
file_unique: _.key
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -257,14 +262,14 @@ export class OneBotMsgApi {
|
|||||||
if (!videoDownUrl) {
|
if (!videoDownUrl) {
|
||||||
videoDownUrl = element.filePath;
|
videoDownUrl = element.filePath;
|
||||||
}
|
}
|
||||||
|
const fileCode = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "."+element.fileName);
|
||||||
return {
|
return {
|
||||||
type: OB11MessageDataType.video,
|
type: OB11MessageDataType.video,
|
||||||
data: {
|
data: {
|
||||||
file: element.fileName,
|
file: fileCode,
|
||||||
path: videoDownUrl,
|
path: videoDownUrl,
|
||||||
url: videoDownUrl,
|
url: videoDownUrl ?? pathToFileURL(element.filePath).href,
|
||||||
file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, element.fileName),
|
file_id: fileCode,
|
||||||
file_size: element.fileSize,
|
file_size: element.fileSize,
|
||||||
file_unique: element.fileName,
|
file_unique: element.fileName,
|
||||||
},
|
},
|
||||||
@@ -277,14 +282,16 @@ export class OneBotMsgApi {
|
|||||||
peerUid: msg.peerUid,
|
peerUid: msg.peerUid,
|
||||||
guildId: '',
|
guildId: '',
|
||||||
};
|
};
|
||||||
const fileCode = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, element.fileName);
|
const fileCode = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "."+element.fileName);
|
||||||
return {
|
return {
|
||||||
type: OB11MessageDataType.voice,
|
type: OB11MessageDataType.voice,
|
||||||
data: {
|
data: {
|
||||||
file: fileCode,
|
file: fileCode,
|
||||||
path: element.filePath,
|
path: element.filePath,
|
||||||
|
url: pathToFileURL(element.filePath).href,
|
||||||
file_id: fileCode,
|
file_id: fileCode,
|
||||||
file_size: element.fileSize,
|
file_size: element.fileSize,
|
||||||
|
file_unique: element.fileName
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -793,18 +800,20 @@ export class OneBotMsgApi {
|
|||||||
) {
|
) {
|
||||||
const isBlankUrl = !inputdata.url || inputdata.url === '';
|
const isBlankUrl = !inputdata.url || inputdata.url === '';
|
||||||
const isBlankFile = !inputdata.file || inputdata.file === '';
|
const isBlankFile = !inputdata.file || inputdata.file === '';
|
||||||
|
const isBlankPath = !inputdata.path || inputdata.path === '';
|
||||||
if (isBlankUrl && isBlankFile) {
|
if (isBlankUrl && isBlankFile) {
|
||||||
this.core.context.logger.logError('文件消息缺少参数', inputdata);
|
this.core.context.logger.logError('文件消息缺少参数', inputdata);
|
||||||
throw Error('文件消息缺少参数');
|
throw Error('文件消息缺少参数');
|
||||||
}
|
}
|
||||||
const fileOrUrl = (isBlankUrl ? inputdata.file : inputdata.url) ?? '';
|
//path->url->file
|
||||||
|
const realUri = (!isBlankUrl ? inputdata.url :(!isBlankPath ? inputdata.path:inputdata.file ))??'';
|
||||||
const {
|
const {
|
||||||
path,
|
path,
|
||||||
isLocal,
|
isLocal,
|
||||||
fileName,
|
fileName,
|
||||||
errMsg,
|
errMsg,
|
||||||
success,
|
success,
|
||||||
} = (await uri2local(this.core.NapCatTempPath, fileOrUrl));
|
} = (await uri2local(this.core.NapCatTempPath, realUri));
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
this.core.context.logger.logError('文件下载失败', errMsg);
|
this.core.context.logger.logError('文件下载失败', errMsg);
|
||||||
|
@@ -6,6 +6,7 @@ export interface GroupUploadFile {
|
|||||||
name: string,
|
name: string,
|
||||||
size: number,
|
size: number,
|
||||||
busid: number,
|
busid: number,
|
||||||
|
url:string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class OB11GroupUploadNoticeEvent extends OB11GroupNoticeEvent {
|
export class OB11GroupUploadNoticeEvent extends OB11GroupNoticeEvent {
|
||||||
|
@@ -84,6 +84,8 @@ export interface OB11MessageText {
|
|||||||
|
|
||||||
export interface OB11MessageFileBase {
|
export interface OB11MessageFileBase {
|
||||||
data: {
|
data: {
|
||||||
|
file_unique?:string,
|
||||||
|
path?: string;
|
||||||
thumb?: string;
|
thumb?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
file: string,
|
file: string,
|
||||||
|
@@ -150,7 +150,12 @@ export async function NCoreInitShell() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
loginService.addKernelLoginListener(proxiedListenerOf(loginListener, logger) as any);
|
loginService.addKernelLoginListener(proxiedListenerOf(loginListener, logger) as any);
|
||||||
|
const isConnect = loginService.connect();
|
||||||
|
if (!isConnect) {
|
||||||
|
logger.logError('核心登录服务连接失败!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
logger.log('核心登录服务连接成功!');
|
||||||
// 实现WebUi快速登录
|
// 实现WebUi快速登录
|
||||||
loginService.getLoginList().then((res) => {
|
loginService.getLoginList().then((res) => {
|
||||||
// 遍历 res.LocalLoginInfoList[x].isQuickLogin是否可以 res.LocalLoginInfoList[x].uin 转为string 加入string[] 最后遍历完成调用WebUiDataRuntime.setQQQuickLoginList
|
// 遍历 res.LocalLoginInfoList[x].isQuickLogin是否可以 res.LocalLoginInfoList[x].uin 转为string 加入string[] 最后遍历完成调用WebUiDataRuntime.setQQQuickLoginList
|
||||||
|
@@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) {
|
|||||||
SettingItem(
|
SettingItem(
|
||||||
'<span id="napcat-update-title">Napcat</span>',
|
'<span id="napcat-update-title">Napcat</span>',
|
||||||
undefined,
|
undefined,
|
||||||
SettingButton('V2.4.0', 'napcat-update-button', 'secondary'),
|
SettingButton('V2.4.2', 'napcat-update-button', 'secondary'),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
@@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) {
|
|||||||
SettingItem(
|
SettingItem(
|
||||||
'<span id="napcat-update-title">Napcat</span>',
|
'<span id="napcat-update-title">Napcat</span>',
|
||||||
void 0,
|
void 0,
|
||||||
SettingButton("V2.4.0", "napcat-update-button", "secondary")
|
SettingButton("V2.4.2", "napcat-update-button", "secondary")
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
Reference in New Issue
Block a user