refactor(api): move Tier-2 extras to ExtrasApi (#6 commit 11/13)
Inlines `actions/extras.ts` into `apis/extras.ts::ExtrasApi`. Covers
the napcat-parity Tier-2 surface: group todo CRUD (0xF90_1/2/3),
stranger online/ext status decode (0xFE1_2), and AI voice list +
synthesis (0x929D / 0x929B).
`StrangerStatus`, `AiVoiceChatType`, `AiVoiceCategory`, `AiVoiceItem`
are now exported from `apis/extras.ts` and re-exported through
`bridge.ts` for backwards compatibility (the OneBot side imports
them via `@snowluma/core`).
No renaming — the names already read cleanly under `apis.extras.X`.
The `fetchAiVoiceList` / `fetchAiVoice` chatType parameter is widened
to `AiVoiceChatType | number` because the OneBot side passes a raw
number from JSON. The wire encoder is happy with any integer; the
strict enum just gives autocompletion at call sites that have it.
Callers updated: `actions/extended.ts` (7 sites).
Tests rewritten:
- `extras.test.ts` → uses `new ExtrasApi(bridge as any).method(...)`
and the it.each dispatch switches to method-name strings.
- `extended-actions.test.ts` APIS_ROUTING gains the extras block.
587/587 tests pass.
This commit is contained in:
1 parent
e5ac2a61b1
commit
22add4ad1c
8 files changed
+205
-204
No files matched your search
@@ -9,18 +9,14 @@ import { IncomingPacketPipeline, type CmdParser } from './packet-pipeline';
|
||||
import { type ApiHub, buildApiHub } from './apis';
|
||||
|
||||
// Delegated modules
|
||||
// Group-todo / stranger-status / AI-voice moved to apis/extras.ts.
|
||||
// Public types stay re-exported through this file for backwards
|
||||
// compatibility — the OneBot side imports them via `@snowluma/core`.
|
||||
import {
|
||||
AiVoiceChatType,
|
||||
cancelGroupTodo as cancelGroupTodo_,
|
||||
completeGroupTodo as completeGroupTodo_,
|
||||
fetchAiVoice as fetchAiVoice_,
|
||||
fetchAiVoiceList as fetchAiVoiceList_,
|
||||
getStrangerStatus as getStrangerStatus_,
|
||||
setGroupTodo as setGroupTodo_,
|
||||
type AiVoiceCategory,
|
||||
type AiVoiceChatType as AiVoiceChatTypeT,
|
||||
type StrangerStatus,
|
||||
} from './actions/extras';
|
||||
} from './apis/extras';
|
||||
// actions/forward.ts removed — moved to apis/forward.ts::ForwardApi.
|
||||
// actions/friend.ts removed — moved to apis/friend.ts::FriendApi.
|
||||
// actions/group-admin.ts removed — moved to `apis/group-admin.ts::GroupAdminApi`.
|
||||
@@ -342,25 +338,7 @@ export class Bridge implements BridgeInterface {
|
||||
// Misc methods (translateEn2Zh / getMiniAppArk /
|
||||
// clickInlineKeyboardButton / sendGroupSign) moved to apis.misc.
|
||||
|
||||
// --- Tier-2 napcat-parity extras (group todo, stranger status, AI voice) ---
|
||||
|
||||
async setGroupTodo(groupId: number, msgSeq: bigint | number | string): Promise<void> {
|
||||
return setGroupTodo_(this, groupId, BigInt(msgSeq));
|
||||
}
|
||||
async completeGroupTodo(groupId: number, msgSeq: bigint | number | string): Promise<void> {
|
||||
return completeGroupTodo_(this, groupId, BigInt(msgSeq));
|
||||
}
|
||||
async cancelGroupTodo(groupId: number, msgSeq: bigint | number | string): Promise<void> {
|
||||
return cancelGroupTodo_(this, groupId, BigInt(msgSeq));
|
||||
}
|
||||
async getStrangerStatus(uin: number): Promise<StrangerStatus | null> {
|
||||
return getStrangerStatus_(this, uin);
|
||||
}
|
||||
async fetchAiVoiceList(groupId: number, chatType: AiVoiceChatTypeT): Promise<AiVoiceCategory[]> {
|
||||
return fetchAiVoiceList_(this, groupId, chatType);
|
||||
}
|
||||
async fetchAiVoice(groupId: number, voiceId: string, text: string, chatType: AiVoiceChatTypeT) {
|
||||
return fetchAiVoice_(this, groupId, voiceId, text, chatType);
|
||||
}
|
||||
// --- Tier-2 napcat-parity extras (group todo / stranger status /
|
||||
// AI voice) moved to apis.extras. ---
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user