Skip to content

feat: receive media messages (image, video, voice, file)#10

Open
jinjiel1994 wants to merge 4 commits into
Johnixr:mainfrom
jinjiel1994:feat/media-receive
Open

feat: receive media messages (image, video, voice, file)#10
jinjiel1994 wants to merge 4 commits into
Johnixr:mainfrom
jinjiel1994:feat/media-receive

Conversation

@jinjiel1994
Copy link
Copy Markdown

Summary

  • Download and decrypt media (image/video/voice/file) from WeChat CDN using AES-128-ECB
  • Save decrypted media to ~/.claude/channels/wechat/media/ with timestamped filenames
  • Forward file paths + metadata to Claude Code via MCP channel notifications
  • Claude can then use the Read tool to view images or process media files

Supported message types

Type Const Handling
2 MSG_ITEM_IMAGE Download + decrypt → .jpg
3 MSG_ITEM_VOICE Download audio + keep existing text transcription
4 MSG_ITEM_FILE Download + preserve original extension
5 MSG_ITEM_VIDEO Download + decrypt → .mp4, includes duration/size metadata

Notification format

Media info is appended to the text content as inline annotations:

[image: /path/to/file.jpg]
[video: /path/to/file.mp4 (duration=9, size=2367862)]
[voice: /path/to/file.silk (transcription=你好)]
[file: /path/to/file.pdf (fileName=document.pdf)]

No new dependencies

Uses only node:crypto, node:fs, and native fetch — all already available in the project.

Test plan

  • Verified image receive: sent image via WeChat → downloaded, decrypted, Claude read the JPEG successfully
  • Verified video receive: sent video via WeChat → downloaded, decrypted to valid MP4 (HEVC 720x1280, 9s)
  • End-to-end test: restarted MCP server with changes, sent image from WeChat phone → Claude saw and described image content

🤖 Generated with Claude Code

jinjiel and others added 4 commits March 24, 2026 10:27
Download and decrypt media from WeChat CDN, save to local disk,
and forward file paths to Claude Code via MCP notifications.

- Add interfaces for MediaField, ImageItem, VideoItem, VoiceItemFull, FileItem
- Add downloadAndDecryptMedia() with AES-128-ECB decryption
- Add extractMediaFromItem() handling types 2/3/4/5
- Modify polling loop to process media alongside text
- Media saved to ~/.claude/channels/wechat/media/

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Upload and encrypt media to WeChat CDN, then send via ilink API.

- Add uploadAndSendMedia() with AES-128-ECB encryption + CDN upload flow
- Add getUploadUrl() for /ilink/bot/getuploadurl endpoint
- Register wechat_send_media tool (accepts file_path + media_type)
- Support image, video, and file sending
- Update MCP instructions to document media capabilities

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix CDN download param: use x-encrypted-query-param instead of x-encrypted-param
- Add encrypt_type, mid_size, hd_size to image_item for proper rendering
- Remove debug logging from upload flow

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Generate video thumbnail with ffmpeg for proper WeChat rendering
- Extract play_length with ffprobe
- Upload thumbnail to CDN separately and include as thumb_media
- Add encrypt_type field to all media items
- Clean up all debug logging

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Johnixr
Copy link
Copy Markdown
Owner

Johnixr commented Mar 24, 2026

Thanks for the PR! The media receive/send implementation looks good overall. One minor note:

Hardcoded thumbnail dimensions: In generateVideoThumbnail, the ffmpeg scale filter uses scale=224:-1 which preserves aspect ratio, but thumb_height is hardcoded to 398. The actual thumbnail height will vary depending on the video's aspect ratio, so this metadata may not match the real dimensions. Consider reading the actual thumbnail dimensions after generation, or just noting it as a known limitation.

Everything else looks solid — the download/decrypt flow, dual AES key format handling, and error handling are well done.

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.

2 participants