feat: QuickHandle From LLOB

This commit is contained in:
手瓜一十雪
2024-05-18 14:35:24 +08:00
parent ec3ec8a1d9
commit 159f4ee28b
4 changed files with 92 additions and 79 deletions

View File

@@ -0,0 +1,17 @@
import { log } from '@/common/utils/log';
import BaseAction from '../BaseAction'
import { ActionName } from '../types'
import { QuickAction, QuickActionEvent, handleQuickOperation } from '@/onebot11/server/postOB11Event';
interface Payload{
context: QuickActionEvent,
operation: QuickAction
}
export class GoCQHTTHandleQuickOperation extends BaseAction<Payload, null>{
actionName = ActionName.GoCQHTTP_HandleQuickOperation
protected async _handle(payload: Payload): Promise<null> {
handleQuickOperation(payload.context, payload.operation).then().catch(log);
return null
}
}

View File

@@ -42,13 +42,13 @@ export async function sendMsg(peer: Peer, sendElements: SendMessageElement[], de
try {
for (const fileElement of sendElements) {
if (fileElement.elementType === ElementType.PTT) {
totalSize += fs.statSync(fileElement.pttElement.filePath).size
totalSize += fs.statSync(fileElement.pttElement.filePath).size;
}
if (fileElement.elementType === ElementType.FILE) {
totalSize += fs.statSync(fileElement.fileElement.filePath).size
totalSize += fs.statSync(fileElement.fileElement.filePath).size;
}
if (fileElement.elementType === ElementType.VIDEO) {
totalSize += fs.statSync(fileElement.videoElement.filePath).size
totalSize += fs.statSync(fileElement.videoElement.filePath).size;
}
if (fileElement.elementType === ElementType.PIC) {
totalSize += fs.statSync(fileElement.picElement.sourcePath).size
@@ -57,7 +57,7 @@ export async function sendMsg(peer: Peer, sendElements: SendMessageElement[], de
//且 PredictTime ((totalSize / 1024 / 512) * 1000)不等于Nan
let PredictTime = totalSize / 1024 / 512 * 1000;
if (!Number.isNaN(PredictTime)) {
timeout += PredictTime// 10S Basic Timeout + PredictTime( For File 512kb/s )
timeout += PredictTime// 5S Basic Timeout + PredictTime( For File 512kb/s )
}
} catch (e) {
logError("发送消息计算预计时间异常", e);

View File

@@ -60,6 +60,7 @@ export enum ActionName {
CleanCache = 'clean_cache',
GetCookies = 'get_cookies',
// 以下为go-cqhttp api
GoCQHTTP_HandleQuickOperation = ".handle_quick_operation",
GetGroupHonorInfo = 'get_group_honor_info',
GoCQHTTP_GetEssenceMsg = 'get_essence_msg_list',
GoCQHTTP_SendGroupNotice = '_send_group_notice',