feat: add merged forward message (合并转发) parsing support#9
Open
Wuchen-4810 wants to merge 1 commit into
Open
Conversation
- Add _format_merged_forward_message to parse app_type 17/19 XML - Extract individual messages from <recorditem> <dataitem> elements - Show sender, timestamp, and content for each forwarded message - Handle nested forwarded messages and file references - Fix XML parsing failure when <?xml?> declaration is embedded inside <msg> - Increase _XML_PARSE_MAX_LEN from 20000 to 200000 for long chat records Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add merged forward (合并转发) message parsing support to wechat-cli.
Problem
When WeChat users forward multiple messages together (合并转发), the resulting chat record uses app_type=17 or app_type=19. Previously, wechat-cli displayed these as [链接/文件], making the forwarded content unreadable.
Changes
1. New function:
_format_merged_forward_message()Parses the nested XML structure inside merged forward messages:
<recorditem>to<dataitem>elements from CDATA sections<desc>text when structured data is unavailable├ sender [time]: content2. Increased XML parse size limit
_XML_PARSE_MAX_LEN: 20000 -> 2000003. XML declaration cleanup
re.sub(r'<\?xml\b[^?]*\?>', '', content)before parsing<?xml version="1.0"?>is embedded inside the<msg>tag4. App type routing
app_type in (17, 19)branch in_format_app_message_text()[链接/文件]Before/After
Testing
Tested with real WeChat merged forward messages from group chats, including a 64KB chat record containing dozens of messages.