Skip to content

Commit 24ce6b7

Browse files
committed
Merge branch 'develop' into add_missing_db_fields
2 parents b0b7056 + 5bec182 commit 24ce6b7

23 files changed

+603
-9
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ php:
1515
- 7.0
1616
- 7.1
1717
- 7.2
18+
- 7.3
1819
- nightly
1920
- hhvm
2021

CHANGELOG.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,24 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
66
## [Unreleased]
77
:exclamation: After updating to this version, you will need to execute the [SQL migration script][unreleased-sql-migration] on your database.
88
### Added
9-
- Bot API 4.0 (without Passport)
109
- Added missing API fields to Entities and DB.
1110
- Created database tables for `shipping_query` and `pre_checkout_query`.
1211
### Changed
13-
- [:exclamation:][unreleased-bc-move-animation-out-of-games-namespace] Move Animation entity out of Games namespace.
1412
### Deprecated
1513
### Removed
1614
### Fixed
1715
### Security
1816

17+
## [0.55.0] - 2018-12-20
18+
:exclamation: After updating to this version, you will need to execute the [SQL migration script][0.55.0-sql-migration] on your database.
19+
### Added
20+
- Bot API 4.0 and 4.1 (Telegram Passport)
21+
- Test PHP 7.3 with Travis.
22+
### Changed
23+
- [:exclamation:][0.55.0-bc-move-animation-out-of-games-namespace] Move Animation entity out of Games namespace.
24+
### Fixed
25+
- Added missing `video_note` to `Message` types.
26+
1927
## [0.54.1] - 2018-10-23
2028
### Fixed
2129
- `sendToActiveChats` now works correctly for any valid Request action.
@@ -222,8 +230,9 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
222230
### Deprecated
223231
- Move `hideKeyboard` to `removeKeyboard`.
224232

