mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
refactor
This commit is contained in:
@@ -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('不存在任何文件, 无法下载')
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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 {
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user