wechaty / wechaty

Conversational RPA SDK for Chatbot Makers. Join our Discord: https://discord.gg/7q8NBZbQzt

Home Page:https://wechaty.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Message Type of Image/Video

ak5 opened this issue · comments

commented

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

@ak5 thanks for like wechaty.

as you need media support and submit this issue, I'll put this feature as high priority. 💯

stay tuned.

commented

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. :)

@sjdy521 我觉得咱们说中文不太合适。和你聊天应该用 Perl 文 :-]

@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.

@naishstar

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:

  1. Get to know how to call webwxApp API_webwxuploadmedia , source code at here: link, we can study it from Wechat4U at here: link
  2. Expose a method, ie: uploadMediaAsync() for API_webwxuploadmedia in WechatyBro(wechaty-bro.js) around here: link
  3. add new methods for supporting uploadMediaAsync in bridge.ts & puppet-web.ts, examples can be found at here and there
  4. modify class MediaMessage in message-media.ts, to support add a media stream to message method, like MediaMessage.addMedia()(?)
  5. 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.

commented

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.

@lbineau Thanks for voting this up. :)

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!

commented

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).
error
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!

@yumewang Fixed,please test PR #438

commented

@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).

multi-file-send
ps: I used /example/ding-dong-bot.ts to test directly.

Sorry for big pic, I could not resize this pic at Markdown.

commented

@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?

commented

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

Support for sending any type of file.

doc/pdf/ppt/mp3/mp4/gif/jpg... any type file.

see #714

Thanks, @binsee !

Finally, this issue seems could be closed in the near future, after 12 months... LOL.

  1. PR from @mukaiu was already landed, and
  2. PR from @binsee will be landed recently.

So I closed this issue for keep issue list clean.

Appreciate for the discussion about this feature!