Skip to content

Commit

Permalink
Merge pull request #11 from droooney/allow-input-file-as-paid-media-i…
Browse files Browse the repository at this point in the history
…nput

allow InputFile as paid media input
  • Loading branch information
Borodin authored Sep 27, 2024
2 parents a015225 + 7060662 commit eb7f347
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/types/InputPaidMediaPhoto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Attachment } from './index';

/**
* InputPaidMediaPhoto
* The paid media to send is a photo.
Expand All @@ -15,5 +17,5 @@ export type InputPaidMediaPhoto = {
* multipart/form-data under <file_attach_name> name.
* @see https://core.telegram.org/bots/api#sending-files
*/
media: string;
media: string | Attachment;
};
3 changes: 2 additions & 1 deletion src/types/InputPaidMediaVideo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { InputFile } from './InputFile';
import { Attachment } from './index';

/**
* InputPaidMediaVideo
Expand All @@ -17,7 +18,7 @@ export type InputPaidMediaVideo = {
* multipart/form-data under <file_attach_name> name.
* @see https://core.telegram.org/bots/api#sending-files
*/
media: string;
media: string | Attachment;

/**
* Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side.
Expand Down
16 changes: 16 additions & 0 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,22 @@ describe('.sendPaidMedia()', () => {
}),
).resolves.toHaveProperty('paid_media');
});

it('should send paid media from file', async () => {
await expect(
bot.sendPaidMedia({
chat_id: TEST_CHANNEL_ID,
star_count: 1,
media: [
{
type: 'video',
media: createReadStream('tests/data/video.mp4'),
},
],
caption: 'Paid media from file',
}),
).resolves.toHaveProperty('paid_media');
});
});

describe('.sendMediaGroup()', () => {
Expand Down

0 comments on commit eb7f347

Please sign in to comment.