feat: implement default mark msg as read and add get clientkey onebot api

This commit is contained in:
H3CoF6 committed 2026-05-08 16:42:19 +08:00
1 parent e3e364db63
commit 7e2ba60073
5 files changed
+50 -3

No files matched your search

+33 -1
View File
@@ -172,6 +172,31 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
return okResponse();
});
h.registerAction('mark_msg_as_read', async (params) => {
const messageId = asNumber(params.message_id);
const targetId = asNumber(params.target_id);
if (!Number.isInteger(messageId) || messageId === 0) {
return failedResponse(RETCODE.BAD_REQUEST, 'message_id is required');
}
const meta = ctx.getMessageMeta(messageId);
if (!meta) return failedResponse(RETCODE.ACTION_FAILED, 'message not found');
if (targetId && targetId !== meta.targetId) {
return failedResponse(RETCODE.BAD_REQUEST, 'target_id does not match message session');
}
if (!(ctx.markPrivateMsgAsRead && ctx.markGroupMsgAsRead)) return failedResponse(RETCODE.ACTION_FAILED, 'not implemented');
if (meta.isGroup) {
await ctx.markGroupMsgAsRead(targetId, meta.sequence);
} else {
await ctx.markPrivateMsgAsRead(targetId, meta.sequence);
}
return okResponse();
});
// --- RKey ---
@@ -542,7 +567,14 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
});
h.registerAction('get_clientkey', async () => {
return failedResponse(RETCODE.ACTION_FAILED, 'not yet implemented');
if (!ctx.forceFetchClientKey) {
return failedResponse(RETCODE.ACTION_FAILED, 'not yet implemented');
}
const clientKeyInfo = await ctx.forceFetchClientKey();
if (!clientKeyInfo.clientKey) {
return failedResponse(RETCODE.ACTION_FAILED, 'get clientkey error');
}
return okResponse(clientKeyInfo);
});
h.registerAction('get_mini_app_ark', async () => {