Support Message Type of Image/Video
ak5 opened this issue · 27 comments
I couldn't find a way to grab images or other media - any way to do this?
Thanks for this it's quite cool even with just text!
Alex
Update by zixia
- wechat4u v0.5 update nodeWechat/wechat4u@5d0275e
- 语音识别 和 图片特征描述提取 nodeWechat/wechat4u#32
@ak5 thanks for like wechaty.
as you need media support and submit this issue, I'll put this feature as high priority. 💯
stay tuned.
Hi,
Any progress on this?
能说中文吗…
hmm... I'm working on stable issues those weeks to make wechaty run smoothly. will try to finger out how to get media for you tonight. :)
@ak5 how do you think this implementation? video should be easy grabed use the same way.
Hi @zixia bumping this request! Receiving images via message as well as plain text would be awesome! Any idea if you would have time to do this some time soon? The implementation you showed would be perfect.
thanks for bumping! I'm hoping to finish this issue on version 0.5, for supporting receive video/audio and send image/audio/video as well as plain text.
as your request, receiving images via message has already supported in the current code, which you can find at example/image-bot.ts
, run by npm run ts-node example/image-bot
.
you can have a try.
so there's only one issue left which belongs to the milestone v0.5...
it's you! 🔪
There's a media file demo bot in the example directory:
https://github.com/wechaty/wechaty/blob/master/example/media-file-bot.ts
+1. It would be very nice to have this feature.
@tiaozi0912 Thanks for pump this up!
In order to support send files(image/video/motion gif/pdf/etc), what we need to do is:
- Get to know how to call webwxApp
API_webwxuploadmedia
, source code at here: link, we can study it from Wechat4U at here: link - Expose a method, ie:
uploadMediaAsync()
forAPI_webwxuploadmedia
in WechatyBro(wechaty-bro.js) around here: link - add new methods for supporting
uploadMediaAsync
in bridge.ts & puppet-web.ts, examples can be found at here and there - modify class
MediaMessage
in message-media.ts, to support add a media stream to message method, likeMediaMessage.addMedia()
(?) - modify
PuppetWeb.send()
to support Message with media file.
The list above might not a full list, I'll add new thoughts to this post when I get them in my mind.
It will be great if you could kick it off, and I'll be very happy to follow you and make it works.
Should this be another ticket? Support for images, even without video would be a very huge improvement!
Split this issue into sub-issues is better because this issue include many feature/functions.
In order to send sticker/image/attachment/video, we need to implement API_webwxuploadmedia
first.
Then everything should be easy to implement. :)
Any news for this issue? Wechaty is really convenient but messaging with only plain text, we miss a lot of wechat functionalities. In my opinion this feature is really a must have.
Thanks @mukaiu's work, I can send Image-message right now.
Hi all, good news! The pull request to implement send attachment file from @lockon is just merged to the master branch! This feature will be available after Wechaty v0.7.58. Please submit an issue if you meet any problem or have any suggestions, Cheers!
Can not support message which is .gif file?
Is someone here? Can you tell me why I can not send .gif?
I did like below:
let mediaM = new MediaMessage(__dirname + '/test.gif');
room.say(mediaM)
but, when I checked this message at specified room, I found the message with 0KB&undefined (Just use type:APP, 49).
when I sent image(.png, .jpg), that's no any problems. I thought maybe asynchronous processing (Like .gif is not finished, there sent message already)?I have no idea of this.
If I do wrong or ignore something, please tell me.
Can you give me some helps to go through this problem?
Thank you very much!
@mukaiu Thank you firstly.
I have just finished this test. It works totally.
But there is one issue: It keeps saying to self, when I got a message, and send a file(.gif).
ps: I used /example/ding-dong-bot.ts to test directly.
Sorry for big pic, I could not resize this pic at Markdown.
@mukaiu can we support to say voice(.mp3 or .amr). I thought this is not be done as you have just changed for saying .gif?
if someone came here while looking for some guide on how to send images using wechaty,
here is what i have found working for me (npm wechaty no docker), no tscript:
const { Wechaty } = require('wechaty')
const Room = require('wechaty').Room
const MediaMessage = require('wechaty').MediaMessage
// blablabla login etc
Wechaty.instance({ profile:'bot' })
Room.find({topic:"YourRoomTopic"}).then( room => { **room.say (new MediaMessage('FileName.jpg'))** })
if room is defined already, then simply the bold part of it and ofc you may read FileName.jpg from some var.
@d2cs Thanks for sharing.
I'd like to make a suggestion:
+ const { Wechaty, Room, MediaMessage } = require('wechaty')
- const { Wechaty } = require('wechaty')
- const Room = require('wechaty').Room
- const MediaMessage = require('wechaty').MediaMessage