mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-26 23:14:38 +01:00
Merge 83c36563f4
into 314db4ee1f
This commit is contained in:
commit
9003c4fe50
45
src/EventHandler/Message/Entities/TextWithEntities.php
Normal file
45
src/EventHandler/Message/Entities/TextWithEntities.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of MadelineProto.
|
||||||
|
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU Affero General Public License for more details.
|
||||||
|
* You should have received a copy of the GNU General Public License along with MadelineProto.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @author Mahdi <mahdi.talaee1379@gmail.com>
|
||||||
|
* @copyright 2016-2023 Mahdi <mahdi.talaee1379@gmail.com>
|
||||||
|
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
|
||||||
|
* @link https://docs.madelineproto.xyz MadelineProto documentation
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace danog\MadelineProto\EventHandler\Message\Entities;
|
||||||
|
|
||||||
|
use danog\MadelineProto\ParseMode;
|
||||||
|
use JsonSerializable;
|
||||||
|
|
||||||
|
final class TextWithEntities implements JsonSerializable
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
/** Text */
|
||||||
|
public readonly string $text,
|
||||||
|
/** Message entities for styled text */
|
||||||
|
public readonly array $entities,
|
||||||
|
/** Whether to parse HTML or Markdown markup in the message */
|
||||||
|
public readonly ?ParseMode $parseMode,
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @internal */
|
||||||
|
public function jsonSerialize(): mixed
|
||||||
|
{
|
||||||
|
$res = ['_' => static::class];
|
||||||
|
$refl = new ReflectionClass($this);
|
||||||
|
foreach ($refl->getProperties(ReflectionProperty::IS_PUBLIC) as $prop) {
|
||||||
|
$res[$prop->getName()] = $prop->getValue($this);
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
}
|
45
src/EventHandler/Message/Service/DialogGiftStars.php
Normal file
45
src/EventHandler/Message/Service/DialogGiftStars.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of MadelineProto.
|
||||||
|
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU Affero General Public License for more details.
|
||||||
|
* You should have received a copy of the GNU General Public License along with MadelineProto.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @author Mahdi <mahdi.talaee1379@gmail.com>
|
||||||
|
* @copyright 2016-2023 Mahdi <mahdi.talaee1379@gmail.com>
|
||||||
|
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
|
||||||
|
* @link https://docs.madelineproto.xyz MadelineProto documentation
|
||||||
|
*/
|
||||||
|
|
||||||
|
use danog\MadelineProto\EventHandler\Message\ServiceMessage;
|
||||||
|
use danog\MadelineProto\MTProto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Info about a gifted Telegram Stars.
|
||||||
|
*/
|
||||||
|
class DialogGiftStars extends ServiceMessage
|
||||||
|
{
|
||||||
|
/** @internal */
|
||||||
|
public function __construct(
|
||||||
|
MTProto $API,
|
||||||
|
array $rawMessage,
|
||||||
|
array $info,
|
||||||
|
/** Three-letter ISO 4217 currency code */
|
||||||
|
public string $currency,
|
||||||
|
/** Price of the gift in the smallest units of the currency (integer, not float/double). */
|
||||||
|
public int $amount,
|
||||||
|
/** Amount of gifted stars */
|
||||||
|
public int $stars,
|
||||||
|
/** If the gift was bought using a cryptocurrency, the cryptocurrency name. */
|
||||||
|
public ?string $cryptoCurrency,
|
||||||
|
/** If the gift was bought using a cryptocurrency, price of the gift in the smallest units of a cryptocurrency. */
|
||||||
|
public ?int $cryptoAmount,
|
||||||
|
/** Identifier of the transaction, only visible to the receiver of the gift. */
|
||||||
|
public string $transactionId,
|
||||||
|
) {
|
||||||
|
parent::__construct($API, $rawMessage, $info);
|
||||||
|
}
|
||||||
|
}
|
49
src/EventHandler/Message/Service/DialogStarGift.php
Normal file
49
src/EventHandler/Message/Service/DialogStarGift.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of MadelineProto.
|
||||||
|
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU Affero General Public License for more details.
|
||||||
|
* You should have received a copy of the GNU General Public License along with MadelineProto.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @author Mahdi <mahdi.talaee1379@gmail.com>
|
||||||
|
* @copyright 2016-2023 Mahdi <mahdi.talaee1379@gmail.com>
|
||||||
|
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
|
||||||
|
* @link https://docs.madelineproto.xyz MadelineProto documentation
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace danog\MadelineProto\EventHandler\Message\Service;
|
||||||
|
|
||||||
|
use danog\MadelineProto\EventHandler\Message\Entities\TextWithEntities;
|
||||||
|
use danog\MadelineProto\EventHandler\Message\ServiceMessage;
|
||||||
|
use danog\MadelineProto\EventHandler\Payments\StarGift;
|
||||||
|
use danog\MadelineProto\MTProto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Info about a Star gifted.
|
||||||
|
*/
|
||||||
|
class DialogStarGift extends ServiceMessage
|
||||||
|
{
|
||||||
|
/** @internal */
|
||||||
|
public function __construct(
|
||||||
|
MTProto $API,
|
||||||
|
array $rawMessage,
|
||||||
|
array $info,
|
||||||
|
/** Show the name of sender hide or no */
|
||||||
|
public readonly ?bool $hide,
|
||||||
|
/** Show the gift is saved on profile or no */
|
||||||
|
public readonly ?bool $saved,
|
||||||
|
/** Show the gift is converted to stars or no */
|
||||||
|
public readonly ?bool $converted,
|
||||||
|
/** The gift */
|
||||||
|
public readonly StarGift $gift,
|
||||||
|
/** Styled text that sender of gift provided */
|
||||||
|
public readonly ?TextWithEntities $message,
|
||||||
|
/** Amount of stars after the gift converted */
|
||||||
|
public readonly ?int $convertStars
|
||||||
|
) {
|
||||||
|
parent::__construct($API, $rawMessage, $info);
|
||||||
|
}
|
||||||
|
}
|
90
src/EventHandler/Payments/Payment.php
Normal file
90
src/EventHandler/Payments/Payment.php
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This file is part of MadelineProto.
|
||||||
|
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU Affero General Public License for more details.
|
||||||
|
* You should have received a copy of the GNU General Public License along with MadelineProto.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @author Mahdi <mahdi.talaee1379@gmail.com>
|
||||||
|
* @copyright 2016-2023 Mahdi <mahdi.talaee1379@gmail.com>
|
||||||
|
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
|
||||||
|
* @link https://docs.madelineproto.xyz MadelineProto documentation
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace danog\MadelineProto\EventHandler\Payments;
|
||||||
|
|
||||||
|
use danog\MadelineProto\EventHandler\Update;
|
||||||
|
use danog\MadelineProto\MTProto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This object contains information about an incoming pre-checkout query.
|
||||||
|
*/
|
||||||
|
class Payment extends Update
|
||||||
|
{
|
||||||
|
/** Unique query identifier */
|
||||||
|
public readonly int $queryId;
|
||||||
|
/** User who sent the query */
|
||||||
|
public readonly int $userId;
|
||||||
|
/** Bot specified invoice payload */
|
||||||
|
public readonly string $payload;
|
||||||
|
/** Order info provided by the user */
|
||||||
|
public readonly ?PaymentRequestedInfo $info;
|
||||||
|
/** Identifier of the shipping option chosen by the user */
|
||||||
|
public readonly ?string $shippingOptionId;
|
||||||
|
/** Three-letter ISO 4217 currency code */
|
||||||
|
public readonly string $currency;
|
||||||
|
/**Total amount in the smallest units of the currency (integer, not float/double). */
|
||||||
|
public readonly int $totalAmount;
|
||||||
|
/** @internal */
|
||||||
|
public function __construct(MTProto $API, array $rawRequestedPayment)
|
||||||
|
{
|
||||||
|
parent::__construct($API);
|
||||||
|
$this->queryId = $rawRequestedPayment['query_id'];
|
||||||
|
$this->userId = $rawRequestedPayment['user_id'];
|
||||||
|
$this->payload = $rawRequestedPayment['payload'];
|
||||||
|
$this->info = isset($rawRequestedPayment['payload']) ? new PaymentRequestedInfo(
|
||||||
|
$rawRequestedPayment['name'],
|
||||||
|
$rawRequestedPayment['phone'],
|
||||||
|
$rawRequestedPayment['email'],
|
||||||
|
) : null;
|
||||||
|
$this->shippingOptionId = $rawRequestedPayment['shipping_option_id'] ?? null;
|
||||||
|
$this->currency = $rawRequestedPayment['currency'];
|
||||||
|
$this->totalAmount = $rawRequestedPayment['total_amount'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accept pending payment.
|
||||||
|
* note that you must call this function or reject function up to 10 seconds after user accept payment!!.
|
||||||
|
*/
|
||||||
|
public function accept(): true
|
||||||
|
{
|
||||||
|
return $this->getClient()->methodCallAsyncRead(
|
||||||
|
'messages.setBotPrecheckoutResults',
|
||||||
|
[
|
||||||
|
'success' => true,
|
||||||
|
'query_id' => $this->queryId,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reject pending payment.
|
||||||
|
* note that you must call this function or accept function up to 10 seconds after user accept payment!!.
|
||||||
|
* @param string $errorMessage if the success isn’t set. Error message in human-readable form that explains the reason for failure to proceed with the checkout
|
||||||
|
*/
|
||||||
|
public function reject(string $errorMessage): false
|
||||||
|
{
|
||||||
|
return $this->getClient()->methodCallAsyncRead(
|
||||||
|
'messages.setBotPrecheckoutResults',
|
||||||
|
[
|
||||||
|
'success' => false,
|
||||||
|
'query_id' => $this->queryId,
|
||||||
|
'error' => $errorMessage,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
30
src/EventHandler/Payments/PaymentRequestedInfo.php
Normal file
30
src/EventHandler/Payments/PaymentRequestedInfo.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace danog\MadelineProto\EventHandler\Payments;
|
||||||
|
|
||||||
|
use JsonSerializable;
|
||||||
|
|
||||||
|
final class PaymentRequestedInfo implements JsonSerializable
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
/** User’s full name */
|
||||||
|
public readonly string $name,
|
||||||
|
/** User’s phone number */
|
||||||
|
public readonly string $phone,
|
||||||
|
/** User’s email address */
|
||||||
|
public readonly string $email
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @internal */
|
||||||
|
public function jsonSerialize(): mixed
|
||||||
|
{
|
||||||
|
$res = ['_' => static::class];
|
||||||
|
$refl = new ReflectionClass($this);
|
||||||
|
foreach ($refl->getProperties(ReflectionProperty::IS_PUBLIC) as $prop) {
|
||||||
|
$res[$prop->getName()] = $prop->getValue($this);
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
}
|
61
src/EventHandler/Payments/StarGift.php
Normal file
61
src/EventHandler/Payments/StarGift.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace danog\MadelineProto\EventHandler\Payments;
|
||||||
|
|
||||||
|
use danog\MadelineProto\EventHandler\Media\StaticSticker;
|
||||||
|
use danog\MadelineProto\EventHandler\Media\Sticker;
|
||||||
|
use danog\MadelineProto\Ipc\IpcCapable;
|
||||||
|
use danog\MadelineProto\MTProto;
|
||||||
|
|
||||||
|
final class StarGift extends IpcCapable implements \JsonSerializable
|
||||||
|
{
|
||||||
|
/** Show the gift is limited or not. */
|
||||||
|
public readonly ?bool $limited;
|
||||||
|
/** Show the gift is soldOut or not. */
|
||||||
|
public readonly ?bool $soldOut;
|
||||||
|
/** Gift id. */
|
||||||
|
public readonly int $id;
|
||||||
|
/** Gift sticker info. */
|
||||||
|
public readonly ?Sticker $sticker;
|
||||||
|
/** Amount of stars that need for buying this gift. */
|
||||||
|
public readonly int $stars;
|
||||||
|
/** Amount of gift that left. */
|
||||||
|
public readonly ?int $availabilityRemains;
|
||||||
|
/** Amount of total gift. */
|
||||||
|
public readonly ?int $availabilityTotal;
|
||||||
|
public readonly int $convertStars;
|
||||||
|
/** Show timestamp for first buy of the gift */
|
||||||
|
public readonly ?int $startSell;
|
||||||
|
/** Show timestamp for last buy of the gift */
|
||||||
|
public readonly ?int $endSell;
|
||||||
|
|
||||||
|
public function __construct(MTProto $API, array $rawStarGift)
|
||||||
|
{
|
||||||
|
$this->limited = $rawStarGift['limited'] ?? null;
|
||||||
|
$this->soldOut = $rawStarGift['sold_out'] ?? null;
|
||||||
|
$this->id = $rawStarGift['id'];
|
||||||
|
$this->sticker = isset($rawStarGift['sticker']) ?
|
||||||
|
new StaticSticker(
|
||||||
|
$API,
|
||||||
|
$rawStarGift['sticker'],
|
||||||
|
$rawStarGift['sticker']['attributes'],
|
||||||
|
$rawStarGift['sticker']['attributes'],
|
||||||
|
false
|
||||||
|
) : null;
|
||||||
|
$this->stars = $rawStarGift['stars'];
|
||||||
|
$this->availabilityRemains = $rawStarGift['availability_remains'] ?? null;
|
||||||
|
$this->availabilityTotal = $rawStarGift['availability_total'] ?? null;
|
||||||
|
$this->convertStars = $rawStarGift['convert_stars'];
|
||||||
|
$this->startSell = $rawStarGift['first_sale_date'] ?? null;
|
||||||
|
$this->endSell = $rawStarGift['last_sale_date'] ?? null;
|
||||||
|
parent::__construct($API);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @internal */
|
||||||
|
public function jsonSerialize(): mixed
|
||||||
|
{
|
||||||
|
$v = get_object_vars($this);
|
||||||
|
unset($v['API'], $v['session']);
|
||||||
|
return $v;
|
||||||
|
}
|
||||||
|
}
|
@ -50,6 +50,8 @@ use danog\MadelineProto\EventHandler\InlineQuery;
|
|||||||
use danog\MadelineProto\EventHandler\Message;
|
use danog\MadelineProto\EventHandler\Message;
|
||||||
use danog\MadelineProto\EventHandler\Message\ChannelMessage;
|
use danog\MadelineProto\EventHandler\Message\ChannelMessage;
|
||||||
use danog\MadelineProto\EventHandler\Message\CommentReply;
|
use danog\MadelineProto\EventHandler\Message\CommentReply;
|
||||||
|
use danog\MadelineProto\EventHandler\Message\Entities\MessageEntity;
|
||||||
|
use danog\MadelineProto\EventHandler\Message\Entities\TextWithEntities;
|
||||||
use danog\MadelineProto\EventHandler\Message\GroupMessage;
|
use danog\MadelineProto\EventHandler\Message\GroupMessage;
|
||||||
use danog\MadelineProto\EventHandler\Message\PrivateMessage;
|
use danog\MadelineProto\EventHandler\Message\PrivateMessage;
|
||||||
use danog\MadelineProto\EventHandler\Message\SecretMessage;
|
use danog\MadelineProto\EventHandler\Message\SecretMessage;
|
||||||
@ -80,11 +82,14 @@ use danog\MadelineProto\EventHandler\Message\Service\DialogScreenshotTaken;
|
|||||||
use danog\MadelineProto\EventHandler\Message\Service\DialogSetChatTheme;
|
use danog\MadelineProto\EventHandler\Message\Service\DialogSetChatTheme;
|
||||||
use danog\MadelineProto\EventHandler\Message\Service\DialogSetChatWallPaper;
|
use danog\MadelineProto\EventHandler\Message\Service\DialogSetChatWallPaper;
|
||||||
use danog\MadelineProto\EventHandler\Message\Service\DialogSetTTL;
|
use danog\MadelineProto\EventHandler\Message\Service\DialogSetTTL;
|
||||||
|
use danog\MadelineProto\EventHandler\Message\Service\DialogStarGift;
|
||||||
use danog\MadelineProto\EventHandler\Message\Service\DialogSuggestProfilePhoto;
|
use danog\MadelineProto\EventHandler\Message\Service\DialogSuggestProfilePhoto;
|
||||||
use danog\MadelineProto\EventHandler\Message\Service\DialogTitleChanged;
|
use danog\MadelineProto\EventHandler\Message\Service\DialogTitleChanged;
|
||||||
use danog\MadelineProto\EventHandler\Message\Service\DialogTopicCreated;
|
use danog\MadelineProto\EventHandler\Message\Service\DialogTopicCreated;
|
||||||
use danog\MadelineProto\EventHandler\Message\Service\DialogTopicEdited;
|
use danog\MadelineProto\EventHandler\Message\Service\DialogTopicEdited;
|
||||||
use danog\MadelineProto\EventHandler\Message\Service\DialogWebView;
|
use danog\MadelineProto\EventHandler\Message\Service\DialogWebView;
|
||||||
|
use danog\MadelineProto\EventHandler\Payments\Payment;
|
||||||
|
use danog\MadelineProto\EventHandler\Payments\StarGift;
|
||||||
use danog\MadelineProto\EventHandler\Pinned;
|
use danog\MadelineProto\EventHandler\Pinned;
|
||||||
use danog\MadelineProto\EventHandler\Pinned\PinnedChannelMessages;
|
use danog\MadelineProto\EventHandler\Pinned\PinnedChannelMessages;
|
||||||
use danog\MadelineProto\EventHandler\Pinned\PinnedGroupMessages;
|
use danog\MadelineProto\EventHandler\Pinned\PinnedGroupMessages;
|
||||||
@ -128,6 +133,7 @@ use danog\MadelineProto\TL\Types\Button;
|
|||||||
use danog\MadelineProto\UpdateHandlerType;
|
use danog\MadelineProto\UpdateHandlerType;
|
||||||
use danog\MadelineProto\VoIP\DiscardReason;
|
use danog\MadelineProto\VoIP\DiscardReason;
|
||||||
use danog\MadelineProto\VoIPController;
|
use danog\MadelineProto\VoIPController;
|
||||||
|
use DialogGiftStars;
|
||||||
use Revolt\EventLoop;
|
use Revolt\EventLoop;
|
||||||
use SplQueue;
|
use SplQueue;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
@ -490,6 +496,7 @@ trait UpdateHandler
|
|||||||
'updatePendingJoinRequests' => new PendingJoinRequests($this, $update),
|
'updatePendingJoinRequests' => new PendingJoinRequests($this, $update),
|
||||||
'updateBotChatInviteRequester' => new BotChatInviteRequest($this, $update),
|
'updateBotChatInviteRequester' => new BotChatInviteRequest($this, $update),
|
||||||
'updateBotCommands' => new BotCommands($this, $update),
|
'updateBotCommands' => new BotCommands($this, $update),
|
||||||
|
'updateBotPrecheckoutQuery' => new Payment($this, $update),
|
||||||
default => null
|
default => null
|
||||||
};
|
};
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
@ -684,6 +691,37 @@ trait UpdateHandler
|
|||||||
$message['action']['text'],
|
$message['action']['text'],
|
||||||
null
|
null
|
||||||
),
|
),
|
||||||
|
'messageActionGiftStars' => new DialogGiftStars(
|
||||||
|
$this,
|
||||||
|
$message,
|
||||||
|
$info,
|
||||||
|
$message['action']['currency'],
|
||||||
|
$message['action']['amount'],
|
||||||
|
$message['action']['stars'],
|
||||||
|
$message['action']['crypto_currency'] ?? null,
|
||||||
|
$message['action']['crypto_amount'] ?? null,
|
||||||
|
$message['action']['transaction_id'],
|
||||||
|
),
|
||||||
|
'messageActionStarGift' => new DialogStarGift(
|
||||||
|
$this,
|
||||||
|
$message,
|
||||||
|
$info,
|
||||||
|
$message['action']['name_hidden'] ?? null,
|
||||||
|
$message['action']['saved'] ?? null,
|
||||||
|
$message['action']['converted'] ?? null,
|
||||||
|
new StarGift(
|
||||||
|
$this,
|
||||||
|
$message['action']['gift']
|
||||||
|
),
|
||||||
|
isset($message['action']['message']) ? new TextWithEntities(
|
||||||
|
$message['action']['message']['text'],
|
||||||
|
MessageEntity::fromRawEntities($message['action']['message']['entities']),
|
||||||
|
isset($message['action']['message']['parse_mode']) ?
|
||||||
|
ParseMode::fromString($message['action']['message']['parse_mode'])
|
||||||
|
: null
|
||||||
|
) : null,
|
||||||
|
$message['action']['convert_stars'],
|
||||||
|
),
|
||||||
'messageActionGiftPremium' => new DialogGiftPremium(
|
'messageActionGiftPremium' => new DialogGiftPremium(
|
||||||
$this,
|
$this,
|
||||||
$message,
|
$message,
|
||||||
|
@ -24,4 +24,14 @@ enum ParseMode: string
|
|||||||
case HTML = 'HTML';
|
case HTML = 'HTML';
|
||||||
case MARKDOWN = 'Markdown';
|
case MARKDOWN = 'Markdown';
|
||||||
case TEXT = 'text';
|
case TEXT = 'text';
|
||||||
|
/** @internal */
|
||||||
|
public static function fromString(string $mode): ?string
|
||||||
|
{
|
||||||
|
foreach (self::cases() as $case) {
|
||||||
|
if(strtoupper($mode) === $case->name) {
|
||||||
|
return $case->value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user