-
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
Receive and send audio messages #21
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your PR looks great, it has implemented most of the code for supporting the audio message for the OA puppet!
However, there has two parts of the code that we need to improve before we can merge it.
Please see my review at #19 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update!
Please see my reviews for some minor questions.
And for better unit testing, I believe the best practice is to build a Mock HTTP Server to interact with the code, and make sure our code is behavior as expected.
examples/echo.ts
Outdated
if (payload.qrcode) { | ||
// Generate a QR Code online via | ||
// http://goqr.me/api/doc/create-qr-code/ | ||
const qrcodeImageUrl = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use our wechaty.js.org to generate the online qrcode. because the qrserver.com is too slow and always out of service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comment below. TL;DR I deleted it in the newest commit.
examples/echo.ts
Outdated
*/ | ||
async function onMessage (event: EventMessagePayload) { | ||
const payload = await puppet.messagePayload(event.messageId); | ||
const fileBox = await puppet.messageFile(event.messageId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The payload
might not a file type.
What if a user just sends a text to the official account?
Need to be checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. I updated the code to handle different types of messages.
Replied to questions in the code review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this PR will be ready to merge after the CI turns green.
Please fix the lining problems, thanks!
Kindly ping @zhangfand |
The newest huan/file-box#53 should fix the issue. Once that is merged, I can upgrade dependency version as part of the PR. |
Dove. Thank you very much for keeping the modules update! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you very much for your contribution! You are welcome to join Wechaty Contributor Program1. Join Wechaty Organization
I have invited you to join our Wechaty GitHub Organization, please accept it by following the above message. 2. Update Your Wechaty Contributor Profile
3. Join The Contributor Only WeChat RoomWe also have a WeChat room for contributors only which can discuss Wechaty at a deeper level, you are welcome to join and if you are interested. Please add @lijiarui wechat: ruirui_0914 and send her this pr link. She will invite you into Wechaty Contributor Room Cheers! |
Fixes #19
The change adds support to OA puppet to receive and send audio files from / to Wechat,
and add another example that "echo" text or audio messages.
The implementation is largely constructed per the detailed instructions in #19 (❤️ ) .
There are a few catches:
messageSend
public and use it in the example instead of usingmessageSendFile
. The main reason ismime
package can not infer MIME type ofamr
file extension./get/media
API handles audio file is not well documented. From experiments, it seems to always return the audio file. I've documented the assumed format in the code.