-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: receive and send audio message #19
Comments
Yes, |
We now support very limit message types: In order to support receiving more message types, like audio, you need to look at: I hope the above information can help you and please feel free to let me know if you have more questions. @MachengShen |
Thanks! I added 'voice' to the 'knownTypeList', and the voice message triggers the onMessage() method in ding-dong.ts, but the message type is 'text' instead of 'audio'. The log shows that the received message was 'voice' before 'const msgPayload = await puppet.messagePayload(payload.messageId)' was called, so my understanding is that something in the wechaty-puppet repo is messing up with the payload? I attached the code piece to reproduce this issue and the log (level 'silly') from the console: Steps for reproduce:
async function onMessage (payload: EventMessagePayload) {
const msgPayload = await puppet.messagePayload(payload.messageId)
log.verbose('ding-dong', `onMessage: ${JSON.stringify(msgPayload)}`)
}
const knownTypeList = [
'text',
'image',
'voice',
] Then send a voice message to the official account Logs:
|
Congratulations! It seems that you can receive the right webhook payload from WeChat Official Server when you sent an audio message to your Official Account! However, it seems that the Wechaty Message Payload has not been set correctly. In order to make it correct, you need to understand the message processing flow in Wechaty Puppet. Wechaty Puppet Message Processing Flow
What to Do NextSo it will be very clear that, what we need to do to support the new Message Type (audio in this case), is to implement the I hope the above explanation could help you to move forward, please feel free to let me know if you have more questions. |
Review for #21 Receiving Audio FileThe Wechaty will call
Sending Audio FileThe Wechaty will call |
Thanks for your prompt reply. One issue I ran into when trying to update
https://github.com/huan/file-box/blob/master/src/file-box.ts#L270 What would you suggest to work around this? |
In my understanding, our problem is that the My suggestion would like:
Please let me what you think about this solution, thanks. |
UpdateIt seems that the So we can add the following line to FileBox which I believe could fix the mime issue for // Require Mime class
const Mime = require('mime/Mime');
// Define mime type -> extensions map
const typeMap = {
'audio/amr': ['amr'],
};
// Create and use Mime instance
const myMime = new Mime(typeMap);
myMime.getType('amr'); // ⇨ 'audio/amr' |
I saw it has been merged already, cheers! Please link the issues together in the future, for example, ref to this issue to jshttp/mime-db#228 so that we can always sync the latest updates. I believe this feature has no blocker anymore, so please go ahead and feel free to let me know if you have any new questions. Happy Chinese New Year! |
🎉👍
…Sent from my iPhone
On Feb 13, 2021, at 1:08 PM, Huan (李卓桓) <[email protected]> wrote:
I saw it has been merged already, cheers!
Please link the issues together in the future, for example, ref to this issue to jshttp/mime-db#228<jshttp/mime-db#228> so that we can always sync the latest updates.
I believe this feature has no blocker anymore, so please go ahead and feel free to let me know if you have any new questions.
Happy Chinese New Year!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#19 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ALM6ERQGH5UVPKCEZ7IUUXLS6YCMJANCNFSM4W4A243Q>.
|
Good call! I wasn't aware this feature exists. Will definitely do that more in the future. I don't foresee any blocker as well. Will address the comments and update the PR. Happy Lunar New Year to you, too! |
Hi, Thanks for the nice OA puppet. I'm interested in receiving and sending audio messages with wechat users through OA. Currently the puppet.messageSendFile() method throws an 'unsupported file exception' when trying to send SILK encoded audio files, or .mp3, and the 'EventMessagePayload' also does not receive audio input from the user.
Would appreciate it if we can add this new feature, please instruct how to do it. Thanks!
The text was updated successfully, but these errors were encountered: