Skip to content

Bot API 6.4-6.7 #1389

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 7 commits into from
Apr 26, 2023
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c

## [Unreleased]
### Notes
- [:ledger: View file changes][Unreleased]
- [:ledger: View file changes][Unreleased] ∙ [:page_with_curl: DB migration script][unreleased-sql-migration]
### Added
- Added AllowDynamicProperties attribute to Entities to support newer PHP versions (@alesinicio) (#1388)
- Bot API 6.4, 6.5, 6.6, 6.7 (@noplanman)
### Changed
### Deprecated
### Removed
Expand Down Expand Up @@ -613,6 +614,7 @@ 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.80.0-unreleased.sql
[0.80.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.79.0-0.80.0.sql
[0.80.0-bc-commands-with-underscores]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#commands-with-underscores
[0.78.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.77.1-0.78.0.sql
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

A Telegram Bot based on the official [Telegram Bot API]

[![API Version](https://img.shields.io/badge/Bot%20API-6.3%20%28November%202022%29-32a2da.svg)](https://core.telegram.org/bots/api#november-5-2022)
[![API Version](https://img.shields.io/badge/Bot%20API-6.7%20%28April%202023%29-32a2da.svg)](https://core.telegram.org/bots/api-changelog#april-21-2023)
[![Join the bot support group on Telegram](https://img.shields.io/badge/telegram-@PHP__Telegram__Bot__Support-64659d.svg)](https://telegram.me/PHP_Telegram_Bot_Support)
[![Donate](https://img.shields.io/badge/%F0%9F%92%99-Donate%20%2F%20Support%20Us-blue.svg)](#donate)

Expand Down Expand Up @@ -78,7 +78,7 @@ This Bot aims to provide a platform where one can simply write a bot and have in

The Bot can:
- Retrieve updates with [webhook](#webhook-installation) and [getUpdates](#getupdates-installation) methods.
- Supports all types and methods according to Telegram Bot API 6.3 (November 2022).
- Supports all types and methods according to Telegram Bot API 6.7 (April 2023).
- Supports supergroups.
- Handle commands in chat with other bots.
- Manage Channel from the bot admin interface.
Expand Down Expand Up @@ -389,15 +389,15 @@ The reason for denying an update can be defined with the `$reason` parameter. Th

### Types

All types are implemented according to Telegram API 6.3 (November 2022).
All types are implemented according to Telegram API 6.7 (April 2023).

### Inline Query

Full support for inline query according to Telegram API 6.3 (November 2022).
Full support for inline query according to Telegram API 6.7 (April 2023).

### Methods

All methods are implemented according to Telegram API 6.3 (November 2022).
All methods are implemented according to Telegram API 6.7 (April 2023).

#### Send Message

Expand Down
19 changes: 13 additions & 6 deletions src/DB.php
Original file line number Diff line number Diff line change
Expand Up @@ -1136,23 +1136,23 @@ public static function insertMessageRequest(Message $message): bool
`id`, `user_id`, `chat_id`, `message_thread_id`, `sender_chat_id`, `date`, `forward_from`, `forward_from_chat`, `forward_from_message_id`,
`forward_signature`, `forward_sender_name`, `forward_date`, `is_topic_message`,
`reply_to_chat`, `reply_to_message`, `via_bot`, `edit_date`, `media_group_id`, `author_signature`, `text`, `entities`, `caption_entities`,
`audio`, `document`, `animation`, `game`, `photo`, `sticker`, `video`, `voice`, `video_note`, `caption`, `contact`,
`audio`, `document`, `animation`, `game`, `photo`, `sticker`, `video`, `voice`, `video_note`, `caption`, `has_media_spoiler`, `contact`,
`location`, `venue`, `poll`, `dice`, `new_chat_members`, `left_chat_member`,
`new_chat_title`, `new_chat_photo`, `delete_chat_photo`, `group_chat_created`,
`supergroup_chat_created`, `channel_chat_created`, `message_auto_delete_timer_changed`, `migrate_to_chat_id`, `migrate_from_chat_id`,
`pinned_message`, `invoice`, `successful_payment`, `connected_website`, `passport_data`, `proximity_alert_triggered`,
`forum_topic_created`, `forum_topic_closed`, `forum_topic_reopened`,
`pinned_message`, `invoice`, `successful_payment`, `user_shared`, `chat_shared`, `connected_website`, `write_access_allowed`, `passport_data`, `proximity_alert_triggered`,
`forum_topic_created`, `forum_topic_edited`, `forum_topic_closed`, `forum_topic_reopened`, `general_forum_topic_hidden`, `general_forum_topic_unhidden`,
`video_chat_scheduled`, `video_chat_started`, `video_chat_ended`, `video_chat_participants_invited`, `web_app_data`, `reply_markup`
) VALUES (
:message_id, :user_id, :chat_id, :message_thread_id, :sender_chat_id, :date, :forward_from, :forward_from_chat, :forward_from_message_id,
:forward_signature, :forward_sender_name, :forward_date, :is_topic_message,
:reply_to_chat, :reply_to_message, :via_bot, :edit_date, :media_group_id, :author_signature, :text, :entities, :caption_entities,
:audio, :document, :animation, :game, :photo, :sticker, :video, :voice, :video_note, :caption, :contact,
:audio, :document, :animation, :game, :photo, :sticker, :video, :voice, :video_note, :caption, :has_media_spoiler, :contact,
:location, :venue, :poll, :dice, :new_chat_members, :left_chat_member,
:new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created,
:supergroup_chat_created, :channel_chat_created, :message_auto_delete_timer_changed, :migrate_to_chat_id, :migrate_from_chat_id,
:pinned_message, :invoice, :successful_payment, :connected_website, :passport_data, :proximity_alert_triggered,
:forum_topic_created, :forum_topic_closed, :forum_topic_reopened,
:pinned_message, :invoice, :successful_payment, :user_shared, :chat_shared, :connected_website, :write_access_allowed, :passport_data, :proximity_alert_triggered,
:forum_topic_created, :forum_topic_edited, :forum_topic_closed, :forum_topic_reopened, :general_forum_topic_hidden, :general_forum_topic_unhidden,
:video_chat_scheduled, :video_chat_started, :video_chat_ended, :video_chat_participants_invited, :web_app_data, :reply_markup
)
');
Expand Down Expand Up @@ -1206,6 +1206,7 @@ public static function insertMessageRequest(Message $message): bool
$sth->bindValue(':voice', $message->getVoice());
$sth->bindValue(':video_note', $message->getVideoNote());
$sth->bindValue(':caption', $message->getCaption());
$sth->bindValue(':has_media_spoiler', $message->getHasMediaSpoiler());
$sth->bindValue(':contact', $message->getContact());
$sth->bindValue(':location', $message->getLocation());
$sth->bindValue(':venue', $message->getVenue());
Expand All @@ -1225,12 +1226,18 @@ public static function insertMessageRequest(Message $message): bool
$sth->bindValue(':pinned_message', $message->getPinnedMessage());
$sth->bindValue(':invoice', $message->getInvoice());
$sth->bindValue(':successful_payment', $message->getSuccessfulPayment());
$sth->bindValue(':user_shared', $message->getUserShared());
$sth->bindValue(':chat_shared', $message->getChatShared());
$sth->bindValue(':connected_website', $message->getConnectedWebsite());
$sth->bindValue(':write_access_allowed', $message->getWriteAccessAllowed());
$sth->bindValue(':passport_data', $message->getPassportData());
$sth->bindValue(':proximity_alert_triggered', $message->getProximityAlertTriggered());
$sth->bindValue(':forum_topic_created', $message->getForumTopicCreated());
$sth->bindValue(':forum_topic_edited', $message->getForumTopicEdited());
$sth->bindValue(':forum_topic_closed', $message->getForumTopicClosed());
$sth->bindValue(':forum_topic_reopened', $message->getForumTopicReopened());
$sth->bindValue(':general_forum_topic_hidden', $message->getGeneralForumTopicHidden());
$sth->bindValue(':general_forum_topic_unhidden', $message->getGeneralForumTopicUnhidden());
$sth->bindValue(':video_chat_scheduled', $message->getVideoChatScheduled());
$sth->bindValue(':video_chat_started', $message->getVideoChatStarted());
$sth->bindValue(':video_chat_ended', $message->getVideoChatEnded());
Expand Down
4 changes: 2 additions & 2 deletions src/Entities/Animation.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @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 PhotoSize getThumbnail() 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
* @method int getFileSize() Optional. File size
Expand All @@ -36,7 +36,7 @@ class Animation extends Entity
protected function subEntities(): array
{
return [
'thumb' => PhotoSize::class,
'thumbnail' => PhotoSize::class,
];
}
}
4 changes: 2 additions & 2 deletions src/Entities/Audio.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @method string getFileName() Optional. Original filename as defined by sender
* @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
* @method PhotoSize getThumbnail() Optional. Thumbnail of the album cover to which the music file belongs
*/
class Audio extends Entity
{
Expand All @@ -34,7 +34,7 @@ class Audio extends Entity
protected function subEntities(): array
{
return [
'thumb' => PhotoSize::class,
'thumbnail' => PhotoSize::class,
];
}
}
17 changes: 17 additions & 0 deletions src/Entities/BotDescription.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Longman\TelegramBot\Entities;

/**
* Class BotDescription
*
* This entity represents the bot's description.
*
* @link https://core.telegram.org/bots/api#botdescription
*
* @method string getDescription() The bot's description.
*/
class BotDescription extends Entity
{

}
17 changes: 17 additions & 0 deletions src/Entities/BotName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Longman\TelegramBot\Entities;

/**
* Class BotName
*
* This object represents the bot's name.
*
* @link https://core.telegram.org/bots/api#botname
*
* @method string getName() The bot's name.
*/
class BotName extends Entity
{

}
17 changes: 17 additions & 0 deletions src/Entities/BotShortDescription.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Longman\TelegramBot\Entities;

/**
* Class BotShortDescription
*
* This entity represents the bot's short description.
*
* @link https://core.telegram.org/bots/api#botshortdescription
*
* @method string getShortDescription() The bot's short description
*/
class BotShortDescription extends Entity
{

}
2 changes: 2 additions & 0 deletions src/Entities/Chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
* @method ChatPermissions getPermissions() Optional. Default chat member permissions, for groups and supergroups. Returned only in getChat.
* @method int getSlowModeDelay() Optional. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user. Returned only in getChat.
* @method int getMessageAutoDeleteTime() Optional. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat.
* @method bool getHasAggressiveAntiSpamEnabled() Optional. True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. Returned only in getChat.
* @method bool getHasHiddenMembers() Optional. True, if non-administrators can only get the list of bots and administrators in the chat. Returned only in getChat.
* @method bool getHasProtectedContent() Optional. True, if messages from the chat can't be forwarded to other chats. Returned only in getChat.
* @method string getStickerSetName() Optional. For supergroups, name of group sticker set. Returned only in getChat.
* @method bool getCanSetStickerSet() Optional. True, if the bot can change the group sticker set. Returned only in getChat.
Expand Down
1 change: 1 addition & 0 deletions src/Entities/ChatJoinRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*
* @method Chat getChat() Chat to which the request was sent
* @method User getFrom() User that sent the join request
* @method int getUserChatId() Identifier of a private chat with the user who sent the join request.
* @method int getDate() Date the request was sent in Unix time
* @method string getBio() Optional. Bio of the user.
* @method ChatInviteLink getInviteLink() Optional. Chat invite link that was used by the user to send the join request
Expand Down
24 changes: 23 additions & 1 deletion src/Entities/ChatMember/ChatMemberRestricted.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
* @method bool getCanPinMessages() True, if the user is allowed to pin messages; groups and supergroups only
* @method bool getCanManageTopics() True, if the user is allowed to create forum topics
* @method bool getCanSendMessages() True, if the user is allowed to send text messages, contacts, locations and venues
* @method bool getCanSendMediaMessages() True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes
* @method bool getCanSendAudios() True, if the user is allowed to send audios
* @method bool getCanSendDocuments() True, if the user is allowed to send documents
* @method bool getCanSendPhotos() True, if the user is allowed to send photos
* @method bool getCanSendVideos() True, if the user is allowed to send videos
* @method bool getCanSendVideoNotes() True, if the user is allowed to send video notes
* @method bool getCanSendVoiceNotes() True, if the user is allowed to send voice notes
* @method bool getCanSendPolls() True, if the user is allowed to send polls
* @method bool getCanSendOtherMessages() True, if the user is allowed to send animations, games, stickers and use inline bots
* @method bool getCanAddWebPagePreviews() True, if the user is allowed to add web page previews to their messages
Expand All @@ -35,4 +40,21 @@ protected function subEntities(): array
'user' => User::class,
];
}

/**
* True, if the user is allowed to send audios, documents, photos, videos, video notes OR voice notes
*
* @deprecated Use new fine-grained methods provided by Telegram Bot API.
*
* @return bool
*/
public function getCanSendMediaMessages(): bool
{
return $this->getCanSendAudios() ||
$this->getCanSendDocuments() ||
$this->getCanSendPhotos() ||
$this->getCanSendVideos() ||
$this->getCanSendVideoNotes() ||
$this->getCanSendVoiceNotes();
}
}
1 change: 1 addition & 0 deletions src/Entities/ChatMemberUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* @method ChatMember getOldChatMember() Previous information about the chat member
* @method ChatMember getNewChatMember() New information about the chat member
* @method ChatInviteLink getInviteLink() Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only.
* @method bool getViaChatFolderInviteLink() Optional. True, if the user joined the chat via a chat folder invite link
*/
class ChatMemberUpdated extends Entity
{
Expand Down
24 changes: 22 additions & 2 deletions src/Entities/ChatPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
* @link https://core.telegram.org/bots/api#chatpermissions
*
* @method bool getCanSendMessages() Optional. True, if the user is allowed to send text messages, contacts, locations and venues
* @method bool getCanSendMediaMessages() Optional. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
* @method bool getCanSendAudios() Optional. True, if the user is allowed to send audios
* @method bool getCanSendDocuments() Optional. True, if the user is allowed to send documents
* @method bool getCanSendPhotos() Optional. True, if the user is allowed to send photos
* @method bool getCanSendVideos() Optional. True, if the user is allowed to send videos
* @method bool getCanSendVideoNotes() Optional. True, if the user is allowed to send video notes
* @method bool getCanSendVoiceNotes() Optional. True, if the user is allowed to send voice notes
* @method bool getCanSendPolls() Optional. True, if the user is allowed to send polls, implies can_send_messages
* @method bool getCanSendOtherMessages() Optional. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages
* @method bool getCanAddWebPagePreviews() Optional. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages
Expand All @@ -28,5 +33,20 @@
*/
class ChatPermissions extends Entity
{

/**
* True, if the user is allowed to send audios, documents, photos, videos, video notes OR voice notes
*
* @deprecated Use new fine-grained methods provided by Telegram Bot API.
*
* @return bool
*/
public function getCanSendMediaMessages(): bool
{
return $this->getCanSendAudios() ||
$this->getCanSendDocuments() ||
$this->getCanSendPhotos() ||
$this->getCanSendVideos() ||
$this->getCanSendVideoNotes() ||
$this->getCanSendVoiceNotes();
}
}
18 changes: 18 additions & 0 deletions src/Entities/ChatShared.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Longman\TelegramBot\Entities;

/**
* Class ChatShared
*
* This object contains information about the chat whose identifier was shared with the bot using a KeyboardButtonRequestChat button.
*
* @link https://core.telegram.org/bots/api#chatshared
*
* @method int getRequestId() Identifier of the request
* @method int getChatId() Identifier of the shared chat.
*/
class ChatShared extends Entity
{

}
4 changes: 2 additions & 2 deletions src/Entities/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* @method string getFileId() Identifier for this file, which can be used to download or reuse the file
* @method string getFileUniqueId() Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
* @method PhotoSize getThumb() Optional. Document thumbnail as defined by sender
* @method PhotoSize getThumbnail() Optional. Document thumbnail as defined by sender
* @method string getFileName() Optional. Original filename as defined by sender
* @method string getMimeType() Optional. MIME type of the file as defined by sender
* @method int getFileSize() Optional. File size
Expand All @@ -31,7 +31,7 @@ class Document extends Entity
protected function subEntities(): array
{
return [
'thumb' => PhotoSize::class,
'thumbnail' => PhotoSize::class,
];
}
}
Loading