Skip to content

Commit ec49055

Browse files
authored
Merge pull request #870 from noplanman/bot_api_4.0_no_passport
Bot API 4.0 - NO Telegram Passport
2 parents 9a59c01 + 1ecb49a commit ec49055

21 files changed

+268
-42
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
44
Exclamation symbols (:exclamation:) note something of importance e.g. breaking changes. Click them to learn more.
55

66
## [Unreleased]
7+
:exclamation: After updating to this version, you will need to execute the [SQL migration script][unreleased-sql-migration] on your database.
78
### Added
9+
- Bot API 4.0 (without Passport)
810
### Changed
11+
- [:exclamation:][unreleased-bc-move-animation-out-of-games-namespace] Move Animation entity out of Games namespace.
912
### Deprecated
1013
### Removed
1114
### Fixed
@@ -213,6 +216,8 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
213216
### Deprecated
214217
- Move `hideKeyboard` to `removeKeyboard`.
215218

219+
[unreleased-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.54.0-unreleased.sql
220+
[unreleased-bc-move-animation-out-of-games-namespace]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#move-animation-out-of-games-namespace
216221
[0.54.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.53.0-0.54.0.sql
217222
[0.54.0-bc-rename-constants]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#rename-constants
218223
[0.53.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.52.0-0.53.0.sql

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ $result = Request::sendPhoto([
364364
]);
365365
```
366366

367-
*sendAudio*, *sendDocument*, *sendSticker*, *sendVideo*, *sendVoice* and *sendVideoNote* all work in the same way, just check the [API documentation](https://core.telegram.org/bots/api#sendphoto) for the exact usage.
367+
*sendAudio*, *sendDocument*, *sendAnimation*, *sendSticker*, *sendVideo*, *sendVoice* and *sendVideoNote* all work in the same way, just check the [API documentation](https://core.telegram.org/bots/api#sendphoto) for the exact usage.
368368
See the [*ImageCommand.php*][ImageCommand.php] for a full example.
369369

370370
#### Send Chat Action

src/DB.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,15 +829,15 @@ public static function insertMessageRequest(Message $message)
829829
(
830830
`id`, `user_id`, `chat_id`, `date`, `forward_from`, `forward_from_chat`, `forward_from_message_id`,
831831
`forward_date`, `reply_to_chat`, `reply_to_message`, `media_group_id`, `text`, `entities`, `audio`, `document`,
832-
`game`, `photo`, `sticker`, `video`, `voice`, `video_note`, `caption`, `contact`,
832+
`animation`, `game`, `photo`, `sticker`, `video`, `voice`, `video_note`, `caption`, `contact`,
833833
`location`, `venue`, `new_chat_members`, `left_chat_member`,
834834
`new_chat_title`,`new_chat_photo`, `delete_chat_photo`, `group_chat_created`,
835835
`supergroup_chat_created`, `channel_chat_created`,
836836
`migrate_from_chat_id`, `migrate_to_chat_id`, `pinned_message`, `connected_website`
837837
) VALUES (
838838
:message_id, :user_id, :chat_id, :date, :forward_from, :forward_from_chat, :forward_from_message_id,
839839
:forward_date, :reply_to_chat, :reply_to_message, :media_group_id, :text, :entities, :audio, :document,
840-
:game, :photo, :sticker, :video, :voice, :video_note, :caption, :contact,
840+
:animation, :game, :photo, :sticker, :video, :voice, :video_note, :caption, :contact,
841841
:location, :venue, :new_chat_members, :left_chat_member,
842842
:new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created,
843843
:supergroup_chat_created, :channel_chat_created,
@@ -881,6 +881,7 @@ public static function insertMessageRequest(Message $message)
881881
$sth->bindValue(':entities', $t = self::entitiesArrayToJson($message->getEntities(), null));
882882
$sth->bindValue(':audio', $message->getAudio());
883883
$sth->bindValue(':document', $message->getDocument());
884+
$sth->bindValue(':animation', $message->getAnimation());
884885
$sth->bindValue(':game', $message->getGame());
885886
$sth->bindValue(':photo', $t = self::entitiesArrayToJson($message->getPhoto(), null));
886887
$sth->bindValue(':sticker', $message->getSticker());

src/Entities/Games/Animation.php renamed to src/Entities/Animation.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
* file that was distributed with this source code.
99
*/
1010

11-
namespace Longman\TelegramBot\Entities\Games;
12-
13-
use Longman\TelegramBot\Entities\Entity;
11+
namespace Longman\TelegramBot\Entities;
1412

1513
/**
1614
* Class Animation
@@ -20,6 +18,9 @@
2018
* @link https://core.telegram.org/bots/api#animation
2119
*
2220
* @method string getFileId() Unique file identifier
21+
* @method int getWidth() Video width as defined by sender
22+
* @method int getHeight() Video height as defined by sender
23+
* @method int getDuration() Duration of the video in seconds as defined by sender
2324
* @method PhotoSize getThumb() Optional. Animation thumbnail as defined by sender
2425
* @method string getFileName() Optional. Original animation filename as defined by sender
2526
* @method string getMimeType() Optional. MIME type of the file as defined by sender

src/Entities/Audio.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,23 @@
1515
*
1616
* @link https://core.telegram.org/bots/api#audio
1717
*
18-
* @method string getFileId() Unique identifier for this file
19-
* @method int getDuration() Duration of the audio in seconds as defined by sender
20-
* @method string getPerformer() Optional. Performer of the audio as defined by sender or by audio tags
21-
* @method string getTitle() Optional. Title of the audio as defined by sender or by audio tags
22-
* @method string getMimeType() Optional. MIME type of the file as defined by sender
23-
* @method int getFileSize() Optional. File size
18+
* @method string getFileId() Unique identifier for this file
19+
* @method int getDuration() Duration of the audio in seconds as defined by sender
20+
* @method string getPerformer() Optional. Performer of the audio as defined by sender or by audio tags
21+
* @method string getTitle() Optional. Title of the audio as defined by sender or by audio tags
22+
* @method string getMimeType() Optional. MIME type of the file as defined by sender
23+
* @method int getFileSize() Optional. File size
24+
* @method PhotoSize getThumb() Optional. Thumbnail of the album cover to which the music file belongs
2425
*/
2526
class Audio extends Entity
2627
{
27-
28+
/**
29+
* {@inheritdoc}
30+
*/
31+
protected function subEntities()
32+
{
33+
return [
34+
'thumb' => PhotoSize::class,
35+
];
36+
}
2837
}

src/Entities/Contact.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* @method string getFirstName() Contact's first name
2020
* @method string getLastName() Optional. Contact's last name
2121
* @method int getUserId() Optional. Contact's user identifier in Telegram
22+
* @method string getVcard() Optional. Additional data about the contact in the form of a vCard
2223
*/
2324
class Contact extends Entity
2425
{

src/Entities/InlineQuery/InlineQueryResultContact.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
* @method string getPhoneNumber() Contact's phone number
3838
* @method string getFirstName() Contact's first name
3939
* @method string getLastName() Optional. Contact's last name
40+
* @method string getVcard() Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes
4041
* @method InlineKeyboard getReplyMarkup() Optional. Inline keyboard attached to the message
4142
* @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the contact
4243
* @method string getThumbUrl() Optional. Url of the thumbnail for the result
@@ -47,6 +48,7 @@
4748
* @method $this setPhoneNumber(string $phone_number) Contact's phone number
4849
* @method $this setFirstName(string $first_name) Contact's first name
4950
* @method $this setLastName(string $last_name) Optional. Contact's last name
51+
* @method $this setVcard(string $vcard) Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes
5052
* @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. Inline keyboard attached to the message
5153
* @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the contact
5254
* @method $this setThumbUrl(string $thumb_url) Optional. Url of the thumbnail for the result

src/Entities/InlineQuery/InlineQueryResultVenue.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
* @method string getTitle() Title of the venue
4242
* @method string getAddress() Address of the venue
4343
* @method string getFoursquareId() Optional. Foursquare identifier of the venue if known
44+
* @method string getFoursquareType() Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
4445
* @method InlineKeyboard getReplyMarkup() Optional. Inline keyboard attached to the message
4546
* @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the venue
4647
* @method string getThumbUrl() Optional. Url of the thumbnail for the result
@@ -53,6 +54,7 @@
5354
* @method $this setTitle(string $title) Title of the venue
5455
* @method $this setAddress(string $address) Address of the venue
5556
* @method $this setFoursquareId(string $foursquare_id) Optional. Foursquare identifier of the venue if known
57+
* @method $this setFoursquareType(string $foursquare_type) Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
5658
* @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. Inline keyboard attached to the message
5759
* @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the venue
5860
* @method $this setThumbUrl(string $thumb_url) Optional. Url of the thumbnail for the result
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 <[email protected]>
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 <[email protected]>
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+
}

0 commit comments

Comments
 (0)