From e6d36dc6c39503fe76aa213b66577e6f00b16055 Mon Sep 17 00:00:00 2001
From: linyuchen <lin.yu.chen@foxmail.com>
Date: Wed, 6 Mar 2024 21:14:13 +0800
Subject: [PATCH] fix: send video filename fix: send msg don't return
 message_id on Linux

---
 src/ntqqapi/constructor.ts     | 4 ++--
 src/onebot11/action/SendMsg.ts | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/ntqqapi/constructor.ts b/src/ntqqapi/constructor.ts
index a9dfc6c..9187f59 100644
--- a/src/ntqqapi/constructor.ts
+++ b/src/ntqqapi/constructor.ts
@@ -104,8 +104,8 @@ export class SendMsgElementConstructor {
         return element;
     }
 
-    static video(filePath: string): Promise<SendFileElement> {
-        return SendMsgElementConstructor.file(filePath, true);
+    static video(filePath: string, fileName: string=""): Promise<SendFileElement> {
+        return SendMsgElementConstructor.file(filePath, true, fileName);
     }
 
     static async ptt(pttPath: string): Promise<SendPttElement> {
diff --git a/src/onebot11/action/SendMsg.ts b/src/onebot11/action/SendMsg.ts
index 7eb98fc..1bcb34c 100644
--- a/src/onebot11/action/SendMsg.ts
+++ b/src/onebot11/action/SendMsg.ts
@@ -133,6 +133,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
             const returnMsg = await this.send(peer, sendElements, deleteAfterSentFiles)
             return {message_id: returnMsg.msgShortId}
         } catch (e) {
+            log("发送消息失败", e.stack.toString())
             throw (e.toString())
         }
     }
@@ -313,6 +314,9 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
                             if (sendMsg.type === OB11MessageDataType.file) {
                                 log("发送文件", path, payloadFileName || fileName)
                                 sendElements.push(await SendMsgElementConstructor.file(path, false, payloadFileName || fileName));
+                            } else if (sendMsg.type === OB11MessageDataType.video) {
+                                log("发送视频", path, payloadFileName || fileName)
+                                sendElements.push(await SendMsgElementConstructor.video(path, payloadFileName || fileName));
                             } else {
                                 sendElements.push(await constructorMap[sendMsg.type](path));
                             }
@@ -336,7 +340,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
         }
         const returnMsg = await NTQQApi.sendMsg(peer, sendElements, waitComplete, 20000);
         log("消息发送结果", returnMsg)
-        await dbUtil.addMsg(returnMsg)
+        returnMsg.msgShortId = await dbUtil.addMsg(returnMsg)
         deleteAfterSentFiles.map(f => fs.unlink(f, () => {
         }))
         return returnMsg