Commit 7e73592c authored by Armando Lüscher's avatar Armando Lüscher Committed by GitHub

Merge pull request #647 from noplanman/finalise_payments_implementation

Add missing Payment properties to Message entity
parents 04de592d 646b8c4f
...@@ -5,6 +5,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c ...@@ -5,6 +5,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
## [Unreleased] ## [Unreleased]
### Added ### Added
- Finish implementing payments, adding all missing type checks and docblock methods.
### Changed ### Changed
### Deprecated ### Deprecated
### Removed ### Removed
......
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
namespace Longman\TelegramBot\Entities; namespace Longman\TelegramBot\Entities;
use Longman\TelegramBot\Entities\Payments\Invoice;
use Longman\TelegramBot\Entities\Payments\SuccessfulPayment;
/** /**
* Class Message * Class Message
* *
...@@ -46,6 +49,8 @@ namespace Longman\TelegramBot\Entities; ...@@ -46,6 +49,8 @@ namespace Longman\TelegramBot\Entities;
* @method int getMigrateToChatId() Optional. The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. * @method int getMigrateToChatId() Optional. The group has been migrated to a supergroup with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
* @method int getMigrateFromChatId() Optional. The supergroup has been migrated from a group with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. * @method int getMigrateFromChatId() Optional. The supergroup has been migrated from a group with the specified identifier. This number may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.
* @method Message getPinnedMessage() Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply. * @method Message getPinnedMessage() Optional. Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it is itself a reply.
* @method Invoice getInvoice() Optional. Message is an invoice for a payment, information about the invoice.
* @method SuccessfulPayment getSuccessfulPayment() Optional. Message is a service message about a successful payment, information about the payment.
*/ */
class Message extends Entity class Message extends Entity
{ {
...@@ -75,6 +80,8 @@ class Message extends Entity ...@@ -75,6 +80,8 @@ class Message extends Entity
'left_chat_member' => User::class, 'left_chat_member' => User::class,
'new_chat_photo' => PhotoSize::class, 'new_chat_photo' => PhotoSize::class,
'pinned_message' => Message::class, 'pinned_message' => Message::class,
'invoice' => Invoice::class,
'successful_payment' => SuccessfulPayment::class,
]; ];
} }
...@@ -244,7 +251,7 @@ class Message extends Entity ...@@ -244,7 +251,7 @@ class Message extends Entity
/** /**
* Detect type based on properties. * Detect type based on properties.
* *
* @return string|null * @return string
*/ */
public function getType() public function getType()
{ {
...@@ -270,6 +277,8 @@ class Message extends Entity ...@@ -270,6 +277,8 @@ class Message extends Entity
'migrate_to_chat_id', 'migrate_to_chat_id',
'migrate_from_chat_id', 'migrate_from_chat_id',
'pinned_message', 'pinned_message',
'invoice',
'successful_payment',
]; ];
foreach ($types as $type) { foreach ($types as $type) {
......
...@@ -420,9 +420,7 @@ class Telegram ...@@ -420,9 +420,7 @@ class Telegram
$command = 'genericmessage'; $command = 'genericmessage';
$update_type = $this->update->getUpdateType(); $update_type = $this->update->getUpdateType();
if (in_array($update_type, ['edited_message', 'channel_post', 'edited_channel_post', 'inline_query', 'chosen_inline_result', 'callback_query'], true)) { if ($update_type === 'message') {
$command = $this->getCommandFromType($update_type);
} elseif ($update_type === 'message') {
$message = $this->update->getMessage(); $message = $this->update->getMessage();
//Load admin commands //Load admin commands
...@@ -434,21 +432,25 @@ class Telegram ...@@ -434,21 +432,25 @@ class Telegram
if ($type === 'command') { if ($type === 'command') {
$command = $message->getCommand(); $command = $message->getCommand();
} elseif (in_array($type, [ } elseif (in_array($type, [
'channel_chat_created', 'new_chat_members',
'left_chat_member',
'new_chat_title',
'new_chat_photo',
'delete_chat_photo', 'delete_chat_photo',
'group_chat_created', 'group_chat_created',
'left_chat_member', 'supergroup_chat_created',
'migrate_from_chat_id', 'channel_chat_created',
'migrate_to_chat_id', 'migrate_to_chat_id',
'new_chat_members', 'migrate_from_chat_id',
'new_chat_photo',
'new_chat_title',
'pinned_message', 'pinned_message',
'supergroup_chat_created', 'invoice',
'successful_payment',
], true) ], true)
) { ) {
$command = $this->getCommandFromType($type); $command = $this->getCommandFromType($type);
} }
} else {
$command = $this->getCommandFromType($update_type);
} }
//Make sure we have an up-to-date command list //Make sure we have an up-to-date command list
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment