Skip to content

Bot API 4.0 - NO Telegram Passport #870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
Exclamation symbols (:exclamation:) note something of importance e.g. breaking changes. Click them to learn more.

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

[unreleased-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.54.0-unreleased.sql
[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
[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
[0.54.0-bc-rename-constants]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#rename-constants
[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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ $result = Request::sendPhoto([
]);
```

*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.
*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.
See the [*ImageCommand.php*][ImageCommand.php] for a full example.

#### Send Chat Action
Expand Down
5 changes: 3 additions & 2 deletions src/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -829,15 +829,15 @@ public static function insertMessageRequest(Message $message)
(
`id`, `user_id`, `chat_id`, `date`, `forward_from`, `forward_from_chat`, `forward_from_message_id`,
`forward_date`, `reply_to_chat`, `reply_to_message`, `media_group_id`, `text`, `entities`, `audio`, `document`,
`game`, `photo`, `sticker`, `video`, `voice`, `video_note`, `caption`, `contact`,
`animation`, `game`, `photo`, `sticker`, `video`, `voice`, `video_note`, `caption`, `contact`,
`location`, `venue`, `new_chat_members`, `left_chat_member`,
`new_chat_title`,`new_chat_photo`, `delete_chat_photo`, `group_chat_created`,
`supergroup_chat_created`, `channel_chat_created`,
`migrate_from_chat_id`, `migrate_to_chat_id`, `pinned_message`, `connected_website`
) VALUES (
:message_id, :user_id, :chat_id, :date, :forward_from, :forward_from_chat, :forward_from_message_id,
:forward_date, :reply_to_chat, :reply_to_message, :media_group_id, :text, :entities, :audio, :document,
:game, :photo, :sticker, :video, :voice, :video_note, :caption, :contact,
:animation, :game, :photo, :sticker, :video, :voice, :video_note, :caption, :contact,
:location, :venue, :new_chat_members, :left_chat_member,
:new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created,
:supergroup_chat_created, :channel_chat_created,
Expand Down Expand Up @@ -881,6 +881,7 @@ public static function insertMessageRequest(Message $message)
$sth->bindValue(':entities', $t = self::entitiesArrayToJson($message->getEntities(), null));
$sth->bindValue(':audio', $message->getAudio());
$sth->bindValue(':document', $message->getDocument());
$sth->bindValue(':animation', $message->getAnimation());
$sth->bindValue(':game', $message->getGame());
$sth->bindValue(':photo', $t = self::entitiesArrayToJson($message->getPhoto(), null));
$sth->bindValue(':sticker', $message->getSticker());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot\Entities\Games;

use Longman\TelegramBot\Entities\Entity;
namespace Longman\TelegramBot\Entities;

/**
* Class Animation
Expand All @@ -20,6 +18,9 @@
* @link https://core.telegram.org/bots/api#animation
*
* @method string getFileId() Unique file identifier
* @method int getWidth() Video width as defined by sender
* @method int getHeight() Video height as defined by sender
* @method int getDuration() Duration of the video in seconds as defined by sender
* @method PhotoSize getThumb() Optional. Animation thumbnail as defined by sender
* @method string getFileName() Optional. Original animation filename as defined by sender
* @method string getMimeType() Optional. MIME type of the file as defined by sender
Expand Down
23 changes: 16 additions & 7 deletions src/Entities/Audio.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,23 @@
*
* @link https://core.telegram.org/bots/api#audio
*
* @method string getFileId() Unique identifier for this file
* @method int getDuration() Duration of the audio in seconds as defined by sender
* @method string getPerformer() Optional. Performer of the audio as defined by sender or by audio tags
* @method string getTitle() Optional. Title of the audio as defined by sender or by audio tags
* @method string getMimeType() Optional. MIME type of the file as defined by sender
* @method int getFileSize() Optional. File size
* @method string getFileId() Unique identifier for this file
* @method int getDuration() Duration of the audio in seconds as defined by sender
* @method string getPerformer() Optional. Performer of the audio as defined by sender or by audio tags
* @method string getTitle() Optional. Title of the audio as defined by sender or by audio tags
* @method string getMimeType() Optional. MIME type of the file as defined by sender
* @method int getFileSize() Optional. File size
* @method PhotoSize getThumb() Optional. Thumbnail of the album cover to which the music file belongs
*/
class Audio extends Entity
{

/**
* {@inheritdoc}
*/
protected function subEntities()
{
return [
'thumb' => PhotoSize::class,
];
}
}
1 change: 1 addition & 0 deletions src/Entities/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @method string getFirstName() Contact's first name
* @method string getLastName() Optional. Contact's last name
* @method int getUserId() Optional. Contact's user identifier in Telegram
* @method string getVcard() Optional. Additional data about the contact in the form of a vCard
*/
class Contact extends Entity
{
Expand Down
2 changes: 2 additions & 0 deletions src/Entities/InlineQuery/InlineQueryResultContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* @method string getPhoneNumber() Contact's phone number
* @method string getFirstName() Contact's first name
* @method string getLastName() Optional. Contact's last name
* @method string getVcard() Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes
* @method InlineKeyboard getReplyMarkup() Optional. Inline keyboard attached to the message
* @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the contact
* @method string getThumbUrl() Optional. Url of the thumbnail for the result
Expand All @@ -47,6 +48,7 @@
* @method $this setPhoneNumber(string $phone_number) Contact's phone number
* @method $this setFirstName(string $first_name) Contact's first name
* @method $this setLastName(string $last_name) Optional. Contact's last name
* @method $this setVcard(string $vcard) Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes
* @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. Inline keyboard attached to the message
* @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the contact
* @method $this setThumbUrl(string $thumb_url) Optional. Url of the thumbnail for the result
Expand Down
2 changes: 2 additions & 0 deletions src/Entities/InlineQuery/InlineQueryResultVenue.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* @method string getTitle() Title of the venue
* @method string getAddress() Address of the venue
* @method string getFoursquareId() Optional. Foursquare identifier of the venue if known
* @method string getFoursquareType() Optional. Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
* @method InlineKeyboard getReplyMarkup() Optional. Inline keyboard attached to the message
* @method InputMessageContent getInputMessageContent() Optional. Content of the message to be sent instead of the venue
* @method string getThumbUrl() Optional. Url of the thumbnail for the result
Expand All @@ -53,6 +54,7 @@
* @method $this setTitle(string $title) Title of the venue
* @method $this setAddress(string $address) Address of the venue
* @method $this setFoursquareId(string $foursquare_id) Optional. Foursquare identifier of the venue if known
* @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”.)
* @method $this setReplyMarkup(InlineKeyboard $reply_markup) Optional. Inline keyboard attached to the message
* @method $this setInputMessageContent(InputMessageContent $input_message_content) Optional. Content of the message to be sent instead of the venue
* @method $this setThumbUrl(string $thumb_url) Optional. Url of the thumbnail for the result
Expand Down
63 changes: 63 additions & 0 deletions src/Entities/InputMedia/InputMediaAnimation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot\Entities\InputMedia;

use Longman\TelegramBot\Entities\Entity;

/**
* Class InputMediaAnimation
*
* @link https://core.telegram.org/bots/api#inputmediaanimation
*
* <code>
* $data = [
* 'media' => '123abc',
* 'thumb' => '456def',
* 'caption' => '*Animation* caption',
* 'parse_mode' => 'markdown',
* 'width' => 200,
* 'height' => 150,
* 'duration' => 11,
* ];
* </code>
*
* @method string getType() Type of the result, must be animation
* @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 »
* @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 »
* @method string getCaption() Optional. Caption of the animation to be sent, 0-200 characters
* @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.
* @method int getWidth() Optional. Animation width
* @method int getHeight() Optional. Animation height
* @method int getDuration() Optional. Animation duration
*
* @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 »
* @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 »
* @method $this setCaption(string $caption) Optional. Caption of the animation to be sent, 0-200 characters
* @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.
* @method $this setWidth(int $width) Optional. Animation width
* @method $this setHeight(int $height) Optional. Animation height
* @method $this setDuration(int $duration) Optional. Animation duration
*/
class InputMediaAnimation extends Entity implements InputMedia
{
/**
* InputMediaAnimation constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'animation';
parent::__construct($data);
}
}
63 changes: 63 additions & 0 deletions src/Entities/InputMedia/InputMediaAudio.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Longman\TelegramBot\Entities\InputMedia;

use Longman\TelegramBot\Entities\Entity;

/**
* Class InputMediaAudio
*
* @link https://core.telegram.org/bots/api#inputmediaaudio
*
* <code>
* $data = [
* 'media' => '123abc',
* 'thumb' => '456def',
* 'caption' => '*Audio* caption',
* 'parse_mode' => 'markdown',
* 'duration' => 42,
* 'performer' => 'John Doe',
* 'title' => 'The Song',
* ];
* </code>
*
* @method string getType() Type of the result, must be audio
* @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.
* @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 »
* @method string getCaption() Optional. Caption of the audio to be sent, 0-200 characters
* @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.
* @method int getDuration() Optional. Duration of the audio in seconds
* @method string getPerformer() Optional. Performer of the audio
* @method string getTitle() Optional. Title of the audio
*
* @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.
* @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 »
* @method $this setCaption(string $caption) Optional. Caption of the audio to be sent, 0-200 characters
* @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.
* @method $this setDuration(int $duration) Optional. Duration of the audio in seconds
* @method $this setPerformer(string $performer) Optional. Performer of the audio
* @method $this setTitle(string $title) Optional. Title of the audio
*/
class InputMediaAudio extends Entity implements InputMedia
{
/**
* InputMediaAudio constructor
*
* @param array $data
*
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function __construct(array $data = [])
{
$data['type'] = 'audio';
parent::__construct($data);
}
}
Loading