mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
feat: send file api add name field
This commit is contained in:
@@ -81,19 +81,19 @@ export class SendMsgElementConstructor {
|
||||
};
|
||||
}
|
||||
|
||||
static async file(filePath: string, isVideo: boolean = false): Promise<SendFileElement> {
|
||||
static async file(filePath: string, showPreview: boolean = false, fileName: string = ""): Promise<SendFileElement> {
|
||||
let picHeight = 0;
|
||||
let picWidth = 0;
|
||||
if (isVideo) {
|
||||
if (showPreview) {
|
||||
picHeight = 1024;
|
||||
picWidth = 768;
|
||||
}
|
||||
const {md5, fileName, path, fileSize} = await NTQQApi.uploadFile(filePath, ElementType.FILE);
|
||||
const {md5, fileName: _fileName, path, fileSize} = await NTQQApi.uploadFile(filePath, ElementType.FILE);
|
||||
let element: SendFileElement = {
|
||||
elementType: ElementType.FILE,
|
||||
elementId: "",
|
||||
fileElement: {
|
||||
fileName,
|
||||
fileName: fileName || _fileName,
|
||||
"filePath": path,
|
||||
"fileSize": (fileSize).toString(),
|
||||
picHeight,
|
||||
|
@@ -455,20 +455,19 @@ export class NTQQApi {
|
||||
if (waitComplete) {
|
||||
if ((await dbUtil.getMsgByLongId(sentMessage.msgId)).sendStatus == 2) {
|
||||
return sentMessage
|
||||
} else {
|
||||
return await checkSendComplete()
|
||||
}
|
||||
}
|
||||
// log(`给${peerUid}发送消息成功`)
|
||||
return sentMessage
|
||||
} else {
|
||||
checkSendCompleteUsingTime += 500
|
||||
if (checkSendCompleteUsingTime > timeout) {
|
||||
throw ('发送超时')
|
||||
else{
|
||||
return sentMessage
|
||||
}
|
||||
await sleep(500)
|
||||
return await checkSendComplete()
|
||||
// log(`给${peerUid}发送消息成功`)
|
||||
}
|
||||
checkSendCompleteUsingTime += 500
|
||||
if (checkSendCompleteUsingTime > timeout) {
|
||||
throw ('发送超时')
|
||||
}
|
||||
await sleep(500)
|
||||
return await checkSendComplete()
|
||||
}
|
||||
|
||||
callNTQQApi({
|
||||
|
Reference in New Issue
Block a user