Skip to content

feat: expose URL for link messages (app_type=5)#7

Open
fengcunhan wants to merge 1 commit intohuohuoer:mainfrom
fengcunhan:feat/expose-link-url
Open

feat: expose URL for link messages (app_type=5)#7
fengcunhan wants to merge 1 commit intohuohuoer:mainfrom
fengcunhan:feat/expose-link-url

Conversation

@fengcunhan
Copy link
Copy Markdown

Summary

链接消息(app_type == 5)此前只输出 [链接] 标题,把 <appmsg><url> 字段丢弃了。这导致从 CLI / LLM 端无法拿到原始链接,只能直接查数据库。

本 PR 在 _format_app_message_text 中读取 <url>,并以缩进续行的方式附加在标题之后 —— 沿用现有的 [文件] 和引用消息的展示风格。

Diff

```diff
if app_type == 5:

  •    return f\"[链接] {title}\" if title else \"[链接]\"
    
  •    url = _collapse_text(appmsg.findtext('url') or '')
    
  •    label = f\"[链接] {title}\" if title else \"[链接]\"
    
  •    if url:
    
  •        label += f\"\\n  {url}\"
    
  •    return label
    

```

Before / After

Before:
```
[2026-04-26 20:04] zartbot: [链接] DeepSeek-V4详细分析(1): 算法和模型结构
```

After:
```
[2026-04-26 20:04] zartbot: [链接] DeepSeek-V4详细分析(1): 算法和模型结构
http://mp.weixin.qq.com/s?__biz=...
```

Test plan

  • wechat-cli history <chat> --type link 输出包含 URL
  • --format json / --format text 两种格式均生效(共享 _format_message_text 调用链)
  • 没有 URL 字段的链接消息回退到原行为(仅显示 [链接] 标题

Link messages previously only printed the title, hiding the actual URL
stored in <appmsg><url>. This made it impossible to retrieve the original
link target without querying the database directly.

Append the URL on an indented continuation line, matching the existing
pattern used for file messages and quoted messages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant