Compare commits

..

20 Commits

Author SHA1 Message Date
手瓜一十雪
b6e392fdb2 release: v2.6.11 2024-09-22 11:42:13 +08:00
手瓜一十雪
2280e83aa2 fix: type 2024-09-21 17:40:42 +08:00
手瓜一十雪
f49b94edb9 Merge pull request #392 from Fripine/feat/more-music-types
feat: support more types of music cards
2024-09-21 15:00:59 +08:00
Fripine
2428a12221 chore 2024-09-21 12:30:05 +08:00
Fripine
9c353f3760 feat: support more types of music cards 2024-09-21 12:17:05 +08:00
手瓜一十雪
5b86d25d7f Merge pull request #389 from Fripine/fix/FriendAdd
fix: FriendAddNoticeEvent
2024-09-20 21:18:14 +08:00
Fripine
2b168e8bbc fix: FriendAdd 2024-09-20 15:50:31 +08:00
手瓜一十雪
537db32847 Merge pull request #388 from NapNeko/revert-387-fix/friendAddEvent
Revert "fix: 好友添加成功事件"
2024-09-20 15:36:32 +08:00
手瓜一十雪
498b7f9f2b Revert "fix: 好友添加成功事件" 2024-09-20 14:33:52 +08:00
手瓜一十雪
9935568597 Merge pull request #387 from Fripine/fix/friendAddEvent
fix: 好友添加成功事件
2024-09-20 13:00:13 +08:00
Fripine
467003af8c chore 2024-09-20 10:24:19 +08:00
Fripine
4c9edcc47b chore 2024-09-20 10:21:26 +08:00
Fripine
24bf9cf121 chore: 换一种方法 2024-09-20 10:17:30 +08:00
手瓜一十雪
e06f6f39a9 Merge pull request #386 from 123233513/main
增加处理消息段时的检查,过滤无效消息段。
2024-09-20 07:54:52 +08:00
123233513
98ee0c307b Merge branch 'main' of https://github.com/123233513/NapCatQQ 2024-09-20 04:57:41 +08:00
Fripine
5e53ea0bc3 fix: cant emit FriendAddNoticeEvent 2024-09-20 04:38:09 +08:00
123233513
847d88ea77 Update msg.ts
处理消息段时的检查,过滤无效消息段。
2024-09-19 22:14:18 +08:00
123233513
d5046cc2b3 Merge branch 'main' of https://githubfast.com/123233513/NapCatQQ 2024-09-19 21:36:52 +08:00
123233513
3ad64b7cbb 增加处理消息段时的检查,过滤无效消息段。 2024-09-19 21:31:33 +08:00
手瓜一十雪
0dbfe8ca55 feat: 拦截不合法消息 2024-09-19 20:49:33 +08:00
8 changed files with 54 additions and 46 deletions

View File

@@ -4,7 +4,7 @@
"name": "NapCatQQ", "name": "NapCatQQ",
"slug": "NapCat.Framework", "slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现", "description": "高性能的 OneBot 11 协议实现",
"version": "2.6.10", "version": "2.6.11",
"icon": "./logo.png", "icon": "./logo.png",
"authors": [ "authors": [
{ {

View File

@@ -2,7 +2,7 @@
"name": "napcat", "name": "napcat",
"private": true, "private": true,
"type": "module", "type": "module",
"version": "2.6.10", "version": "2.6.11",
"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",

View File

@@ -1 +1 @@
export const napCatVersion = '2.6.10'; export const napCatVersion = '2.6.11';

View File

@@ -1,14 +1,15 @@
export interface IdMusicSignPostData { export interface IdMusicSignPostData {
type: 'qq' | '163', type: 'qq' | '163' | 'kugou' | 'migu' | 'kuwo',
id: string | number, id: string | number,
} }
export interface CustomMusicSignPostData { export interface CustomMusicSignPostData {
type: 'custom', type: 'qq' | '163' | 'kugou' | 'migu' | 'kuwo' | 'custom',
id: undefined,
url: string, url: string,
audio: string, audio?: string,
title: string, title?: string,
image?: string, image: string,
singer?: string singer?: string
} }

View File

@@ -1,7 +1,8 @@
import { GeneralCallResult } from './common'; import { GeneralCallResult } from './common';
export interface NodeIKernelNodeMiscService { export interface NodeIKernelNodeMiscService {
writeVersionToRegistry: any; writeVersionToRegistry(version: string): void;
getMiniAppPath(): unknown; getMiniAppPath(): unknown;
setMiniAppVersion(version: string): unknown; setMiniAppVersion(version: string): unknown;

View File

@@ -421,6 +421,10 @@ export class OneBotMsgApi {
// 从face_config.json中获取表情名称 // 从face_config.json中获取表情名称
const sysFaces = faceConfig.sysface; const sysFaces = faceConfig.sysface;
const face: any = sysFaces.find((systemFace) => systemFace.QSid === parsedFaceId.toString()); const face: any = sysFaces.find((systemFace) => systemFace.QSid === parsedFaceId.toString());
if (!face) {
this.core.context.logger.logError('不支持的ID', id);
return undefined;
}
parsedFaceId = parseInt(parsedFaceId.toString()); parsedFaceId = parseInt(parsedFaceId.toString());
let faceType = 1; let faceType = 1;
if (parsedFaceId >= 222) { if (parsedFaceId >= 222) {
@@ -543,32 +547,28 @@ export class OneBotMsgApi {
[OB11MessageDataType.music]: async ({ data }, context) => { [OB11MessageDataType.music]: async ({ data }, context) => {
// 保留, 直到...找到更好的解决方案 // 保留, 直到...找到更好的解决方案
if (data.type === 'custom') { if (data.id !== undefined) {
if (!['qq', '163', 'kugou', 'kuwo', 'migu'].includes(data.type)) {
this.core.context.logger.logError('音乐卡片type错误, 只支持qq、163、kugou、kuwo、migu当前type:', data.type);
return undefined;
}
} else {
if (!['qq', '163', 'kugou', 'kuwo', 'migu', 'custom'].includes(data.type)) {
this.core.context.logger.logError('音乐卡片type错误, 只支持qq、163、kugou、kuwo、migu、custom当前type:', data.type);
return undefined;
}
if (!data.url) { if (!data.url) {
this.core.context.logger.logError('自定义音卡缺少参数url'); this.core.context.logger.logError('自定义音卡缺少参数url');
return undefined; return undefined;
} }
if (!data.audio) { if (!data.image) {
this.core.context.logger.logError('自定义音卡缺少参数audio'); this.core.context.logger.logError('自定义音卡缺少参数image');
return undefined;
}
if (!data.title) {
this.core.context.logger.logError('自定义音卡缺少参数title');
return undefined;
}
} else {
if (!['qq', '163'].includes(data.type)) {
this.core.context.logger.logError('音乐卡片type错误, 只支持qq、163、custom当前type:', data.type);
return undefined;
}
if (!data.id) {
this.core.context.logger.logError('音乐卡片缺少参数id');
return undefined; return undefined;
} }
} }
let postData: IdMusicSignPostData | CustomMusicSignPostData; let postData: IdMusicSignPostData | CustomMusicSignPostData;
if (data.type === 'custom' && data.content) { if (data.id === undefined && data.content) {
const { content, ...others } = data; const { content, ...others } = data;
postData = { singer: content, ...others }; postData = { singer: content, ...others };
} else { } else {
@@ -576,7 +576,7 @@ export class OneBotMsgApi {
} }
let signUrl = this.obContext.configLoader.configData.musicSignUrl; let signUrl = this.obContext.configLoader.configData.musicSignUrl;
if (!signUrl) { if (!signUrl) {
signUrl = 'https://ss.xingzhige.com/music_card/card';//感谢思思! signUrl = 'https://ss.xingzhige.com/music_card/card';//感谢思思!已获思思许可 其余地方使用请自行询问
//throw Error('音乐消息签名地址未配置'); //throw Error('音乐消息签名地址未配置');
} }
try { try {
@@ -628,18 +628,14 @@ export class OneBotMsgApi {
return; return;
} }
for (const element of msg.elements) { for (const element of msg.elements) {
if (element.grayTipElement) { if (element.grayTipElement && element.grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
if (element.grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) { if (element.grayTipElement.jsonGrayTipElement.busiId == 1061) {
if (element.grayTipElement.jsonGrayTipElement.busiId == 1061) { const PokeEvent = await this.obContext.apis.FriendApi.parsePrivatePokeEvent(element.grayTipElement);
const PokeEvent = await this.obContext.apis.FriendApi.parsePrivatePokeEvent(element.grayTipElement); if (PokeEvent) return PokeEvent;
if (PokeEvent) return PokeEvent;
}
} }
if (element.grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_XMLMSG) { //好友添加成功事件
//好友添加成功事件 if (element.grayTipElement.jsonGrayTipElement.busiId == 19324 && msg.peerUid !== '') {
if (element.grayTipElement.xmlElement.templId === '10229' && msg.peerUin !== '') { return new OB11FriendAddNoticeEvent(this.core, Number(await this.core.apis.UserApi.getUinByUidV2(msg.peerUid)));
return new OB11FriendAddNoticeEvent(this.core, parseInt(msg.peerUin) || Number(await this.core.apis.UserApi.getUinByUidV2(msg.peerUid)));
}
} }
} }
} }
@@ -701,36 +697,46 @@ export class OneBotMsgApi {
} }
} }
const msgSegments = (await Promise.allSettled(msg.elements.map( // 处理消息段
const msgSegments = await Promise.allSettled(msg.elements.map(
async (element) => { async (element) => {
for (const key in element) { for (const key in element) {
if (keyCanBeParsed(key, this.rawToOb11Converters) && element[key]) { if (keyCanBeParsed(key, this.rawToOb11Converters) && element[key]) {
return await this.rawToOb11Converters[key]?.( const parsedElement = await this.rawToOb11Converters[key]?.(
// eslint-disable-next-line // eslint-disable-next-line
// @ts-ignore // @ts-ignore
element[key], element[key],
msg, msg,
element, element,
); );
// 对于 face 类型的消息,检查是否存在
if (key === 'faceElement' && !parsedElement) {
return null; // 如果没有找到对应的表情,返回 null
}
return parsedElement;
} }
} }
}, },
))).filter(entry => { ));
// 过滤掉无效的消息段
const validSegments = msgSegments.filter(entry => {
if (entry.status === 'fulfilled') { if (entry.status === 'fulfilled') {
return !!entry.value; return !!entry.value;
} else { } else {
this.core.context.logger.logError('消息段解析失败', entry.reason); this.core.context.logger.logError('消息段解析失败', entry.reason);
return false; return false;
} }
}).map((entry) => (<PromiseFulfilledResult<OB11MessageData>>entry).value); }).map((entry) => (<PromiseFulfilledResult<OB11MessageData>>entry).value).filter(value => value != null);
const msgAsCQCode = msgSegments.map(msg => encodeCQCode(msg)).join('').trim(); const msgAsCQCode = validSegments.map(msg => encodeCQCode(msg)).join('').trim();
if (messagePostFormat === 'string') { if (messagePostFormat === 'string') {
resMsg.message = msgAsCQCode; resMsg.message = msgAsCQCode;
resMsg.raw_message = msgAsCQCode; resMsg.raw_message = msgAsCQCode;
} else { } else {
resMsg.message = msgSegments; resMsg.message = validSegments;
resMsg.raw_message = msgAsCQCode; resMsg.raw_message = msgAsCQCode;
} }
return resMsg; return resMsg;

View File

@@ -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.6.10', 'napcat-update-button', 'secondary'), SettingButton('V2.6.11', 'napcat-update-button', 'secondary'),
), ),
]), ]),
SettingList([ SettingList([

View File

@@ -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.6.10", "napcat-update-button", "secondary") SettingButton("V2.6.11", "napcat-update-button", "secondary")
) )
]), ]),
SettingList([ SettingList([