From b02cd3af00810dcfdbe5138245bee1dfe90f7e2f Mon Sep 17 00:00:00 2001 From: idranme Date: Fri, 9 Aug 2024 16:46:08 +0800 Subject: [PATCH 1/3] Create .editorconfig --- .editorconfig | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ed7f9e5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +insert_final_newline = true +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true \ No newline at end of file From be1b9c21c1182578dc16edde96f26a3ea1ddde2d Mon Sep 17 00:00:00 2001 From: idranme Date: Fri, 9 Aug 2024 18:02:52 +0800 Subject: [PATCH 2/3] feat: support for `at` message segment specifying `name` --- src/main/main.ts | 7 +------ src/ntqqapi/api/msg.ts | 3 ++- src/ntqqapi/api/user.ts | 10 +++++----- src/ntqqapi/constructor.ts | 4 ++-- src/onebot11/action/msg/SendMsg.ts | 13 ++++++++++--- src/onebot11/constructor.ts | 2 +- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/main/main.ts b/src/main/main.ts index 76ffee8..c4ed253 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -13,13 +13,10 @@ import { CHANNEL_UPDATE, } from '../common/channels' import { ob11WebsocketServer } from '../onebot11/server/ws/WebsocketServer' -import { DATA_DIR, qqPkgInfo } from '../common/utils' +import { DATA_DIR } from '../common/utils' import { friendRequests, - getFriend, - getGroup, getGroupMember, - groups, llonebotError, selfInfo, uidMaps, @@ -27,9 +24,7 @@ import { import { hookNTQQApiCall, hookNTQQApiReceive, ReceiveCmdS, registerReceiveHook, startHook } from '../ntqqapi/hook' import { OB11Constructor } from '../onebot11/constructor' import { - ChatType, FriendRequestNotify, - GroupMemberRole, GroupNotifies, GroupNotifyTypes, RawMessage, diff --git a/src/ntqqapi/api/msg.ts b/src/ntqqapi/api/msg.ts index 615eda5..b35374c 100644 --- a/src/ntqqapi/api/msg.ts +++ b/src/ntqqapi/api/msg.ts @@ -358,8 +358,9 @@ export class NTQQMsgApi { }) }) } + static async getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, z: boolean) { const session = getSession() - return await session?.getMsgService().getMsgsBySeqAndCount(peer, seq, count, desc, z); + return await session?.getMsgService().getMsgsBySeqAndCount(peer, seq, count, desc, z)! } } diff --git a/src/ntqqapi/api/user.ts b/src/ntqqapi/api/user.ts index bd8e9d0..4c2d7fa 100644 --- a/src/ntqqapi/api/user.ts +++ b/src/ntqqapi/api/user.ts @@ -221,7 +221,7 @@ export class NTQQUserApi { static async getUidByUinV1(Uin: string) { const session = getSession() // 通用转换开始尝试 - let uid = (await session?.getUixConvertService().getUid([Uin])!).uidInfo.get(Uin); + let uid = (await session?.getUixConvertService().getUid([Uin]))?.uidInfo.get(Uin) // Uid 好友转 if (!uid) { friends.forEach((t) => { @@ -251,11 +251,11 @@ export class NTQQUserApi { static async getUidByUinV2(Uin: string) { const session = getSession() - let uid = (await session?.getProfileService().getUidByUin('FriendsServiceImpl', [Uin])!).get(Uin) + let uid = (await session?.getProfileService().getUidByUin('FriendsServiceImpl', [Uin]))?.get(Uin) if (uid) return uid - uid = (await session?.getGroupService().getUidByUins([Uin])!).uids.get(Uin) + uid = (await session?.getGroupService().getUidByUins([Uin]))?.uids.get(Uin) if (uid) return uid - uid = (await session?.getUixConvertService().getUid([Uin])!).uidInfo.get(Uin) + uid = (await session?.getUixConvertService().getUid([Uin]))?.uidInfo.get(Uin) if (uid) return uid console.log((await NTQQFriendApi.getBuddyIdMapCache(true))) uid = (await NTQQFriendApi.getBuddyIdMapCache(true)).getValue(Uin)//从Buddy缓存获取Uid @@ -263,7 +263,7 @@ export class NTQQUserApi { uid = (await NTQQFriendApi.getBuddyIdMap(true)).getValue(Uin) if (uid) return uid let unveifyUid = (await NTQQUserApi.getUserDetailInfoByUinV2(Uin)).detail.uid//从QQ Native 特殊转换 - if (unveifyUid.indexOf("*") == -1) uid = unveifyUid + if (unveifyUid.indexOf('*') == -1) uid = unveifyUid //if (uid) return uid return uid } diff --git a/src/ntqqapi/constructor.ts b/src/ntqqapi/constructor.ts index f99f18a..4f1f5f6 100644 --- a/src/ntqqapi/constructor.ts +++ b/src/ntqqapi/constructor.ts @@ -44,12 +44,12 @@ export class SendMsgElementConstructor { } } - static at(atUid: string, atNtUid: string, atType: AtType, atName: string): SendTextElement { + static at(atUid: string, atNtUid: string, atType: AtType, display: string): SendTextElement { return { elementType: ElementType.TEXT, elementId: '', textElement: { - content: `@${atName}`, + content: display, atType, atUid, atTinyId: '', diff --git a/src/onebot11/action/msg/SendMsg.ts b/src/onebot11/action/msg/SendMsg.ts index 85b27cb..2453e45 100644 --- a/src/onebot11/action/msg/SendMsg.ts +++ b/src/onebot11/action/msg/SendMsg.ts @@ -109,15 +109,22 @@ export async function createSendElements( } } if (isAdmin && remainAtAllCount > 0) { - sendElements.push(SendMsgElementConstructor.at(atQQ, atQQ, AtType.atAll, '全体成员')) + sendElements.push(SendMsgElementConstructor.at(atQQ, atQQ, AtType.atAll, '@全体成员')) } } else if (peer.chatType === ChatType.group) { - // const atMember = group?.members.find(m => m.uin == atQQ) const atMember = await getGroupMember(peer.peerUid, atQQ) if (atMember) { + const display = `@${atMember.cardName || atMember.nick}` sendElements.push( - SendMsgElementConstructor.at(atQQ, atMember.uid, AtType.atUser, atMember.cardName || atMember.nick), + SendMsgElementConstructor.at(atQQ, atMember.uid, AtType.atUser, display), + ) + } else { + const atNmae = sendMsg.data?.name + const uid = await NTQQUserApi.getUidByUin(atQQ) || '' + const display = atNmae ? `@${atNmae}` : '' + sendElements.push( + SendMsgElementConstructor.at(atQQ, uid, AtType.atUser, display), ) } } diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts index d45f818..671d97a 100644 --- a/src/onebot11/constructor.ts +++ b/src/onebot11/constructor.ts @@ -554,7 +554,7 @@ export class OB11Constructor { if (msgList[0].senderUin === '0') { msgList[0].senderUin = postMsg?.senderUin ?? selfInfo.uin } - return new OB11GroupEssenceEvent(parseInt(msg.peerUid), postMsg?.msgShortId!, parseInt(msgList[0].senderUin)) + return new OB11GroupEssenceEvent(parseInt(msg.peerUid), postMsg?.msgShortId!, parseInt(msgList[0].senderUin!)) // 获取MsgSeq+Peer可获取具体消息 } if (grayTipElement.jsonGrayTipElement.busiId == 2407) { From 6931277e33239e256a5adfe4249c9b730d3153f7 Mon Sep 17 00:00:00 2001 From: idranme Date: Fri, 9 Aug 2024 18:07:50 +0800 Subject: [PATCH 3/3] chore: v3.28.2 --- manifest.json | 2 +- src/version.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 3ce5014..b27b0ca 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "LLOneBot", "slug": "LLOneBot", "description": "实现 OneBot 11 协议,用以 QQ 机器人开发", - "version": "3.28.1", + "version": "3.28.2", "icon": "./icon.webp", "authors": [ { diff --git a/src/version.ts b/src/version.ts index a706e91..235a755 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const version = '3.28.1' +export const version = '3.28.2'