Skip to content

Commit 574894e

Browse files
committed
Add new InputMedia types and complete existing ones.
1 parent 9a59c01 commit 574894e

File tree

5 files changed

+198
-9
lines changed

5 files changed

+198
-9
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* This file is part of the TelegramBot package.
4+
*
5+
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace Longman\TelegramBot\Entities\InputMedia;
12+
13+
use Longman\TelegramBot\Entities\Entity;
14+
15+
/**
16+
* Class InputMediaAnimation
17+
*
18+
* @link https://core.telegram.org/bots/api#inputmediaanimation
19+
*
20+
* <code>
21+
* $data = [
22+
* 'media' => '123abc',
23+
* 'thumb' => '456def',
24+
* 'caption' => '*Animation* caption',
25+
* 'parse_mode' => 'markdown',
26+
* 'width' => 200,
27+
* 'height' => 150,
28+
* 'duration' => 11,
29+
* ];
30+
* </code>
31+
*
32+
* @method string getType() Type of the result, must be animation
33+
* @method string getMedia() File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More info on Sending Files »
34+
* @method string getThumb() Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
35+
* @method string getCaption() Optional. Caption of the animation to be sent, 0-200 characters
36+
* @method string getParseMode() Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
37+
* @method int getWidth() Optional. Animation width
38+
* @method int getHeight() Optional. Animation height
39+
* @method int getDuration() Optional. Animation duration
40+
*
41+
* @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More info on Sending Files »
42+
* @method $this setThumb(string $thumb) Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
43+
* @method $this setCaption(string $caption) Optional. Caption of the animation to be sent, 0-200 characters
44+
* @method $this setParseMode(string $parse_mode) Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
45+
* @method $this setWidth(int $width) Optional. Animation width
46+
* @method $this setHeight(int $height) Optional. Animation height
47+
* @method $this setDuration(int $duration) Optional. Animation duration
48+
*/
49+
class InputMediaAnimation extends Entity implements InputMedia
50+
{
51+
/**
52+
* InputMediaAnimation constructor
53+
*
54+
* @param array $data
55+
*
56+
* @throws \Longman\TelegramBot\Exception\TelegramException
57+
*/
58+
public function __construct(array $data = [])
59+
{
60+
$data['type'] = 'animation';
61+
parent::__construct($data);
62+
}
63+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* This file is part of the TelegramBot package.
4+
*
5+
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace Longman\TelegramBot\Entities\InputMedia;
12+
13+
use Longman\TelegramBot\Entities\Entity;
14+
15+
/**
16+
* Class InputMediaAudio
17+
*
18+
* @link https://core.telegram.org/bots/api#inputmediaaudio
19+
*
20+
* <code>
21+
* $data = [
22+
* 'media' => '123abc',
23+
* 'thumb' => '456def',
24+
* 'caption' => '*Audio* caption',
25+
* 'parse_mode' => 'markdown',
26+
* 'duration' => 42,
27+
* 'performer' => 'John Doe',
28+
* 'title' => 'The Song',
29+
* ];
30+
* </code>
31+
*
32+
* @method string getType() Type of the result, must be audio
33+
* @method string getMedia() File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
34+
* @method string getThumb() Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
35+
* @method string getCaption() Optional. Caption of the audio to be sent, 0-200 characters
36+
* @method string getParseMode() Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
37+
* @method int getDuration() Optional. Duration of the audio in seconds
38+
* @method string getPerformer() Optional. Performer of the audio
39+
* @method string getTitle() Optional. Title of the audio
40+
*
41+
* @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
42+
* @method $this setThumb(string $thumb) Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
43+
* @method $this setCaption(string $caption) Optional. Caption of the audio to be sent, 0-200 characters
44+
* @method $this setParseMode(string $parse_mode) Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
45+
* @method $this setDuration(int $duration) Optional. Duration of the audio in seconds
46+
* @method $this setPerformer(string $performer) Optional. Performer of the audio
47+
* @method $this setTitle(string $title) Optional. Title of the audio
48+
*/
49+
class InputMediaAudio extends Entity implements InputMedia
50+
{
51+
/**
52+
* InputMediaAudio constructor
53+
*
54+
* @param array $data
55+
*
56+
* @throws \Longman\TelegramBot\Exception\TelegramException
57+
*/
58+
public function __construct(array $data = [])
59+
{
60+
$data['type'] = 'audio';
61+
parent::__construct($data);
62+
}
63+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* This file is part of the TelegramBot package.
4+
*
5+
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace Longman\TelegramBot\Entities\InputMedia;
12+
13+
use Longman\TelegramBot\Entities\Entity;
14+
15+
/**
16+
* Class InputMediaDocument
17+
*
18+
* @link https://core.telegram.org/bots/api#inputmediadocument
19+
*
20+
* <code>
21+
* $data = [
22+
* 'media' => '123abc',
23+
* 'thumb' => '456def',
24+
* 'caption' => '*Document* caption',
25+
* 'parse_mode' => 'markdown',
26+
* ];
27+
* </code>
28+
*
29+
* @method string getType() Type of the result, must be document
30+
* @method string getMedia() File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
31+
* @method string getThumb() Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
32+
* @method string getCaption() Optional. Caption of the document to be sent, 0-200 characters
33+
* @method string getParseMode() Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
34+
*
35+
* @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
36+
* @method $this setThumb(string $thumb) Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
37+
* @method $this setCaption(string $caption) Optional. Caption of the document to be sent, 0-200 characters
38+
* @method $this setParseMode(string $parse_mode) Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
39+
*/
40+
class InputMediaDocument extends Entity implements InputMedia
41+
{
42+
/**
43+
* InputMediaDocument constructor
44+
*
45+
* @param array $data
46+
*
47+
* @throws \Longman\TelegramBot\Exception\TelegramException
48+
*/
49+
public function __construct(array $data = [])
50+
{
51+
$data['type'] = 'document';
52+
parent::__construct($data);
53+
}
54+
}

src/Entities/InputMedia/InputMediaPhoto.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,20 @@
1919
*
2020
* <code>
2121
* $data = [
22-
* 'media' => '123abc',
23-
* 'caption' => 'Photo caption',
22+
* 'media' => '123abc',
23+
* 'caption' => '*Photo* caption',
24+
* 'parse_mode' => 'markdown',
2425
* ];
2526
* </code>
2627
*
27-
* @method string getType() Type of the result, must be photo
28-
* @method string getMedia() File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
29-
* @method string getCaption() Optional. Caption of the photo to be sent, 0-200 characters
28+
* @method string getType() Type of the result, must be photo
29+
* @method string getMedia() File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
30+
* @method string getCaption() Optional. Caption of the photo to be sent, 0-200 characters
31+
* @method string getParseMode() Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
3032
*
31-
* @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
32-
* @method $this setCaption(string $caption) Optional. Caption of the photo to be sent, 0-200 characters
33+
* @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
34+
* @method $this setCaption(string $caption) Optional. Caption of the photo to be sent, 0-200 characters
35+
* @method $this setParseMode(string $parse_mode) Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
3336
*/
3437
class InputMediaPhoto extends Entity implements InputMedia
3538
{

src/Entities/InputMedia/InputMediaVideo.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,30 @@
2020
* <code>
2121
* $data = [
2222
* 'media' => '123abc',
23-
* 'caption' => 'Video caption (streamable)',
23+
* 'thumb' => '456def',
24+
* 'caption' => '*Video* caption (streamable)',
25+
* 'parse_mode' => 'markdown',
2426
* 'width' => 800,
2527
* 'height' => 600,
2628
* 'duration' => 42,
27-
* 'supports_streaming' => true
29+
* 'supports_streaming' => true,
2830
* ];
2931
* </code>
3032
*
3133
* @method string getType() Type of the result, must be video
3234
* @method string getMedia() File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
35+
* @method string getThumb() Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
3336
* @method string getCaption() Optional. Caption of the video to be sent, 0-200 characters
37+
* @method string getParseMode() Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
3438
* @method int getWidth() Optional. Video width
3539
* @method int getHeight() Optional. Video height
3640
* @method int getDuration() Optional. Video duration
3741
* @method bool getSupportsStreaming() Optional. Pass True, if the uploaded video is suitable for streaming
3842
*
3943
* @method $this setMedia(string $media) File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
44+
* @method $this setThumb(string $thumb) Optional. Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
4045
* @method $this setCaption(string $caption) Optional. Caption of the video to be sent, 0-200 characters
46+
* @method $this setParseMode(string $parse_mode) Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
4147
* @method $this setWidth(int $width) Optional. Video width
4248
* @method $this setHeight(int $height) Optional. Video height
4349
* @method $this setDuration(int $duration) Optional. Video duration

0 commit comments

Comments
 (0)