Skip to content

Add outbound Weixin native voice-message support#9

Open
cgf120 wants to merge 1 commit intoTencent:mainfrom
cgf120:feat/weixin-voice-outbound
Open

Add outbound Weixin native voice-message support#9
cgf120 wants to merge 1 commit intoTencent:mainfrom
cgf120:feat/weixin-voice-outbound

Conversation

@cgf120
Copy link
Copy Markdown

@cgf120 cgf120 commented Mar 31, 2026

Summary

This PR adds outbound native Weixin voice-message support.

The protocol layer already defines:

  • UploadMediaType.VOICE = 4
  • MessageItemType.VOICE = 3
  • VoiceItem with voice-specific metadata

The README also documents voice_item / SILK-based voice messages.

However, the current outbound implementation only exposes:

  • text
  • image
  • video
  • file

Audio files are currently routed through the generic file path instead of being sent as native Weixin voice messages.

What changed

  • Added uploadVoiceToWeixin() using UploadMediaType.VOICE
  • Added sendVoiceMessageWeixin() to emit MessageItemType.VOICE
  • Updated send-media.ts so supported audio files are routed to the voice path instead of always falling back to file attachments
  • Preserved file fallback for unsupported audio formats

Notes

  • The current implementation routes:
    • .silkencode_type = 6
    • .mp3 / audio/mpegencode_type = 7
    • .ogg / audio/oggencode_type = 8
  • Unsupported audio formats still fall back to file attachment delivery
  • This keeps the existing behavior safe while enabling native voice delivery for supported formats

Why

The protocol and public docs already indicate native voice-message capability, but the outbound implementation was missing the final send/upload path for VOICE.

This PR completes that missing path so outbound behavior matches the documented message schema.

@cgf120
Copy link
Copy Markdown
Author

cgf120 commented Apr 13, 2026

@pumpkinxing1 HI

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