225-
[unreleased-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.54.0-unreleased.sql
226-
[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
233+
[unreleased-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.55.0-unreleased.sql
234+
[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
235+
[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
227236
[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
228237
[0.54.0-bc-rename-constants]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#rename-constants
229238
[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
@@ -241,6 +250,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
241250
[example-bot]: https://github.com/php-telegram-bot/example-bot
242251

243252
[Unreleased]: https://github.com/php-telegram-bot/core/compare/master...develop
253+
[0.55.0]: https://github.com/php-telegram-bot/core/compare/0.54.1...0.55.0
244254
[0.54.1]: https://github.com/php-telegram-bot/core/compare/0.54.0...0.54.1
245255
[0.54.0]: https://github.com/php-telegram-bot/core/compare/0.53.0...0.54.0
246256
[0.53.0]: https://github.com/php-telegram-bot/core/compare/0.52.0...0.53.0

src/DB.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,16 +880,16 @@ public static function insertMessageRequest(Message $message)
880880
`animation`, `game`, `photo`, `sticker`, `video`, `voice`, `video_note`, `caption`, `contact`,
881881
`location`, `venue`, `new_chat_members`, `left_chat_member`,
882882
`new_chat_title`,`new_chat_photo`, `delete_chat_photo`, `group_chat_created`,
883-
`supergroup_chat_created`, `channel_chat_created`,
884-
`migrate_from_chat_id`, `migrate_to_chat_id`, `pinned_message`, `invoice`, `successful_payment`, `connected_website`
883+
`supergroup_chat_created`, `channel_chat_created`, `migrate_from_chat_id`, `migrate_to_chat_id`,
884+
`pinned_message`, `invoice`, `successful_payment`, `connected_website`, `passport_data`
885885
) VALUES (
886886
:message_id, :user_id, :chat_id, :date, :forward_from, :forward_from_chat, :forward_from_message_id,
887887
:forward_signature, :forward_date, :reply_to_chat, :reply_to_message, :edit_date, :media_group_id, :author_signature, :text, :entities, :caption_entities, :audio, :document,
888888
:animation, :game, :photo, :sticker, :video, :voice, :video_note, :caption, :contact,
889889
:location, :venue, :new_chat_members, :left_chat_member,
890890
:new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created,
891-
:supergroup_chat_created, :channel_chat_created,
892-
:migrate_from_chat_id, :migrate_to_chat_id, :pinned_message, :invoice, :successful_payment, :connected_website
891+
:supergroup_chat_created, :channel_chat_created, :migrate_from_chat_id, :migrate_to_chat_id,
892+
:pinned_message, :invoice, :successful_payment, :connected_website, :passport_data
893893
)
894894
');
895895

@@ -958,6 +958,7 @@ public static function insertMessageRequest(Message $message)
958958
$sth->bindValue(':invoice', $message->getInvoice());
959959
$sth->bindValue(':successful_payment', $message->getSuccessfulPayment());
960960
$sth->bindValue(':connected_website', $message->getConnectedWebsite());
961+
$sth->bindValue(':passport_data', $message->getPassportData());
961962

962963
return $sth->execute();
963964
} catch (PDOException $e) {

src/Entities/Message.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Longman\TelegramBot\Entities\Games\Game;
1414
use Longman\TelegramBot\Entities\Payments\Invoice;
1515
use Longman\TelegramBot\Entities\Payments\SuccessfulPayment;
16+
use Longman\TelegramBot\Entities\TelegramPassport\PassportData;
1617

1718
/**
1819
* Class Message
@@ -56,6 +57,7 @@
5657
* @method Invoice getInvoice() Optional. Message is an invoice for a payment, information about the invoice.
5758
* @method SuccessfulPayment getSuccessfulPayment() Optional. Message is a service message about a successful payment, information about the payment.
5859
* @method string getConnectedWebsite() Optional. The domain name of the website on which the user has logged in.
60+
* @method PassportData getPassportData() Optional. Telegram Passport data
5961
*/
6062
class Message extends Entity
6163
{
@@ -90,6 +92,7 @@ protected function subEntities()
9092
'pinned_message' => Message::class,
9193
'invoice' => Invoice::class,
9294
'successful_payment' => SuccessfulPayment::class,
95+
'passport_data' => PassportData::class,
9396
];
9497
}
9598

@@ -288,6 +291,7 @@ public function getType()
288291
'sticker',
289292
'video',
290293
'voice',
294+
'video_note',
291295
'contact',
292296
'location',
293297
'venue',
@@ -304,6 +308,7 @@ public function getType()
304308
'pinned_message',
305309
'invoice',
306310
'successful_payment',
311+
'passport_data',
307312
];
308313

309314
$is_command = strlen($this->getCommand()) > 0;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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\TelegramPassport;
12+
13+
use Longman\TelegramBot\Entities\Entity;
14+
15+
/**
16+
* Class EncryptedCredentials
17+
*
18+
* Contains data required for decrypting and authenticating EncryptedCredentials. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes.
19+
*
20+
* @link https://core.telegram.org/bots/api#encryptedcredentials
21+
*
22+
* @method string getData() Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets required for EncryptedPassportElement decryption and authentication
23+
* @method string getHash() Base64-encoded data hash for data authentication
24+
* @method string getSecret() Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption
25+
**/
26+
class EncryptedCredentials extends Entity
27+
{
28+
29+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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\TelegramPassport;
12+
13+
use Longman\TelegramBot\Entities\Entity;
14+
15+
/**
16+
* Class EncryptedPassportElement
17+
*
18+
* Contains information about documents or other Telegram Passport elements shared with the bot by the user.
19+
*
20+
* @link https://core.telegram.org/bots/api#encryptedpassportelement
21+
*
22+
* @method string getType() Element type. One of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”, “phone_number”, “email”.
23+
* @method string getData() Optional. Base64-encoded encrypted Telegram Passport element data provided by the user, available for “personal_details”, “passport”, “driver_license”, “identity_card”, “identity_passport” and “address” types. Can be decrypted and verified using the accompanying EncryptedCredentials.
24+
* @method string getPhoneNumber() Optional. User's verified phone number, available only for “phone_number” type
25+
* @method string getEmail() Optional. User's verified email address, available only for “email” type
26+
* @method PassportFile getFrontSide() Optional. Encrypted file with the front side of the document, provided by the user. Available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials.
27+
* @method PassportFile getReverseSide() Optional. Encrypted file with the reverse side of the document, provided by the user. Available for “driver_license” and “identity_card”. The file can be decrypted and verified using the accompanying EncryptedCredentials.
28+
* @method PassportFile getSelfie() Optional. Encrypted file with the selfie of the user holding a document, provided by the user; available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials.
29+
* @method string getHash() Base64-encoded element hash for using in PassportElementErrorUnspecified
30+
**/
31+
class EncryptedPassportElement extends Entity
32+
{
33+
/**
34+
* {@inheritdoc}
35+
*/
36+
protected function subEntities()
37+
{
38+
return [
39+
'files' => PassportFile::class,
40+
'front_side' => PassportFile::class,
41+
'reverse_side' => PassportFile::class,
42+
'selfie' => PassportFile::class,
43+
'translation' => PassportFile::class,
44+
];
45+
}
46+
47+
/**
48+
* Optional. Array of encrypted files with documents provided by the user, available for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials.
49+
*
50+
* This method overrides the default getFiles method
51+
* and returns a nice array of PassportFile objects.
52+
*
53+
* @return null|PassportFile[]
54+
*/
55+
public function getFiles()
56+
{
57+
$pretty_array = $this->makePrettyObjectArray(PassportFile::class, 'files');
58+
59+
return empty($pretty_array) ? null : $pretty_array;
60+
}
61+
62+
/**
63+
* Optional. Array of encrypted files with translated versions of documents provided by the user. Available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials.
64+
*
65+
* This method overrides the default getTranslation method
66+
* and returns a nice array of PassportFile objects.
67+
*
68+
* @return null|PassportFile[]
69+
*/
70+
public function getTranslation()
71+
{
72+
$pretty_array = $this->makePrettyObjectArray(PassportFile::class, 'translation');
73+
74+
return empty($pretty_array) ? null : $pretty_array;
75+
}
76+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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\TelegramPassport;
12+
13+
use Longman\TelegramBot\Entities\Entity;
14+
15+
/**
16+
* Class PassportData
17+
*
18+
* Contains information about Telegram Passport data shared with the bot by the user.
19+
*
20+
* @link https://core.telegram.org/bots/api#passportdata
21+
*
22+
* @method EncryptedCredentials getCredentials() Encrypted credentials required to decrypt the data
23+
**/
24+
class PassportData extends Entity
25+
{
26+
/**
27+
* {@inheritdoc}
28+
*/
29+
protected function subEntities()
30+
{
31+
return [
32+
'data' => EncryptedPassportElement::class,
33+
'credentials' => EncryptedCredentials::class,
34+
];
35+
}
36+
37+
/**
38+
* Array with information about documents and other Telegram Passport elements that was shared with the bot
39+
*
40+
* This method overrides the default getData method
41+
* and returns a nice array of EncryptedPassportElement objects.
42+
*
43+
* @return null|EncryptedPassportElement[]
44+
*/
45+
public function getData()
46+
{
47+
$pretty_array = $this->makePrettyObjectArray(EncryptedPassportElement::class, 'data');
48+
49+
return empty($pretty_array) ? null : $pretty_array;
50+
}
51+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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 Entities\TelegramPassport\PassportElementError;
12+
13+
interface PassportElementError
14+
{
15+
16+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 Entities\TelegramPassport\PassportElementError;
12+
13+
use Longman\TelegramBot\Entities\Entity;
14+
15+
/**
16+
* Class PassportElementErrorDataField
17+
*
18+
* Represents an issue in one of the data fields that was provided by the user. The error is considered resolved when the field's value changes.
19+
*
20+
* @link https://core.telegram.org/bots/api#passportelementerrordatafield
21+
*
22+
* @method string getSource() Error source, must be data
23+
* @method string getType() The section of the user's Telegram Passport which has the error, one of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”
24+
* @method string getFieldName() Name of the data field which has the error
25+
* @method string getDataHash() Base64-encoded data hash
26+
* @method string getMessage() Error message
27+
*/
28+
class PassportElementErrorDataField extends Entity implements PassportElementError
29+
{
30+
/**
31+
* PassportElementErrorDataField constructor
32+
*
33+
* @param array $data
34+
*
35+
* @throws \Longman\TelegramBot\Exception\TelegramException
36+
*/
37+
public function __construct(array $data = [])
38+
{
39+
$data['source'] = 'data';
40+
parent::__construct($data);
41+
}
42+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 Entities\TelegramPassport\PassportElementError;
12+
13+
use Longman\TelegramBot\Entities\Entity;
14+
15+
/**
16+
* Class PassportElementErrorFile
17+
*
18+
* Represents an issue with a document scan. The error is considered resolved when the file with the document scan changes.
19+
*
20+
* @link https://core.telegram.org/bots/api#passportelementerrorfile
21+
*
22+
* @method string getSource() Error source, must be file
23+
* @method string getType() The section of the user's Telegram Passport which has the issue, one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”
24+
* @method string getFileHash() Base64-encoded file hash
25+
* @method string getMessage() Error message
26+
*/
27+
class PassportElementErrorFile extends Entity implements PassportElementError
28+
{
29+
/**
30+
* PassportElementErrorFile constructor
31+
*
32+
* @param array $data
33+
*
34+
* @throws \Longman\TelegramBot\Exception\TelegramException
35+
*/
36+
public function __construct(array $data = [])
37+
{
38+
$data['source'] = 'file';
39+
parent::__construct($data);
40+
}
41+
}

0 commit comments

Comments
 (0)