feat: implement send group notice

This commit is contained in:
H3CoF6 committed 2026-05-09 03:44:08 +08:00
1 parent d708be4627
commit c862a157db
10 files changed
+158 -26

No files matched your search

+24 -2
View File
@@ -230,8 +230,30 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
// --- Group notice stubs ---
h.registerAction('_send_group_notice', async () => {
return failedResponse(RETCODE.ACTION_FAILED, 'not yet implemented');
h.registerAction('send_group_notice', async (params) => {
const groupId = asNumber(params.group_id);
const content = asString(params.content);
if (!groupId || !content) {
return failedResponse(RETCODE.BAD_REQUEST, 'group_id and content are required');
}
if (!ctx.sendGroupNotice) {
return failedResponse(RETCODE.ACTION_FAILED, 'not implemented');
}
try {
const options = {
image: asString(params.image),
pinned: params.pinned !== undefined ? Number(params.pinned) : 0,
type: params.type !== undefined ? Number(params.type) : 1,
confirm_required: params.confirm_required !== undefined ? Number(params.confirm_required) : 1,
};
await ctx.sendGroupNotice(groupId, content, options);
return okResponse();
} catch (e) {
return failedResponse(RETCODE.ACTION_FAILED, String(e));
}
});
h.registerAction('_get_group_notice', async () => {
+1
View File
@@ -98,6 +98,7 @@ export interface ApiActionContext {
getGroupHonorInfo?: (groupId: number, type: WebHonorType | string) => Promise<any>;
getGroupEssence?: (groupId: number, pageStart?: number, pageLimit?: number) => Promise<GroupEssenceMsgRet>;
getGroupEssenceAll?: (groupId: number) => Promise<GroupEssenceMsgRet[]>;
sendGroupNotice?: (groupId: number, content: string, options?: any) => Promise<any>;
}
type ActionHandler = (params: JsonObject) => Promise<import('./types').ApiResponse>;
@@ -128,6 +128,7 @@ export function buildApiContext(ref: InstanceRef): ApiActionContext {
getGroupHonorInfo: (groupId: number, type: WebHonorType | string)=> bridge.getGroupHonorInfo(groupId, type),
getGroupEssence: (groupId: number, pageStart: number = 0, pageLimit: number = 50) => bridge.getGroupEssence(groupId, pageStart, pageLimit),
getGroupEssenceAll: (groupId: number) => bridge.getGroupEssenceAll(groupId),
sendGroupNotice: (groupId: number, content: string, options?: any) => bridge.sendGroupNotice(groupId, content, options),
};
}