Add support for Paid Media Purchased event
This commit is contained in:
parent
39821585e4
commit
c57cdfe05c
3 changed files with 35 additions and 0 deletions
|
@ -96,6 +96,11 @@
|
|||
return UpdateEventType::POLL;
|
||||
}
|
||||
|
||||
if($update->getPurchasedPaidMedia() !== null)
|
||||
{
|
||||
return UpdateEventType::PAID_MEDIA_PURCHASED;
|
||||
}
|
||||
|
||||
return UpdateEventType::UPDATE_EVENT;
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
use TgBotLib\Events\MyChatMemberUpdatedEvent;
|
||||
use TgBotLib\Events\PollAnswerEvent;
|
||||
use TgBotLib\Events\PollEvent;
|
||||
use TgBotLib\Events\PaidMediaPurchasedEvent;
|
||||
use TgBotLib\Events\RemovedChatBoostEvent;
|
||||
|
||||
enum UpdateEventType : string
|
||||
|
@ -21,4 +22,5 @@
|
|||
case MY_CHAT_MEMBER_UPDATED = MyChatMemberUpdatedEvent::class;
|
||||
case POLL_ANSWER = PollAnswerEvent::class;
|
||||
case POLL = PollEvent::class;
|
||||
case PAID_MEDIA_PURCHASED = PaidMediaPurchasedEvent::class;
|
||||
}
|
||||
|
|
28
src/TgBotLib/Events/PaidMediaPurchasedEvent.php
Normal file
28
src/TgBotLib/Events/PaidMediaPurchasedEvent.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Events;
|
||||
|
||||
use TgBotLib\Abstracts\UpdateEvent;
|
||||
use TgBotLib\Enums\UpdateEventType;
|
||||
use TgBotLib\Objects\Payments\PaidMediaPurchased;
|
||||
|
||||
abstract class PaidMediaPurchasedEvent extends UpdateEvent
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function getEventType(): UpdateEventType
|
||||
{
|
||||
return UpdateEventType::PAID_MEDIA_PURCHASED;
|
||||
}
|
||||
|
||||
/**
|
||||
* A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat
|
||||
*
|
||||
* @return PaidMediaPurchased
|
||||
*/
|
||||
protected function getPurchasedPaidMedia(): PaidMediaPurchased
|
||||
{
|
||||
return $this->update->getPurchasedPaidMedia();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue