Compare commits

..

23 Commits

Author SHA1 Message Date
手瓜一十雪
3da1659c8d fix: buddylike 2024-07-20 20:16:45 +08:00
手瓜一十雪
9aa4cd319c release: 1.6.7 2024-07-20 19:52:39 +08:00
手瓜一十雪
5af866cdca fix: error 2024-07-20 19:31:59 +08:00
手瓜一十雪
2b421fa447 release: 1.6.7 2024-07-20 17:43:56 +08:00
手瓜一十雪
30ec964325 feat: new api 2024-07-20 17:33:26 +08:00
手瓜一十雪
714d7d72eb feat: raw api add 2024-07-20 17:09:38 +08:00
手瓜一十雪
687aa0f363 chore: remove debug 2024-07-20 16:37:16 +08:00
手瓜一十雪
8363ab07a7 feat: 支持精华消息 2024-07-20 16:17:02 +08:00
手瓜一十雪
c46a757339 fix: error 2024-07-20 16:14:02 +08:00
手瓜一十雪
557864395b feat: support essence 2024-07-20 16:09:44 +08:00
手瓜一十雪
3f7a85d80b feat: essence get_sender 2024-07-20 16:00:01 +08:00
手瓜一十雪
8d18d2ce1f refactor: 标准化 2024-07-20 15:55:26 +08:00
手瓜一十雪
7141ba1587 refactor: essence and together listener 2024-07-20 15:53:39 +08:00
手瓜一十雪
44d350a225 docs: todo 2024-07-20 15:37:57 +08:00
手瓜一十雪
239b8e72d9 Merge pull request #134 from serfend/main
fix[group]handle_request reason empty
2024-07-20 15:24:39 +08:00
手瓜一十雪
279bdb6fb1 Merge pull request #135 from pohgxz/main
群戳一戳增加原始信息
2024-07-20 15:24:27 +08:00
Nepenthe
a0cea819da 群戳一戳增加原始信息
群消息log增加视频解析
2024-07-20 14:51:50 +08:00
汉广
9ab7f60544 fix[group]handle_request reason empty 2024-07-20 14:16:07 +08:00
手瓜一十雪
aaf7191bf3 build: 1.6.7-beta03 2024-07-20 10:45:26 +08:00
手瓜一十雪
628c9be0c8 feat: 2401 for 群精华设置 2024-07-20 10:44:57 +08:00
手瓜一十雪
733052720c build: 1.6.6-build02 2024-07-20 10:28:47 +08:00
手瓜一十雪
a10f007194 build: 1.6.7-beta0 2024-07-20 10:21:16 +08:00
手瓜一十雪
6fa50c58d3 feat: 优化接口转换速度 避免频繁读写 2024-07-17 15:03:10 +08:00
29 changed files with 289 additions and 68 deletions

View File

@@ -0,0 +1,25 @@
# v1.6.7
QQ Version: Windows 9.9.12-26000 / Linux 3.2.9-26000
## 使用前警告
1. 在最近版本由于QQ本体大幅变动为了保证NapCat可用性NapCat近期启动与安装方式将将大幅变动请关注文档和社群获取。
2. 在Core上完全执行开源请不要用于违法用途如此可能造成NapCat完全停止更新。
3. 针对原启动方式的围堵NapCat研发了多种方式除此其余理论与扩展的分析和思路将部分展示于Docs以便各位参与开发与维护NapCat。
## 其余·备注
启动方式: WayBoot.03 Electron Main进程为Node 直接注入代码 同理项目: LiteLoader
## 修复与优化
1. 尝试 修复 卡顿问题
2. 尝试 修复 精华消息被设置/一起听 接收时的报错
3. 优化 Uin与Uid 转换速度
4. 修复CQCode可能存在的解码问题
## 新增与调整
1. 戳一戳上报raw
2. 精华消息设置通知事件
3. 新增设置/删除群精华API
4. 新增最近联系列表APIRAW 不稳定)
5. 新增设置所有消息已读API非标准
6. 新增获取点赞信息获取API非标准
新增的 API 详细见[API文档](https://napneko.github.io/zh-CN/develop/extends_api)

View File

@@ -1,4 +1,4 @@
# v1.6.5
# v1.6.6
QQ Version: Windows 9.9.12-26000 / Linux 3.2.9-26000
## 使用前警告

View File

@@ -2,7 +2,7 @@
"name": "napcat",
"private": true,
"type": "module",
"version": "1.6.6",
"version": "1.6.7",
"scripts": {
"watch:dev": "vite --mode development",
"watch:prod": "vite --mode production",

View File

@@ -89,7 +89,36 @@ export function CacheClassFuncAsync(ttl: number = 3600 * 1000, customKey: string
}
return logExecutionTime;
}
export function CacheClassFuncAsyncExtend(ttl: number = 3600 * 1000, customKey: string = '', checker: any = (...data: any[]) => { return true; }) {
//console.log('CacheClassFuncAsync', ttl, customKey);
function logExecutionTime(target: any, methodName: string, descriptor: PropertyDescriptor) {
//console.log('logExecutionTime', target, methodName, descriptor);
const cache = new Map<string, { expiry: number; value: any }>();
const originalMethod = descriptor.value;
descriptor.value = async function (...args: any[]) {
const key = `${customKey}${String(methodName)}.(${args.map(arg => JSON.stringify(arg)).join(', ')})`;
cache.forEach((value, key) => {
if (value.expiry < Date.now()) {
cache.delete(key);
}
});
const cachedValue = cache.get(key);
if (cachedValue && cachedValue.expiry > Date.now()) {
return cachedValue.value;
}
// const start = Date.now();
const result = await originalMethod.apply(this, args);
if (!checker(...args, result)) {
return result;//丢弃缓存
}
// const end = Date.now();
// console.log(`Method ${methodName} executed in ${end - start} ms.`);
cache.set(key, { expiry: Date.now() + ttl, value: result });
return result;
};
}
return logExecutionTime;
}
// export function CacheClassFuncAsync(ttl: number = 3600 * 1000, customKey: string = ''): any {
// const cache = new Map<string, { expiry: number; value: any }>();

View File

@@ -125,7 +125,7 @@ export class NTQQGroupApi {
'seq': seq, // 通知序列号
'type': type,
'groupCode': groupCode,
'postscript': reason || ''
'postscript': reason || ' ' // 仅传空值可能导致处理失败,故默认给个空格
}
});
}

View File

@@ -228,4 +228,7 @@ export class NTQQMsgApi {
}
);
}
static async markallMsgAsRead() {
return napCatCore.session.getMsgService().setAllC2CAndGroupMsgRead();
}
}

View File

@@ -1,12 +1,12 @@
import { ModifyProfileParams, SelfInfo, User, UserDetailInfoByUin } from '@/core/entities';
import { friends, selfInfo } from '@/core/data';
import { CacheClassFuncAsync } from '@/common/utils/helper';
import { CacheClassFuncAsync, CacheClassFuncAsyncExtend } from '@/common/utils/helper';
import { GeneralCallResult, napCatCore, NTQQFriendApi } from '@/core';
import { ProfileListener } from '@/core/listeners';
import { rejects } from 'assert';
import { randomUUID } from 'crypto';
import { RequestUtil } from '@/common/utils/request';
import { logDebug, logError } from '@/common/utils/log';
import { log, logDebug, logError, logWarn } from '@/common/utils/log';
import { NTEventDispatch } from '@/common/utils/EventTask';
const userInfoCache: Record<string, User> = {}; // uid: User
@@ -35,6 +35,20 @@ setTimeout(() => {
// }
// };
export class NTQQUserApi {
static async getProfileLike(uid: string) {
return napCatCore.session.getProfileLikeService().getBuddyProfileLike({
"friendUids": [
uid
],
"basic": 1,
"vote": 1,
"favorite": 0,
"userProfile": 1,
"type": 2,
"start": 0,
"limit": 20
});
}
static async setLongNick(longNick: string) {
return napCatCore.session.getProfileService().setLongNick(longNick);
}
@@ -163,6 +177,13 @@ export class NTQQUserApi {
}
return skey;
}
@CacheClassFuncAsyncExtend(3600, 'Uin2Uid', (Uin: string, Uid: string | undefined) => {
if (Uid && Uid.indexOf('u_') != -1) {
return true
}
logWarn("uin转换到uid时异常", Uin);
return false;
})
static async getUidByUin(Uin: string) {
let ret = await NTEventDispatch.CallNoListenerEvent
<(Uin: string[]) => Promise<{ uidInfo: Map<string, string> }>>(
@@ -181,6 +202,7 @@ export class NTQQUserApi {
});
//uid = Array.from(friends.values()).find((t) => { t.uin == Uin })?.uid; // 从NC维护的QQ Buddy缓存 转换
}
// if (!uid) {
// uid = (await NTQQFriendApi.getFriends(false)).find((t) => { t.uin == Uin })?.uid; //从QQ Native 缓存转换 方法一
// }
@@ -195,6 +217,13 @@ export class NTQQUserApi {
}
return uid;
}
@CacheClassFuncAsyncExtend(3600, 'Uid2Uin', (Uid: string | undefined, Uin: number | undefined) => {
if (Uin && Uin != 0 && !isNaN(Uin)) {
return true
}
logWarn("uid转换到uin时异常", Uid);
return false;
})
static async getUinByUid(Uid: string | undefined) {
if (!Uid) {
return '';
@@ -217,7 +246,7 @@ export class NTQQUserApi {
if (!uin) {
uin = (await NTQQUserApi.getUserDetailInfo(Uid)).uin; //从QQ Native 转换
}
// if (!uin) {
// uin = (await NTQQFriendApi.getFriends(false)).find((t) => { t.uid == Uid })?.uin; //从QQ Native 缓存转换
// }
@@ -226,6 +255,9 @@ export class NTQQUserApi {
// }
return uin;
}
static async getRecentContactList() {
return await napCatCore.session.getRecentContactService().getRecentContactList();
}
static async getUserDetailInfoByUin(Uin: string) {
return NTEventDispatch.CallNoListenerEvent
<(Uin: string) => Promise<UserDetailInfoByUin>>(

View File

@@ -253,7 +253,7 @@ export interface NodeIKernelMsgService {
pageLimit: number,
isReverseOrder: boolean,
isIncludeCurrent: boolean
}):Promise<unknown>;
}): Promise<unknown>;
queryPicOrVideoMsgsDesktop(...args: unknown[]): unknown;
@@ -299,7 +299,7 @@ export interface NodeIKernelMsgService {
setMsgRead(peer: Peer): Promise<GeneralCallResult>;
setAllC2CAndGroupMsgRead(...args: unknown[]): unknown;
setAllC2CAndGroupMsgRead(): Promise<unknown>;
setGuildMsgRead(...args: unknown[]): unknown;
@@ -355,8 +355,8 @@ export interface NodeIKernelMsgService {
getFileThumbSavePathForSend(...args: unknown[]): unknown;
getFileThumbSavePath(...args: unknown[]): unknown;
translatePtt2Text(...args: unknown[]): unknown;
//猜测居多
translatePtt2Text(MsgId: string, Peer: {}, MsgElement: {}): unknown;
setPttPlayedState(...args: unknown[]): unknown;
@@ -406,7 +406,7 @@ export interface NodeIKernelMsgService {
getEmojiResourcePath(...args: unknown[]): unknown;
JoinDragonGroupEmoji(...args: unknown[]): unknown;
JoinDragonGroupEmoji(JoinDragonGroupEmojiReq: any/*joinDragonGroupEmojiReq*/): unknown;
getMsgAbstracts(...args: unknown[]): unknown;

View File

@@ -1,4 +1,5 @@
import { BuddyProfileLikeReq } from "../entities/user";
import { GeneralCallResult } from "./common";
export interface NodeIKernelProfileLikeService {
addKernelProfileLikeListener(listener: NodeIKernelProfileLikeService): void;
@@ -7,7 +8,13 @@ export interface NodeIKernelProfileLikeService {
setBuddyProfileLike(...args: unknown[]): { result: number, errMsg: string, succCounts: number };
getBuddyProfileLike(req: BuddyProfileLikeReq): void;
getBuddyProfileLike(req: BuddyProfileLikeReq): Promise<GeneralCallResult & {
"info": {
"userLikeInfos": Array<any>,
"friendMaxVotes": number,
"start": number
}
}>;
getProfileLikeScidResourceInfo(...args: unknown[]): void;

View File

@@ -43,7 +43,7 @@ export interface NodeIKernelRecentContactService {
deleteRecentContactsVer2(...args: unknown[]): unknown; // 1 arguments
getRecentContactList(): unknown;
getRecentContactList(): Promise<any>;
getMsgUnreadCount(): unknown;

View File

@@ -30,5 +30,6 @@ export interface NodeIKernelRobotService {
setRobotPickTts(arg1: unknown, arg2: unknown): unknown;
getRobotUinRange(data: any): Promise<{ response: { robotUinRanges: any } }>
isNull(): boolean;
}
}

View File

@@ -39,6 +39,7 @@ import { NodeIKernelTianShuService } from './services/NodeIKernelTianShuService'
import { NodeIKernelUnitedConfigService } from './services/NodeIKernelUnitedConfigService';
import { NodeIKernelSearchService } from './services/NodeIKernelSearchService';
import { NodeIKernelCollectionService } from './services/NodeIKernelCollectionService';
import { NodeIKernelRecentContactService } from './services/NodeIKernelRecentContactService';
const __filename = fileURLToPath(import.meta.url);
@@ -236,7 +237,7 @@ export interface NodeIQQNTWrapperSession {
getAVSDKService(): unknown;
getRecentContactService(): unknown;
getRecentContactService(): NodeIKernelRecentContactService;
getConfigMgrService(): unknown;
}

View File

@@ -0,0 +1,16 @@
import { selfInfo } from '@/core/data';
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
import { NTQQUserApi } from '@/core/apis';
export class GetProfileLike extends BaseAction<void, any> {
actionName = ActionName.GetProfileLike;
protected async _handle(payload: void) {
let ret = await NTQQUserApi.getProfileLike(selfInfo.uid);
let listdata: any[] = ret.info.userLikeInfos[0].favoriteInfo.userInfos;
for (let i = 0; i < listdata.length; i++) {
listdata[i].uin = parseInt((await NTQQUserApi.getUinByUid(listdata[i].uid)) || '');
}
return listdata;
}
}

View File

@@ -0,0 +1,31 @@
import { dbUtil } from '@/common/utils/db';
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import { NTQQGroupApi } from '@/core';
const SchemaData = {
type: 'object',
properties: {
message_id: { type: ['number', 'string'] }
},
required: ['message_id']
} as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>;
export default class DelEssenceMsg extends BaseAction<Payload, any> {
actionName = ActionName.DelEssenceMsg;
PayloadSchema = SchemaData;
protected async _handle(payload: Payload): Promise<any> {
const msg = await dbUtil.getMsgByShortId(parseInt(payload.message_id.toString()));
if (!msg) {
throw new Error('msg not found');
}
return await NTQQGroupApi.removeGroupEssence(
msg.peerUin,
msg.msgId
);
}
}

View File

@@ -0,0 +1,30 @@
import { dbUtil } from '@/common/utils/db';
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import { NTQQGroupApi, NTQQMsgApi } from '@/core';
const SchemaData = {
type: 'object',
properties: {
message_id: { type: ['number', 'string'] }
},
required: ['message_id']
} as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>;
export default class SetEssenceMsg extends BaseAction<Payload, any> {
actionName = ActionName.SetEssenceMsg;
PayloadSchema = SchemaData;
protected async _handle(payload: Payload): Promise<any> {
const msg = await dbUtil.getMsgByShortId(parseInt(payload.message_id.toString()));
if (!msg) {
throw new Error('msg not found');
}
return await NTQQGroupApi.addGroupEssence(
msg.peerUin,
msg.msgId
);
}
}

View File

@@ -9,7 +9,7 @@ const SchemaData = {
properties: {
flag: { type: 'string' },
approve: { type: ['string', 'boolean'] },
reason: { type: 'string' }
reason: { type: 'string', nullable: true, }
},
required: ['flag'],
} as const satisfies JSONSchema;

View File

@@ -34,7 +34,7 @@ import SetGroupAdmin from './group/SetGroupAdmin';
import SetGroupCard from './group/SetGroupCard';
import GetImage from './file/GetImage';
import GetRecord from './file/GetRecord';
import { GoCQHTTPMarkMsgAsRead, MarkGroupMsgAsRead, MarkPrivateMsgAsRead } from './msg/MarkMsgAsRead';
import { GoCQHTTPMarkMsgAsRead, MarkAllMsgAsRead, MarkGroupMsgAsRead, MarkPrivateMsgAsRead } from './msg/MarkMsgAsRead';
import CleanCache from './system/CleanCache';
import GoCQHTTPUploadGroupFile from './go-cqhttp/UploadGroupFile';
import { GetConfigAction, SetConfigAction } from '@/onebot11/action/extends/Config';
@@ -70,6 +70,10 @@ import { SetSelfProfile } from './extends/SetSelfProfile';
import { shareGroupEx, sharePeer } from './extends/sharePeer';
import { CreateCollection } from './extends/CreateCollection';
import { SetLongNick } from './extends/SetLongNick';
import DelEssenceMsg from './group/DelEssenceMsg';
import SetEssenceMsg from './group/SetEssenceMsg';
import GetRecentContact from './user/GetRecentContact';
import { GetProfileLike } from './extends/GetProfileLike';
export const actionHandlers = [
new RebootNormal(),
@@ -147,7 +151,12 @@ export const actionHandlers = [
new GoCQHTTPGetForwardMsgAction(),
new GetFriendMsgHistory(),
new GoCQHTTPHandleQuickAction(),
new GetGroupSystemMsg()
new GetGroupSystemMsg(),
new DelEssenceMsg(),
new SetEssenceMsg(),
new GetRecentContact(),
new MarkAllMsgAsRead(),
new GetProfileLike()
];
function initActionMap() {

View File

@@ -60,3 +60,12 @@ export class GoCQHTTPMarkMsgAsRead extends BaseAction<Payload, null> {
return null;
}
}
export class MarkAllMsgAsRead extends BaseAction<Payload, null> {
actionName = ActionName._MarkAllMsgAsRead;
protected async _handle(payload: Payload): Promise<null> {
await NTQQMsgApi.markallMsgAsRead();
return null;
}
}

View File

@@ -93,5 +93,10 @@ export enum ActionName {
SetSelfProfile = 'set_self_profile',
CreateCollection = 'create_collection',
GetCollectionList = 'get_collection_list',
SetLongNick = 'set_self_longnick'
SetLongNick = 'set_self_longnick',
SetEssenceMsg = "set_essence_msg",
DelEssenceMsg = "delete_essence_msg",
GetRecentContact = "get_recent_contact",
_MarkAllMsgAsRead = "_mark_all_as_read",
GetProfileLike = "get_profile_like"
}

View File

@@ -0,0 +1,11 @@
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
import { NTQQUserApi } from '@/core';
export default class GetRecentContact extends BaseAction<void, any> {
actionName = ActionName.GetRecentContact;
protected async _handle(payload: void) {
return await NTQQUserApi.getRecentContactList()
}
}

View File

@@ -18,6 +18,7 @@ import {
Group,
GroupMember,
IMAGE_HTTP_HOST, IMAGE_HTTP_HOST_NT, mFaceCache,
Peer,
RawMessage,
SelfInfo,
Sex,
@@ -45,6 +46,7 @@ import { OB11GroupMsgEmojiLikeEvent } from '@/onebot11/event/notice/OB11MsgEmoji
import { napCatCore } from '@/core';
import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11PokeEvent';
import { OB11BaseNoticeEvent } from './event/notice/OB11BaseNoticeEvent';
import { OB11GroupEssenceEvent } from './event/notice/OB11GroupEssenceEvent';
export class OB11Constructor {
@@ -312,10 +314,10 @@ export class OB11Constructor {
}
}
static async GroupEvent(msg: RawMessage): Promise<OB11GroupNoticeEvent | undefined> {
//log("group msg", msg);
if (msg.chatType !== ChatType.group) {
return;
}
//log("group msg", msg);
if (msg.senderUin && msg.senderUin !== '0') {
const member = await getGroupMember(msg.peerUid, msg.senderUin);
if (member && member.cardName !== msg.sendMemberName) {
@@ -325,6 +327,7 @@ export class OB11Constructor {
return event;
}
}
for (const element of msg.elements) {
const grayTipElement = element.grayTipElement;
const groupElement = grayTipElement?.groupElement;
@@ -396,14 +399,6 @@ export class OB11Constructor {
}
if (grayTipElement) {
if (grayTipElement.xmlElement?.templId === '10382') {
// 表情回应消息
// "content":
// "<gtip align=\"center\">
// <qq uin=\"u_snYxnEfja-Po_\" col=\"3\" jp=\"3794\"/>
// <nor txt=\"回应了你的\"/>
// <url jp= \"\" msgseq=\"74711\" col=\"3\" txt=\"消息:\"/>
// <face type=\"1\" id=\"76\"> </face>
// </gtip>",
const emojiLikeData = new fastXmlParser.XMLParser({
ignoreAttributes: false,
attributeNamePrefix: ''
@@ -447,46 +442,37 @@ export class OB11Constructor {
//代码歧义 GrayTipElementSubType.MEMBER_NEW_TITLE
else if (grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE) {
const json = JSON.parse(grayTipElement.jsonGrayTipElement.jsonStr);
/*
{
align: 'center',
items: [
{ txt: '恭喜', type: 'nor' },
{
col: '3',
jp: '5',
param: ["QQ号"],
txt: '林雨辰',
type: 'url'
},
{ txt: '获得群主授予的', type: 'nor' },
{
col: '3',
jp: '',
txt: '好好好',
type: 'url'
},
{ txt: '头衔', type: 'nor' }
]
}
* */
if (grayTipElement.jsonGrayTipElement.busiId == 1061) {
//判断业务类型
//Poke事件
let pokedetail: any[] = json.items;
const pokedetail: any[] = json.items;
//筛选item带有uid的元素
pokedetail = pokedetail.filter(item => item.uid);
//console.log("[NapCat] 群拍一拍 群:", pokedetail, parseInt(msg.peerUid), " ", await NTQQUserApi.getUinByUid(pokedetail[0].uid), "拍了拍", await NTQQUserApi.getUinByUid(pokedetail[1].uid));
if (pokedetail.length == 2) {
return new OB11GroupPokeEvent(parseInt(msg.peerUid), parseInt((await NTQQUserApi.getUinByUid(pokedetail[0].uid))!), parseInt((await NTQQUserApi.getUinByUid(pokedetail[1].uid))!));
const poke_uid = pokedetail.filter(item => item.uid);
if (poke_uid.length == 2) {
return new OB11GroupPokeEvent(parseInt(msg.peerUid), parseInt((await NTQQUserApi.getUinByUid(poke_uid[0].uid))!), parseInt((await NTQQUserApi.getUinByUid(poke_uid[1].uid))!), pokedetail);
}
}
//下面得改 上面也是错的grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE
const memberUin = json.items[1].param[0];
const title = json.items[3].txt;
logDebug('收到群成员新头衔消息', json);
return new OB11GroupTitleEvent(parseInt(msg.peerUid), parseInt(memberUin), title);
if (grayTipElement.jsonGrayTipElement.busiId == 2401) {
let searchParams = new URL(json.items[0].jp).searchParams;
let msgSeq = searchParams.get('msgSeq')!;
let Group = searchParams.get('groupCode');
let Businessid = searchParams.get('businessid');
let Peer: Peer = {
guildId: '',
chatType: ChatType.group,
peerUid: Group!
};
let msgData = await NTQQMsgApi.getMsgsBySeqAndCount(Peer, msgSeq.toString(), 1, true, true);
return new OB11GroupEssenceEvent(parseInt(msg.peerUid), await dbUtil.addMsg(msgData.msgList[0]), parseInt(msgData.msgList[0].senderUin));
// 获取MsgSeq+Peer可获取具体消息
}
if (grayTipElement.jsonGrayTipElement.busiId == 2407) {
//下面得改 上面也是错的grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE
const memberUin = json.items[1].param[0];
const title = json.items[3].txt;
logDebug('收到群成员新头衔消息', json);
return new OB11GroupTitleEvent(parseInt(msg.peerUid), parseInt(memberUin), title);
}
}
}
}

View File

@@ -67,6 +67,14 @@ export function encodeCQCode(data: OB11MessageData) {
let result = '[CQ:' + data.type;
for (const name in data.data) {
const value = data.data[name];
try {
// Check if the value can be converted to a string
value.toString();
} catch (error) {
// If it can't be converted, skip this name-value pair
// console.warn(`Skipping problematic name-value pair. Name: ${name}, Value: ${value}`);
continue;
}
result += `,${name}=${CQCodeEscape(value)}`;
}
result += ']';

View File

@@ -0,0 +1,14 @@
import { OB11GroupNoticeEvent } from './OB11GroupNoticeEvent';
export class OB11GroupEssenceEvent extends OB11GroupNoticeEvent {
notice_type = 'essence';
message_id: number;
sender_id: number;
sub_type: 'add' | 'delete' = "add";
constructor(groupId: number, message_id: number, sender_id: number) {
super();
this.group_id = groupId;
this.message_id = message_id;
this.sender_id = sender_id;
}
}

View File

@@ -19,11 +19,13 @@ export class OB11FriendPokeEvent extends OB11PokeEvent {
export class OB11GroupPokeEvent extends OB11PokeEvent {
group_id: number;
raw_message: any;
constructor(group_id: number, user_id: number = 0, target_id: number = 0,) {
constructor(group_id: number, user_id: number = 0, target_id: number = 0, raw_message: any) {
super();
this.group_id = group_id;
this.target_id = target_id;
this.user_id = user_id;
this.raw_message = raw_message;
}
}

View File

@@ -63,6 +63,9 @@ export async function logMessage(ob11Message: OB11Message) {
else if (segment.type === 'markdown') {
msgParts.push(spSegColor(`[markdown|${segment.data.content}]`));
}
else if (segment.type === 'video') {
msgParts.push(spSegColor(`[视频|${segment.data.url}]`));
}
else {
msgParts.push(spSegColor(`[未实现|${JSON.stringify(segment)}]`));
}

View File

@@ -331,7 +331,6 @@ export class NapCatOnebot11 {
postOB11Event(msg);
// log("post msg", msg)
}).catch(e => logError('constructMessage error: ', e));
OB11Constructor.GroupEvent(message).then(groupEvent => {
if (groupEvent) {
// log("post group event", groupEvent);

View File

@@ -1 +1 @@
export const version = '1.6.6';
export const version = '1.6.7';

View File

@@ -29,7 +29,7 @@ async function onSettingWindowCreated(view: Element) {
SettingItem(
'<span id="napcat-update-title">Napcat</span>',
undefined,
SettingButton('V1.6.6', 'napcat-update-button', 'secondary')
SettingButton('V1.6.7', 'napcat-update-button', 'secondary')
),
]),
SettingList([

View File

@@ -167,7 +167,7 @@ async function onSettingWindowCreated(view) {
SettingItem(
'<span id="napcat-update-title">Napcat</span>',
void 0,
SettingButton("V1.6.6", "napcat-update-button", "secondary")
SettingButton("V1.6.7", "napcat-update-button", "secondary")
)
]),
SettingList([