fix(kook): 私聊(临时会话)以对端用户为回复目标——修'不能是自己'40000
KOOK 临时私聊里用户→bot 事件的 target_id=bot 自己、author_id=对端用户;原 ChannelID= target_id(bot id),导致回复发给自己→KOOK 40000 不能是自己。修:非群聊时 ChannelID=发送者 (对端)id,回复即发给对端、每 DM 独立会话。加 TestToUnified_PrivateDmUsesPeerAsChannelID。 build/vet/test 全绿, 已重建部署.
This commit is contained in:
1 parent
64efb569c3
commit
c4fe5a0cfd
2 files changed
+35
-1
No files matched your search
@@ -91,10 +91,20 @@ func (a *Adapter) toUnifiedMessage(data json.RawMessage, frame []byte) (adapter.
|
||||
ct, media := messageKind(ev.Type, content)
|
||||
group := channelIsGroup(ev.ChannelType)
|
||||
|
||||
// KOOK temp/临时私聊: for a user→bot DM the event's target_id is the BOT's own id
|
||||
// (the recipient), while author_id is the peer user. Using target_id as the reply
|
||||
// target would make the bot reply to itself ("不能是自己", KOOK 40000). So for a
|
||||
// private (non-group) message we key the conversation by the peer sender, which is
|
||||
// also the correct reply target and keeps each DM a distinct session.
|
||||
channelID := ev.TargetID
|
||||
if group != adapter.ChannelGroup {
|
||||
channelID = senderID
|
||||
}
|
||||
|
||||
msg := adapter.UnifiedMessage{
|
||||
Platform: platformName,
|
||||
ChannelType: group,
|
||||
ChannelID: ev.TargetID,
|
||||
ChannelID: channelID,
|
||||
SenderID: senderID,
|
||||
SenderName: senderName,
|
||||
Content: content,
|
||||
|
||||
Reference in new issue
Block a user