diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b86ed22..b1dde896 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,4 +12,5 @@ 12. 修复群成员加入时间 上次活跃 活跃等级字段 - 影响 API: /get_group_member_info /get_group_member_list 13. 修复视频所需的 ffmpeg 路径不正确导致视频封面和时长获取失败 - 影响 Event/API 14. 支持音乐卡片,需要配置签名服务器地址, `config/onebot11_.json`的`musicSignUrl`字段 - 新增 Feat: Sign Music -15. 支持获取与设置群公告 - 新增 API: /_send_group_notice /_get_group_notice +15. 支持获取与设置群公告 - 新增 API: (/_send_group_notice 暂时未完全实现) /_get_group_notice + diff --git a/src/core b/src/core index 0252eba3..aa3221a8 160000 --- a/src/core +++ b/src/core @@ -1 +1 @@ -Subproject commit 0252eba3beb5adeac068a8de069f1f82e9cf9b8d +Subproject commit aa3221a8904bf6b66cb85325cda85cbcea5639a0 diff --git a/src/onebot11/action/group/GetGroupNotice.ts b/src/onebot11/action/group/GetGroupNotice.ts index df8d4f7f..a0410881 100644 --- a/src/onebot11/action/group/GetGroupNotice.ts +++ b/src/onebot11/action/group/GetGroupNotice.ts @@ -1,3 +1,4 @@ +import { WebApi, WebApiGroupNoticeRet } from '@/core/apis/webapi'; import BaseAction from '../BaseAction'; import { ActionName } from '../types'; @@ -5,12 +6,15 @@ interface PayloadType { group_id: number } -export class GetGroupNotice extends BaseAction { - actionName = ActionName.GoCQHTTP_GetGroupNotice; +export class GetGroupNotice extends BaseAction { + actionName = ActionName.GoCQHTTP_GetGroupNotice; - protected async _handle(payload: PayloadType) { - const group = payload.group_id.toString(); - // WebApi.getGrouptNotice(group); - return null; - } + protected async _handle(payload: PayloadType) { + const group = payload.group_id.toString(); + let ret = await WebApi.getGrouptNotice(group); + if (!ret) { + throw new Error('获取公告失败'); + } + return ret; + } } \ No newline at end of file diff --git a/src/onebot11/action/group/SetGroupNotice.ts b/src/onebot11/action/group/SetGroupNotice.ts index 5a261090..88eb3fa5 100644 --- a/src/onebot11/action/group/SetGroupNotice.ts +++ b/src/onebot11/action/group/SetGroupNotice.ts @@ -1,3 +1,4 @@ +import { WebApi } from '@/core/apis/webapi'; import BaseAction from '../BaseAction'; import { ActionName } from '../types'; @@ -10,7 +11,7 @@ export class SetGroupNotice extends BaseAction { protected async _handle(payload: PayloadType) { const group = payload.group_id.toString(); - // WebApi.getGrouptNotice(group); + WebApi.setGroupNotice(group); return null; } } \ No newline at end of file diff --git a/src/onebot11/action/index.ts b/src/onebot11/action/index.ts index 7bcf595a..ea5c2c1c 100644 --- a/src/onebot11/action/index.ts +++ b/src/onebot11/action/index.ts @@ -49,6 +49,7 @@ import { GetCookies } from './user/GetCookies'; import { SetMsgEmojiLike } from '@/onebot11/action/msg/SetMsgEmojiLike'; import { GetRobotUinRange } from './extends/GetRobotUinRange'; import { SetOnlineStatus } from './extends/SetOnlineStatus'; +import { GetGroupNotice } from './group/GetGroupNotice'; export const actionHandlers = [ new GetFile(), @@ -90,6 +91,7 @@ export const actionHandlers = [ new SetOnlineStatus(), new GetRobotUinRange(), //以下为go-cqhttp api + new GetGroupNotice(), new GoCQHTTPSendForwardMsg(), new GoCQHTTPSendGroupForwardMsg(), new GoCQHTTPSendPrivateForwardMsg(),