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

@@ -557,8 +557,101 @@ export interface FaceroamOpReq {
inner?: pb<1, FaceroamOpReqInner>;
uin?: pb<2, uint_64>;
field3?: pb<3, uint_32>;
body?: pb<5, FaceroamOpBody>;
field6?: pb<6, uint_32>;
}
export interface FaceroamOpBody {
emojiId?: pb<1, string>;
}
// ImgStore.BDHExpressionRoam — 收藏表情上传申请(add 第1步)
// 请求 body 结构来自 9.9.26-44343 frida 抓包。
export interface BDHExpressionRoamInner {
field1?: pb<1, uint_32>;
uin?: pb<2, uint_64>;
field3?: pb<3, uint_32>;
/** 图片 MD5(16B 二进制,非 hex 字符串)。 */
md5?: pb<4, bytes>;
/** 图片字节数。 */
filesize?: pb<5, uint_32>;
field7?: pb<7, uint_32>;
field8?: pb<8, uint_32>;
field9?: pb<9, uint_32>;
ver?: pb<13, string>;
field16?: pb<16, uint_32>;
}
export interface BDHExpressionRoamTailInner {
field1?: pb<1, uint_32>;
field2?: pb<2, uint_32>;
field3?: pb<3, string>;
}
export interface BDHExpressionRoamTail {
inner?: pb<1, BDHExpressionRoamTailInner>;
field2?: pb<2, uint_32>;
}
export interface BDHExpressionRoamReq {
field1?: pb<1, uint_32>;
field2?: pb<2, uint_32>;
inner?: pb<3, BDHExpressionRoamInner>;
field7?: pb<7, uint_32>;
tail?: pb<1001, BDHExpressionRoamTail>;
}
// BDHExpressionRoam 响应:含上传节点 + token(add 第2步 highway 上传用)
export interface BDHExpressionRoamRespInner {
field1?: pb<1, uint_32>;
field2?: pb<2, uint_32>;
field4?: pb<4, uint_32>;
/** repeated varint,抓包见 6 个;上传节点走 fetchHighwaySession,不用这个。 */
field6?: pb_repeated<6, uint_32>;
field7?: pb_repeated<7, uint_32>;
/** 128B 上传 token,highway head 的 serviceTicket 用它。 */
token?: pb<8, bytes>;
field12?: pb<12, uint_32>;
field3?: pb<3, bytes>;
}
export interface BDHExpressionRoamResp {
field1?: pb<1, uint_32>;
field2?: pb<2, uint_32>;
inner?: pb<3, BDHExpressionRoamRespInner>;
}
// highway head(add 第2步,PicUp.DataUp commandId=9)
// 结构对齐 SnowLuma makeHighwayHead 的 msgBaseHead + msgSegHead,
// 但 commandId=9(表情)、segHead.serviceTicket = BDHExpressionRoam token(非 sigSession)、
// 顶层 f3 = emoji_id、f5 = 82B(含义未知,先不填)。
export interface FavEmojiHighwayBaseHead {
version?: pb<1, uint_32>;
uin?: pb<2, string>;
command?: pb<3, string>;
seq?: pb<4, uint_32>;
retryTimes?: pb<5, uint_32>;
filesize?: pb<6, uint_64>;
dataFlag?: pb<7, uint_32>;
commandId?: pb<8, uint_32>;
}
export interface FavEmojiHighwaySegHead {
serviceId?: pb<1, uint_32>;
filesize?: pb<2, uint_64>;
dataOffset?: pb<3, uint_64>;
dataLength?: pb<4, uint_64>;
/** 上传凭证 = BDHExpressionRoam token。 */
serviceTicket?: pb<6, bytes>;
md5?: pb<8, bytes>;
fileMd5?: pb<9, bytes>;
}
export interface FavEmojiIdWrap {
emojiId?: pb<1, string>;
}
export interface FavEmojiHighwayHead {
baseHead?: pb<1, FavEmojiHighwayBaseHead>;
segHead?: pb<2, FavEmojiHighwaySegHead>;
emojiIdWrap?: pb<3, FavEmojiIdWrap>;
field4?: pb<4, uint_32>;
/** 82B,抓包见过但非必需。 */
field5?: pb<5, bytes>;
field8?: pb<8, uint_32>;
}
export interface FaceroamOpRespItem {
faceIds?: pb_repeated<1, string>;
category?: pb<3, string>;