fix(onebot): default forward node sender to self when user_id is 0/absent
A fake forward node (send_group_forward_msg / send_private_forward_msg) whose data.user_id was "0" or omitted got rejected with "forward node user_id/uin is required", even though the protocol端 is logged in and the core forward builder (bridge/apis/forward.ts) already defaults a zero sender to the bot's own uin. Upstream frameworks (AstrBot, etc.) don't manage QQ uins and legitimately send user_id "0"; NapCat and LLBot accept it. parseForwardNodes now falls back to ref.selfId, keeping the throw only for the not-logged-in case (selfId 0). Verified on-target (#203).
This commit is contained in:
2 files changed
+31
-1
No files matched your search
@@ -1193,7 +1193,13 @@ async function parseForwardNodes(
|
||||
continue;
|
||||
}
|
||||
|
||||
const userUin = toPositiveInt(nodeData.user_id ?? nodeData.uin);
|
||||
// [#203] A fake forward node may omit user_id or send "0" — upstream
|
||||
// frameworks (AstrBot, etc.) don't manage QQ uins. The protocol端 is logged
|
||||
// in and the core builder already defaults a zero sender to the bot's own
|
||||
// uin (bridge/apis/forward.ts buildForwardPushBody), so match that leniency
|
||||
// here instead of rejecting. The throw stays as a guard for the not-logged-in
|
||||
// case (selfId 0).
|
||||
const userUin = toPositiveInt(nodeData.user_id ?? nodeData.uin) || ref.selfId;
|
||||
if (userUin <= 0) throw new Error('forward node user_id/uin is required');
|
||||
|
||||
const nickname = String(nodeData.nickname ?? nodeData.name ?? userUin);
|
||||
|
||||
Reference in new issue
Block a user