From 390253242f87fd10361b637bac4f40320c892810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 12 May 2024 15:21:35 +0800 Subject: [PATCH] build: 1.3.5-beta1 --- src/core | 2 +- .../action/go-cqhttp/SendGroupNotice.ts | 33 ++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/core b/src/core index 5d0e5762..cd34fead 160000 --- a/src/core +++ b/src/core @@ -1 +1 @@ -Subproject commit 5d0e5762307ecad70e72da2e924298c09969c703 +Subproject commit cd34feadeb75d6a36c83edb24c4a78ab3ef89520 diff --git a/src/onebot11/action/go-cqhttp/SendGroupNotice.ts b/src/onebot11/action/go-cqhttp/SendGroupNotice.ts index 2e246b09..734bba5d 100644 --- a/src/onebot11/action/go-cqhttp/SendGroupNotice.ts +++ b/src/onebot11/action/go-cqhttp/SendGroupNotice.ts @@ -1,6 +1,7 @@ +import { checkFileReceived, uri2local } from '@/common/utils/file'; import BaseAction from '../BaseAction'; import { ActionName } from '../types'; -import { WebApi } from '@/core/apis'; +import { NTQQGroupApi, WebApi } from '@/core/apis'; interface Payload { group_id: string; content: string; @@ -8,10 +9,34 @@ interface Payload { } export class SendGroupNotice extends BaseAction { actionName = ActionName.GoCQHTTP_SendGroupNotice; - protected async _handle(payload: Payload) { - await WebApi.setGroupNotice(payload.group_id, payload.content); - //返回值验证没做 + let UploadImage: { id: string, width: number, height: number } | undefined = undefined; + if (payload.image) { + //公告图逻辑 + let Image_path, Image_IsLocal, Image_errMsg; + let Uri2LocalRet = (await uri2local(payload.image)); + Image_errMsg = Uri2LocalRet.errMsg; + Image_path = Uri2LocalRet.path; + Image_IsLocal = Uri2LocalRet.isLocal; + if (Image_errMsg) { + throw `群公告${payload.image}设置失败,image字段可能格式不正确`; + } + if (!Image_path) { + throw `群公告${payload.image}设置失败,获取资源失败`; + } + await checkFileReceived(Image_path, 5000); // 文件不存在QQ会崩溃,需要提前判断 + let ImageUploadResult = await NTQQGroupApi.uploadGroupBulletinPic(payload.group_id, Image_path); + if (ImageUploadResult.errCode != 0) { + throw `群公告${payload.image}设置失败,图片上传失败`; + } + UploadImage = ImageUploadResult.picInfo; + } + let PublishGroupBulletinResult = await NTQQGroupApi.publishGroupBulletin(payload.group_id, payload.content, UploadImage); + if(PublishGroupBulletinResult.result ! = 0){ + throw `设置群公告失败,错误信息:${PublishGroupBulletinResult.errMsg}`; + } + // 下面实现扬了 + //await WebApi.setGroupNotice(payload.group_id, payload.content); return null; } }