This commit is contained in:
idranme
2024-08-28 06:49:46 +08:00
parent 5501980ab3
commit 7cb94cb8b8
33 changed files with 382 additions and 602 deletions

View File

@@ -1,9 +1,9 @@
import BaseAction from '../BaseAction'
import { ActionName } from '../types'
import fs from 'fs'
import fsPromise from 'fs/promises'
import path from 'node:path'
import { calculateFileMD5, httpDownload } from '@/common/utils'
import { ActionName } from '../types'
import { calculateFileMD5, fetchFile } from '@/common/utils'
import { TEMP_DIR } from '@/common/globalVars'
import { randomUUID } from 'node:crypto'
@@ -31,8 +31,8 @@ export default class GoCQHTTPDownloadFile extends BaseAction<Payload, FileRespon
await fsPromise.writeFile(filePath, payload.base64, 'base64')
} else if (payload.url) {
const headers = this.getHeaders(payload.headers)
const buffer = await httpDownload({ url: payload.url, headers: headers })
await fsPromise.writeFile(filePath, buffer)
const res = await fetchFile(payload.url, headers)
await fsPromise.writeFile(filePath, res.data)
} else {
throw new Error('不存在任何文件, 无法下载')
}

View File

@@ -2,9 +2,9 @@ import BaseAction from '../BaseAction'
import { OB11User } from '../../types'
import { OB11Constructor } from '../../constructor'
import { ActionName } from '../types'
import { getBuildVersion } from '@/common/utils/QQBasicInfo'
import { getBuildVersion } from '@/common/utils'
import { OB11UserSex } from '../../types'
import { calcQQLevel } from '@/common/utils/qqlevel'
import { calcQQLevel } from '@/common/utils/misc'
interface Payload {
user_id: number | string

View File

@@ -1,5 +1,5 @@
import BaseAction from '../BaseAction'
import { handleQuickOperation, QuickOperation, QuickOperationEvent } from '../../helper/quick-operation'
import { handleQuickOperation, QuickOperation, QuickOperationEvent } from '../../helper/quickOperation'
import { ActionName } from '../types'
interface Payload {

View File

@@ -1,6 +1,7 @@
import SendMsg, { convertMessage2List } from '../msg/SendMsg'
import SendMsg from '../msg/SendMsg'
import { OB11PostSendMsg } from '../../types'
import { ActionName } from '../types'
import { convertMessage2List } from '../../helper/createMessage'
export class GoCQHTTPSendForwardMsg extends SendMsg {
actionName = ActionName.GoCQHTTP_SendForwardMsg

View File

@@ -5,7 +5,7 @@ import { SendMsgElementConstructor } from '@/ntqqapi/constructor'
import { ChatType, SendFileElement } from '@/ntqqapi/types'
import { uri2local } from '@/common/utils'
import { Peer } from '@/ntqqapi/types'
import { sendMsg } from '../msg/SendMsg'
import { sendMsg } from '../../helper/createMessage'
interface Payload {
user_id: number | string