From c313fcd4915d1ee947bb885eb5279050231f6c28 Mon Sep 17 00:00:00 2001
From: linyuchen <lin.yu.chen@foxmail.com>
Date: Sat, 16 Mar 2024 12:34:00 +0800
Subject: [PATCH] refactor: output log ignore ntqq logger event

---
 manifest.json               |  4 ++--
 src/common/config.ts        |  2 +-
 src/ntqqapi/hook.ts         | 18 +++++++++++++++---
 src/onebot11/constructor.ts |  2 +-
 src/version.ts              |  2 +-
 5 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/manifest.json b/manifest.json
index 31edae9..51f84c8 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,10 +1,10 @@
 {
   "manifest_version": 4,
   "type": "extension",
-  "name": "LLOneBot v3.15.1",
+  "name": "LLOneBot v3.15.2",
   "slug": "LLOneBot",
   "description": "LiteLoaderQQNT的OneBotApi,不支持商店在线更新",
-  "version": "3.15.1",
+  "version": "3.15.2",
   "icon": "./icon.jpg",
   "authors": [
     {
diff --git a/src/common/config.ts b/src/common/config.ts
index 397c77c..5a7a964 100644
--- a/src/common/config.ts
+++ b/src/common/config.ts
@@ -2,7 +2,7 @@ import fs from "fs";
 import {Config, OB11Config} from './types';
 import {mergeNewProperties} from "./utils";
 
-export const HOOK_LOG = false;
+export const HOOK_LOG = true;
 
 export const ALLOW_SEND_TEMP_MSG = false;
 
diff --git a/src/ntqqapi/hook.ts b/src/ntqqapi/hook.ts
index c50f6d7..3ab62b1 100644
--- a/src/ntqqapi/hook.ts
+++ b/src/ntqqapi/hook.ts
@@ -54,7 +54,13 @@ let receiveHooks: Array<{
 export function hookNTQQApiReceive(window: BrowserWindow) {
     const originalSend = window.webContents.send;
     const patchSend = (channel: string, ...args: NTQQApiReturnData) => {
-        HOOK_LOG && log(`received ntqq api message: ${channel}`, JSON.stringify(args))
+        try {
+            if (!args[0]?.eventName?.startsWith("ns-LoggerApi")) {
+                HOOK_LOG && log(`received ntqq api message: ${channel}`, JSON.stringify(args))
+            }
+        } catch (e) {
+
+        }
         if (args?.[1] instanceof Array) {
             for (let receiveData of args?.[1]) {
                 const ntQQApiMethodName = receiveData.cmdName;
@@ -98,7 +104,13 @@ export function hookNTQQApiCall(window: BrowserWindow) {
 
     const proxyIpcMsg = new Proxy(ipc_message_proxy, {
         apply(target, thisArg, args) {
-            HOOK_LOG && log("call NTQQ api", thisArg, args);
+            try {
+                if (args[3][1][0] !== "info") {
+                    HOOK_LOG && log("call NTQQ api", thisArg, args);
+                }
+            } catch (e) {
+
+            }
             return target.apply(thisArg, args);
         },
     });
@@ -241,7 +253,7 @@ registerReceiveHook<{ msgList: Array<RawMessage> }>(ReceiveCmd.NEW_MSG, (payload
                     pathList.push(...Object.values(msgElement.picElement.thumbPath))
                 }
                 const aioOpGrayTipElement = msgElement.grayTipElement?.aioOpGrayTipElement
-                if (aioOpGrayTipElement){
+                if (aioOpGrayTipElement) {
                     tempGroupCodeMap[aioOpGrayTipElement.peerUid] = aioOpGrayTipElement.fromGrpCodeOfTmpChat;
                 }
 
diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts
index c13cc66..d55c5ce 100644
--- a/src/onebot11/constructor.ts
+++ b/src/onebot11/constructor.ts
@@ -270,7 +270,7 @@ export class OB11Constructor {
                 }
             }
             else if (element.fileElement){
-                return new OB11GroupUploadNoticeEvent(parseInt(msg.peerUid), parseInt(msg.senderUin), {id: element.fileElement.fileName, name: element.fileElement.fileName, size: parseInt(element.fileElement.fileSize)})
+                return new OB11GroupUploadNoticeEvent(parseInt(msg.peerUid), parseInt(msg.senderUin), {id: element.fileElement.fileUuid, name: element.fileElement.fileName, size: parseInt(element.fileElement.fileSize)})
             }
 
             if (grayTipElement) {
diff --git a/src/version.ts b/src/version.ts
index 2e68519..fe899f1 100644
--- a/src/version.ts
+++ b/src/version.ts
@@ -1 +1 @@
-export const version = "3.15.1"
\ No newline at end of file
+export const version = "3.15.2"
\ No newline at end of file