Skip to content

Commit b0f7eff

Browse files
authored
Merge pull request #152 from DJTommek/pr/bot-api-6.6-thumbnails-renaming
Bot API 6.6 Thumbnails renaming + other changes
2 parents 12971df + edbe64c commit b0f7eff

33 files changed

+433
-91
lines changed

examples/send-audio.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
$sendAudio->chat_id = A_USER_CHAT_ID;
1818
$sendAudio->audio = new InputFile('binary-test-data/ICQ-uh-oh.mp3');
1919
$sendAudio->title = 'The famous ICQ new message alert';
20-
$sendAudio->thumb = new InputFile(__DIR__ . '/binary-test-data/logo-php7-telegram-bot-api-thumbnail.jpg');
20+
$sendAudio->thumbnail = new InputFile(__DIR__ . '/binary-test-data/logo-php7-telegram-bot-api-thumbnail.jpg');
2121

2222
$promise = $tgLog->performApiRequest($sendAudio);
2323

examples/send-document.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
$sendDocument = new SendDocument();
1919
$sendDocument->chat_id = A_USER_CHAT_ID;
2020
$sendDocument->document = new InputFile(__FILE__);
21-
$sendDocument->thumb = new InputFile(__DIR__ . '/binary-test-data/logo-php7-telegram-bot-api-thumbnail.jpg');
21+
$sendDocument->thumbnail = new InputFile(__DIR__ . '/binary-test-data/logo-php7-telegram-bot-api-thumbnail.jpg');
2222

2323
$promise = $tgLog->performApiRequest($sendDocument);
2424

@@ -37,7 +37,7 @@ function ($response) use ($tgLog, $loop) {
3737

3838
// Load uploaded thumbnail and generate URL to download using bot token
3939
$getFileThumb = new GetFile();
40-
$getFileThumb->file_id = $response->document->thumb->file_id;
40+
$getFileThumb->file_id = $response->document->thumbnail->file_id;
4141
$fileThumb = await($tgLog->performApiRequest($getFileThumb), $loop);
4242
var_dump('Thumbnail url: ' . $tgLog->fileUrl($fileThumb));
4343
},

src/Telegram/Methods/SendAnimation.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ class SendAnimation extends TelegramMethods
5959
* if the thumbnail was uploaded using multipart/form-data under <file_attach_name>
6060
* @var string|InputFile
6161
*/
62+
public $thumbnail;
63+
64+
/**
65+
* @deprecated Use $thumbnail instead (Bot API 6.6, March 9, 2023 https://core.telegram.org/bots/api-changelog#march-9-2023)
66+
* @var string|InputFile
67+
*/
6268
public $thumb;
6369

6470
/**

src/Telegram/Methods/SendAudio.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ class SendAudio extends TelegramMethods
4949
* uploaded using multipart/form-data under <file_attach_name>.
5050
* @var string|InputFile
5151
*/
52+
public $thumbnail;
53+
54+
/**
55+
* @deprecated Use $thumbnail instead (Bot API 6.6, March 9, 2023 https://core.telegram.org/bots/api-changelog#march-9-2023)
56+
* @var string|InputFile
57+
*/
5258
public $thumb;
5359

5460
/**
@@ -126,6 +132,7 @@ public function getLocalFiles(): Generator
126132
{
127133
yield from [
128134
'audio' => $this->audio,
135+
'thumbnail' => $this->thumbnail,
129136
'thumb' => $this->thumb,
130137
];
131138
}

src/Telegram/Methods/SendDocument.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace unreal4u\TelegramAPI\Telegram\Methods;
66

@@ -9,7 +9,6 @@
99
use unreal4u\TelegramAPI\Abstracts\TelegramMethods;
1010
use unreal4u\TelegramAPI\Telegram\Types\Custom\InputFile;
1111
use unreal4u\TelegramAPI\Telegram\Types\Custom\MessageEntityArray;
12-
use unreal4u\TelegramAPI\Telegram\Types\MessageEntity;
1312

1413
/**
1514
* Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any
@@ -44,6 +43,12 @@ class SendDocument extends TelegramMethods
4443
* uploaded using multipart/form-data under <file_attach_name>.
4544
* @var string|InputFile
4645
*/
46+
public $thumbnail;
47+
48+
/**
49+
* @deprecated Use $thumbnail instead (Bot API 6.6, March 9, 2023 https://core.telegram.org/bots/api-changelog#march-9-2023)
50+
* @var string|InputFile
51+
*/
4752
public $thumb;
4853

4954
/**
@@ -108,13 +113,16 @@ public function getMandatoryFields(): array
108113

109114
public function hasLocalFiles(): bool
110115
{
111-
return $this->document instanceof InputFile || $this->thumb instanceof InputFile;
116+
return $this->document instanceof InputFile
117+
|| $this->thumbnail instanceof InputFile
118+
|| $this->thumb instanceof InputFile;
112119
}
113120

114121
public function getLocalFiles(): Generator
115122
{
116123
yield from [
117124
'document' => $this->document,
125+
'thumbnail' => $this->thumbnail,
118126
'thumb' => $this->thumb,
119127
];
120128
}

src/Telegram/Methods/SendMessage.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace unreal4u\TelegramAPI\Telegram\Methods;
66

7-
use unreal4u\TelegramAPI\Abstracts\TelegramMethods;
87
use unreal4u\TelegramAPI\Abstracts\KeyboardMethods;
8+
use unreal4u\TelegramAPI\Abstracts\TelegramMethods;
99

1010
/**
1111
* Object that resembles a message object in Telegram
@@ -22,6 +22,12 @@ class SendMessage extends TelegramMethods
2222
*/
2323
public $chat_id = '';
2424

25+
/**
26+
* Optional. Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
27+
* @var int
28+
*/
29+
public $message_thread_id = 0;
30+
2531
/**
2632
* Text of the message to be sent
2733
* @var string
@@ -51,17 +57,24 @@ class SendMessage extends TelegramMethods
5157
public $disable_notification = false;
5258

5359
/**
54-
* Optional. Pass True if the message should be sent even if the specified replied-to message is not found
60+
* Optional. Protects the contents of the sent message from forwarding and saving
61+
*
5562
* @var bool
5663
*/
57-
public $allow_sending_without_reply = false;
64+
public $protect_content = false;
5865

5966
/**
6067
* Optional. If the message is a reply, ID of the original message
6168
* @var int
6269
*/
6370
public $reply_to_message_id = 0;
6471

72+
/**
73+
* Optional. Pass True if the message should be sent even if the specified replied-to message is not found
74+
* @var bool
75+
*/
76+
public $allow_sending_without_reply = false;
77+
6578
/**
6679
* Optional. Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to
6780
* hide keyboard or to force a reply from the user

src/Telegram/Methods/SendVideo.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ class SendVideo extends TelegramMethods
5757
*
5858
* @var InputFile
5959
*/
60+
public $thumbnail;
61+
62+
/**
63+
* @deprecated Use $thumbnail instead (Bot API 6.6, March 9, 2023 https://core.telegram.org/bots/api-changelog#march-9-2023)
64+
* @var InputFile
65+
*/
6066
public $thumb;
6167

6268
/**
Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,13 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
namespace unreal4u\TelegramAPI\Telegram\Methods;
66

7-
use Generator;
8-
use Psr\Log\LoggerInterface;
9-
use unreal4u\TelegramAPI\Abstracts\TelegramMethods;
10-
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
11-
use unreal4u\TelegramAPI\InternalFunctionality\TelegramResponse;
12-
use unreal4u\TelegramAPI\Telegram\Types\Custom\InputFile;
13-
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean;
14-
157
/**
16-
* Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only.
17-
* Returns True on success.
18-
*
19-
* Objects defined as-is June 2020, Bot API v4.9
20-
*
21-
* @see https://core.telegram.org/bots/api#setstickersetthumb
8+
* @deprecated Use directly SetStickerSetThumbnail instead (Bot API 6.6, March 9, 2023)
9+
* @see https://core.telegram.org/bots/api-changelog#march-9-2023
2210
*/
23-
class SetStickerSetThumb extends TelegramMethods
11+
class SetStickerSetThumb extends SetStickerSetThumbnail
2412
{
25-
/**
26-
* Sticker set name
27-
* @var string
28-
*/
29-
public $name;
30-
31-
/**
32-
* User identifier of the sticker set owner
33-
* @var int
34-
*/
35-
public $user_id;
36-
37-
/**
38-
* A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a
39-
* TGS animation with the thumbnail up to 32 kilobytes in size; see
40-
* https://core.telegram.org/animated_stickers#technical-requirements for animated sticker technical requirements.
41-
* Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a
42-
* String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on
43-
* Sending Files ». Animated sticker set thumbnail can't be uploaded via HTTP URL.
44-
*
45-
* @var InputFile|string
46-
*/
47-
public $thumb;
48-
49-
public static function bindToObject(TelegramResponse $data, LoggerInterface $logger): TelegramTypes
50-
{
51-
return new ResultBoolean($data->getResultBoolean(), $logger);
52-
}
53-
54-
public function getMandatoryFields(): array
55-
{
56-
return [
57-
'name',
58-
'user_id',
59-
];
60-
}
61-
62-
public function hasLocalFiles(): bool
63-
{
64-
return $this->thumb instanceof InputFile;
65-
}
66-
67-
public function getLocalFiles(): Generator
68-
{
69-
yield 'thumb' => $this->thumb;
70-
}
7113
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace unreal4u\TelegramAPI\Telegram\Methods;
6+
7+
use Generator;
8+
use Psr\Log\LoggerInterface;
9+
use unreal4u\TelegramAPI\Abstracts\TelegramMethods;
10+
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
11+
use unreal4u\TelegramAPI\InternalFunctionality\TelegramResponse;
12+
use unreal4u\TelegramAPI\Telegram\Types\Custom\InputFile;
13+
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean;
14+
15+
/**
16+
* Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only.
17+
* Returns True on success.
18+
*
19+
* Objects defined as-is June 2020, Bot API v4.9
20+
*
21+
* @see https://core.telegram.org/bots/api#setstickersetthumb
22+
*/
23+
class SetStickerSetThumbnail extends TelegramMethods
24+
{
25+
/**
26+
* Sticker set name
27+
* @var string
28+
*/
29+
public $name;
30+
31+
/**
32+
* User identifier of the sticker set owner
33+
* @var int
34+
*/
35+
public $user_id;
36+
37+
/**
38+
* A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a
39+
* TGS animation with the thumbnail up to 32 kilobytes in size; see
40+
* https://core.telegram.org/animated_stickers#technical-requirements for animated sticker technical requirements.
41+
* Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a
42+
* String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on
43+
* Sending Files ». Animated sticker set thumbnail can't be uploaded via HTTP URL.
44+
*
45+
* @var InputFile|string
46+
*/
47+
public $thumbnail;
48+
49+
/**
50+
* @deprecated Use $thumbnail instead (Bot API 6.6, March 9, 2023 https://core.telegram.org/bots/api-changelog#march-9-2023)
51+
* @var InputFile|string
52+
*/
53+
public $thumb;
54+
55+
public static function bindToObject(TelegramResponse $data, LoggerInterface $logger): TelegramTypes
56+
{
57+
return new ResultBoolean($data->getResultBoolean(), $logger);
58+
}
59+
60+
public function getMandatoryFields(): array
61+
{
62+
return [
63+
'name',
64+
'user_id',
65+
];
66+
}
67+
68+
public function hasLocalFiles(): bool
69+
{
70+
return $this->thumbnail instanceof InputFile || $this->thumb instanceof InputFile;
71+
}
72+
73+
public function getLocalFiles(): Generator
74+
{
75+
yield from [
76+
'thumbnail' => $this->thumbnail,
77+
'thumb' => $this->thumb,
78+
];
79+
}
80+
}

src/Telegram/Types/Animation.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ class Animation extends TelegramTypes
5151
* Optional. Animation thumbnail as defined by sender
5252
* @var PhotoSize
5353
*/
54+
public $thumbnail;
55+
56+
/**
57+
* @deprecated Use $thumbnail instead (Bot API 6.6, March 9, 2023 https://core.telegram.org/bots/api-changelog#march-9-2023)
58+
* @var PhotoSize
59+
*/
5460
public $thumb;
5561

5662
/**
@@ -74,6 +80,7 @@ class Animation extends TelegramTypes
7480
protected function mapSubObjects(string $key, array $data): TelegramTypes
7581
{
7682
switch ($key) {
83+
case 'thumbnail':
7784
case 'thumb':
7885
return new PhotoSize($data, $this->logger);
7986
}

0 commit comments

Comments
 (0)