Skip to content

Commit d8ddc0e

Browse files
authored
Merge branch 'develop' into logo
2 parents 753d681 + 9e132d3 commit d8ddc0e

File tree

12 files changed

+529
-185
lines changed

12 files changed

+529
-185
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ 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.2 (Polls).
10+
- `getIsMember()` method to `ChatMember` entity.
11+
- `getForwardSenderName()` method to `Message` entity.
12+
- `forward_sender_name` (and forgotten `forward_signature`) DB fields.
13+
- Added missing API fields to Entities and DB.
14+
- Created database tables for `shipping_query` and `pre_checkout_query`.
815
### Changed
916
### Deprecated
1017
### Removed
1118
### Fixed
19+
- Missing DB table name specifier in `/cleanup` command. (#947)
1220
### Security
1321

1422
## [0.56.0] - 2019-04-15
@@ -248,6 +256,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
248256
### Deprecated
249257
- Move `hideKeyboard` to `removeKeyboard`.
250258

259+
[unreleased-sql-migration]: https://github.com/php-telegram-bot/core/tree/develop/utils/db-schema-update/unreleased.sql
251260
[0.55.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.54.1-0.55.0.sql
252261
[0.55.0-bc-move-animation-out-of-games-namespace]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#move-animation-out-of-games-namespace
253262
[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

src/Commands/AdminCommands/CleanupCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ private function getQueries($settings)
306306
SELECT id
307307
FROM (
308308
SELECT id
309-
FROM `message`
309+
FROM `%1$s`
310310
WHERE `date` < \'%2$s\'
311311
AND `id` NOT IN (
312312
SELECT `message_id`

src/Commands/Command.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Longman\TelegramBot\Entities\ChosenInlineResult;
1616
use Longman\TelegramBot\Entities\InlineQuery;
1717
use Longman\TelegramBot\Entities\Message;
18+
use Longman\TelegramBot\Entities\Payments\PreCheckoutQuery;
19+
use Longman\TelegramBot\Entities\Payments\ShippingQuery;
20+
use Longman\TelegramBot\Entities\Poll;
1821
use Longman\TelegramBot\Entities\Update;
1922
use Longman\TelegramBot\Request;
2023
use Longman\TelegramBot\Telegram;
@@ -31,6 +34,9 @@
3134
* @method InlineQuery getInlineQuery() Optional. New incoming inline query
3235
* @method ChosenInlineResult getChosenInlineResult() Optional. The result of an inline query that was chosen by a user and sent to their chat partner.
3336
* @method CallbackQuery getCallbackQuery() Optional. New incoming callback query
37+
* @method ShippingQuery getShippingQuery() Optional. New incoming shipping query. Only for invoices with flexible price
38+
* @method PreCheckoutQuery getPreCheckoutQuery() Optional. New incoming pre-checkout query. Contains full information about checkout
39+
* @method Poll getPoll() Optional. New poll state. Bots receive only updates about polls, which are sent or stopped by the bot
3440
*/
3541
abstract class Command
3642
{

src/DB.php

Lines changed: 254 additions & 151 deletions
Large diffs are not rendered by default.

src/Entities/ChatMember.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* @method bool getCanRestrictMembers() Optional. Administrators only. True, if the administrator can restrict, ban or unban chat members
2828
* @method bool getCanPinMessages() Optional. Administrators only. True, if the administrator can pin messages, supergroups only
2929
* @method bool getCanPromoteMembers() Optional. Administrators only. True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)
30+
* @method bool getIsMember() Optional. Restricted only. True, if the user is a member of the chat at the moment of the request
3031
* @method bool getCanSendMessages() Optional. Restricted only. True, if the user can send text messages, contacts, locations and venues
3132
* @method bool getCanSendMediaMessages() Optional. Restricted only. True, if the user can send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages
3233
* @method bool getCanSendOtherMessages() Optional. Restricted only. True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages

src/Entities/Message.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* @method Chat getForwardFromChat() Optional. For messages forwarded from a channel, information about the original channel
2929
* @method int getForwardFromMessageId() Optional. For forwarded channel posts, identifier of the original message in the channel
3030
* @method string getForwardSignature() Optional. For messages forwarded from channels, signature of the post author if present
31+
* @method string getForwardSenderName() Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages
3132
* @method int getForwardDate() Optional. For forwarded messages, date the original message was sent in Unix time
3233
* @method Message getReplyToMessage() Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.
3334
* @method int getEditDate() Optional. Date the message was last edited in Unix time
@@ -45,6 +46,7 @@
4546
* @method Contact getContact() Optional. Message is a shared contact, information about the contact
4647
* @method Location getLocation() Optional. Message is a shared location, information about the location
4748
* @method Venue getVenue() Optional. Message is a venue, information about the venue
49+
* @method Poll getPoll() Optional. Message is a native poll, information about the poll
4850
* @method User getLeftChatMember() Optional. A member was removed from the group, information about them (this member may be the bot itself)
4951
* @method string getNewChatTitle() Optional. A chat title was changed to this value
5052
* @method bool getDeleteChatPhoto() Optional. Service message: the chat photo was deleted
@@ -86,6 +88,7 @@ protected function subEntities()
8688
'contact' => Contact::class,
8789
'location' => Location::class,
8890
'venue' => Venue::class,
91+
'poll' => Poll::class,
8992
'new_chat_members' => User::class,
9093
'left_chat_member' => User::class,
9194
'new_chat_photo' => PhotoSize::class,
@@ -295,6 +298,7 @@ public function getType()
295298
'contact',
296299
'location',
297300
'venue',
301+
'poll',
298302
'new_chat_members',
299303
'left_chat_member',
300304
'new_chat_title',

src/Entities/Poll.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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;
12+
13+
/**
14+
* Class Poll
15+
*
16+
* This entity contains information about a poll.
17+
*
18+
* @link https://core.telegram.org/bots/api#poll
19+
*
20+
* @method string getId() Unique poll identifier
21+
* @method string getQuestion() Poll question, 1-255 characters
22+
* @method bool getIsClosed() True, if the poll is closed
23+
*/
24+
class Poll extends Entity
25+
{
26+
/**
27+
* {@inheritdoc}
28+
*/
29+
protected function subEntities()
30+
{
31+
return [
32+
'options' => PollOption::class,
33+
];
34+
}
35+
36+
/**
37+
* List of poll options
38+
*
39+
* This method overrides the default getOptions method
40+
* and returns a nice array of PollOption objects.
41+
*
42+
* @return null|PollOption[]
43+
*/
44+
public function getOptions()
45+
{
46+
$pretty_array = $this->makePrettyObjectArray(PollOption::class, 'options');
47+
48+
return empty($pretty_array) ? null : $pretty_array;
49+
}
50+
}

src/Entities/PollOption.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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;
12+
13+
/**
14+
* Class PollOption
15+
*
16+
* This entity contains information about one answer option in a poll.
17+
*
18+
* @link https://core.telegram.org/bots/api#polloption
19+
*
20+
* @method string getText() Option text, 1-100 characters
21+
* @method int getVoterCount() Number of users that voted for this option
22+
*/
23+
class PollOption extends Entity
24+
{
25+
26+
}

src/Entities/Update.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* @method CallbackQuery getCallbackQuery() Optional. New incoming callback query
2929
* @method ShippingQuery getShippingQuery() Optional. New incoming shipping query. Only for invoices with flexible price
3030
* @method PreCheckoutQuery getPreCheckoutQuery() Optional. New incoming pre-checkout query. Contains full information about checkout
31+
* @method Poll getPoll() Optional. New poll state. Bots receive only updates about polls, which are sent or stopped by the bot
3132
*/
3233
class Update extends Entity
3334
{
@@ -46,6 +47,7 @@ protected function subEntities()
4647
'callback_query' => CallbackQuery::class,
4748
'shipping_query' => ShippingQuery::class,
4849
'pre_checkout_query' => PreCheckoutQuery::class,
50+
'poll' => Poll::class,
4951
];
5052
}
5153

@@ -66,6 +68,7 @@ public function getUpdateType()
6668
'callback_query',
6769
'shipping_query',
6870
'pre_checkout_query',
71+
'poll',
6972
];
7073
foreach ($types as $type) {
7174
if ($this->getProperty($type)) {

src/Request.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
* @method static ServerResponse stopMessageLiveLocation(array $data) Use this method to stop updating a live location message sent by the bot or via the bot (for inline bots) before live_period expires. On success, if the message was sent by the bot, the sent Message is returned, otherwise True is returned.
4343
* @method static ServerResponse sendVenue(array $data) Use this method to send information about a venue. On success, the sent Message is returned.
4444
* @method static ServerResponse sendContact(array $data) Use this method to send phone contacts. On success, the sent Message is returned.
45+
* @method static ServerResponse sendPoll(array $data) Use this method to send a native poll. A native poll can't be sent to a private chat. On success, the sent Message is returned.
4546
* @method static ServerResponse sendChatAction(array $data) Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.
4647
* @method static ServerResponse getUserProfilePhotos(array $data) Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.
4748
* @method static ServerResponse getFile(array $data) Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again.
@@ -69,6 +70,7 @@
6970
* @method static ServerResponse editMessageCaption(array $data) Use this method to edit captions of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
7071
* @method static ServerResponse editMessageMedia(array $data) Use this method to edit audio, document, photo, or video messages. On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.
7172
* @method static ServerResponse editMessageReplyMarkup(array $data) Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
73+
* @method static ServerResponse stopPoll(array $data) Use this method to stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned.
7274
* @method static ServerResponse deleteMessage(array $data) Use this method to delete a message, including service messages, with certain limitations. Returns True on success.
7375
* @method static ServerResponse getStickerSet(array $data) Use this method to get a sticker set. On success, a StickerSet object is returned.
7476
* @method static ServerResponse uploadStickerFile(array $data) Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success.
@@ -166,6 +168,7 @@ class Request
166168
'stopMessageLiveLocation',
167169
'sendVenue',
168170
'sendContact',
171+
'sendPoll',
169172
'sendChatAction',
170173
'getUserProfilePhotos',
171174
'getFile',
@@ -193,6 +196,7 @@ class Request
193196
'editMessageCaption',
194197
'editMessageMedia',
195198
'editMessageReplyMarkup',
199+
'stopPoll',
196200
'deleteMessage',
197201
'getStickerSet',
198202
'uploadStickerFile',
@@ -807,13 +811,15 @@ private static function limitTelegramRequests($action, array $data = [])
807811
'stopMessageLiveLocation',
808812
'sendVenue',
809813
'sendContact',
814+
'sendPoll',
810815
'sendInvoice',
811816
'sendGame',
812817
'setGameScore',
813818
'editMessageText',
814819
'editMessageCaption',
815820
'editMessageMedia',
816821
'editMessageReplyMarkup',
822+
'stopPoll',
817823
'setChatTitle',
818824
'setChatDescription',
819825
'setChatStickerSet',

0 commit comments

Comments
 (0)