Skip to content

Commit

Permalink
Send media group error (#178)
Browse files Browse the repository at this point in the history
* Fix sendMediaGroup error

* Add media list tests

Co-authored-by: Simone Romano <sromano@tierratelematics.com>
  • Loading branch information
SunTrustDev and Simone Romano authored Jun 12, 2020
1 parent 0e9ba45 commit 8a7b198
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ Use this method to send video files, Telegram clients support `mp4` videos (othe

Use this method to send video messages.

##### `sendMediaGroup(<chat_id>, <media: InputMedia>)`
##### `sendMediaGroup(<chat_id>, <mediaList: InputMedia[]>)`

Use this method to send a group of photos or videos as an album.
Use this method to send a group of photos or videos as an album. (Min. 2)

##### `sendVoice(<chat_id>, <file_id | path | url | buffer | stream>, {duration, caption, fileName, serverDownload, replyToMessage, replyMarkup, notification})`

Expand Down
9 changes: 5 additions & 4 deletions lib/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,11 @@ const methods = {
},

sendMediaGroup: {
arguments: ['chat_id'],
options(form, media) {
form.media = JSON.stringify(media);
return form;
arguments(chat_id, mediaList) {
return {
chat_id,
media: JSON.stringify(mediaList)
};
}
},

Expand Down
6 changes: 6 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ const sendMethods = {
sendVoice: {
'buffer': fs.readFileSync(`${__dirname}/data/voice.m4a`),
'file system': `${__dirname}/data/voice.m4a`
},
sendMediaGroup: {
'mediaList': [
{ type: 'photo', media: 'https://telegram.org/img/t_logo.png' },
{ type: 'video', media: 'http://techslides.com/demos/sample-videos/small.mp4'}
]
}
};

Expand Down

0 comments on commit 8a7b198

Please sign in to comment.