feat(protocol): favorite emoji fetch/delete/add via Faceroam.OpReq + highway (#107)

* feat(protocol): fetch/delete favorite emoji via Faceroam.OpReq

First non-OIDB services in oidb-services/ — Faceroam.OpReq is a trpc
service, so these bypass invokeOidb and call sendRawPacket directly.

- proto-defs: reuse FaceroamOpReq/Inner/Resp, add field5 + FaceroamOpBody
- protocol: oidb-services/emoji/{shared,fetch-fav-list,delete-fav-emoji}
- core: EmojiApi facade + ApiHub registration
- onebot: fetch_fav_emoji_list + delete_fav_emoji actions

Request wire matches 9.9.26-44343 captures byte-for-byte; fetch response
decode + delete verified end-to-end against a live account.

* feat(protocol): add favorite emoji via BDHExpressionRoam + highway HTTP upload

Flow: BDHExpressionRoam (apply upload, get token) -> highway frame
(PicUp.DataUp commandId=9, serviceTicket = BDHExpressionRoam token) ->
HTTP POST httpconn?htcmd=0x6FF0087 -> fetch refresh.

- proto-defs: BDHExpressionRoamReq/Resp + FavEmojiHighwayHead types
- protocol: oidb-services/emoji/add-fav-emoji (fetchHighwaySession +
  BDHExpressionRoam + packHighwayFrame + HTTP POST)
- core: EmojiApi.addFavEmoji facade (reuses loadBinarySource)
- onebot: add_fav_emoji action
- mcp: regenerate catalog

End-to-end verified: new emoji_id appears in fetch list after upload.

* refactor(emoji): reuse fetchCustomFace for fetch_fav_emoji_list

Address review: Faceroam.OpReq had two call sites (profile.fetchCustomFace
+ the new FetchFavList service). Drop the duplicate service —
fetch_fav_emoji_list now reuses ProfileApi.fetchCustomFace and extracts
emoji_id from the returned image URL (qq_expression/<uin>/<id>/0).

delete/add unchanged (independent protocols).

* refactor: align custom-face naming with NapCat

Address review: 'fav_emoji' vs existing 'custom_face' named the same
thing two ways. Rename across the stack to match NapCat's custom_face:
- services: oidb-services/emoji/* -> oidb-services/custom-face/*
  (DeleteFavEmoji -> DeleteCustomFace, AddFavEmoji -> AddCustomFace)
- facade: EmojiApi dropped; delete/add moved to ProfileApi
  (deleteCustomFace / addCustomFace), next to fetchCustomFace
- actions: fetch_fav_emoji_list -> fetch_custom_face_ids,
  delete_fav_emoji -> delete_custom_face, add_fav_emoji -> add_custom_face
- package.json subpaths + catalog regenerated

* refactor(onebot): merge fetch_custom_face_ids into fetch_custom_face

Per review: merge fetch_custom_face_ids back into fetch_custom_face
with a return_type param ('url' default / 'id'). One action, one service,
no separate id-only variant.
This commit is contained in:
Qiao authored and DrSmoothl committed 2026-06-19 02:15:54 +08:00
1 parent e3a04858b4
commit 552238fd04
9 files changed
+631 -21

No files matched your search

+43 -1
View File
@@ -213,6 +213,36 @@ export const actions = [
},
}),
// 删除收藏表情(Faceroam.OpReq opType=2)
defineAction({
name: 'delete_custom_face',
summary: '删除收藏表情',
params: { emoji_id: f.string({ allowEmpty: false }) },
run: async (p, ctx) => {
try {
await ctx.bridge.apis.profile.deleteCustomFace(p.emoji_id);
return okResponse();
} catch (e) {
return failedResponse(RETCODE.ACTION_FAILED, String(e));
}
},
}),
// 添加收藏表情(ImgStore.BDHExpressionRoam + highway HTTP 上传)
defineAction({
name: 'add_custom_face',
summary: '添加收藏表情',
params: { file: f.string({ allowEmpty: false }) },
run: async (p, ctx) => {
try {
const emojiId = await ctx.bridge.apis.profile.addCustomFace(p.file);
return okResponse({ emoji_id: emojiId });
} catch (e) {
return failedResponse(RETCODE.ACTION_FAILED, String(e));
}
},
}),
// 消息历史
groupAction({
name: 'get_group_msg_history',
@@ -803,10 +833,22 @@ export const actions = [
name: 'fetch_custom_face',
summary: '获取自定义表情',
readOnly: true,
params: { count: f.int({ min: 0 }).default(10) },
params: {
count: f.int({ min: 0 }).default(10),
// return_type=url 返回图片 URL(默认,给前端显示);
// return_type=id 返回 emoji_id(给 delete/add 用)。
return_type: f.string().default('url'),
},
run: async (p, ctx) => {
try {
const urls = await ctx.bridge.apis.profile.fetchCustomFace(p.count);
if (p.return_type === 'id') {
const emojiIds = urls.map((url) => {
const m = /\/qq_expression\/[^/]+\/([^/]+)\//.exec(url);
return m ? m[1] : '';
}).filter(Boolean);
return okResponse(emojiIds);
}
return okResponse(urls);
} catch (e) {
return failedResponse(RETCODE.ACTION_FAILED, String(e));