Add support for business message events

This commit is contained in:
netkas 2024-11-03 17:11:16 -05:00
parent b40ee01d6e
commit 2f87996bd3
3 changed files with 36 additions and 0 deletions

View file

@ -146,6 +146,11 @@
return UpdateEventType::EDITED_BUSINESS_MESSAGE; return UpdateEventType::EDITED_BUSINESS_MESSAGE;
} }
if($update->getBusinessMessage() !== null)
{
return UpdateEventType::BUSINESS_MESSAGE;
}
return UpdateEventType::UPDATE_EVENT; return UpdateEventType::UPDATE_EVENT;
} }
} }

View file

@ -3,6 +3,7 @@
namespace TgBotLib\Enums; namespace TgBotLib\Enums;
use TgBotLib\Abstracts\UpdateEvent; use TgBotLib\Abstracts\UpdateEvent;
use TgBotLib\Events\BusinessMessageEvent;
use TgBotLib\Events\CallbackQueryEvent; use TgBotLib\Events\CallbackQueryEvent;
use TgBotLib\Events\ChatBoostEvent; use TgBotLib\Events\ChatBoostEvent;
use TgBotLib\Events\ChatJoinRequestEvent; use TgBotLib\Events\ChatJoinRequestEvent;
@ -42,4 +43,5 @@
case MESSAGE_REACTION = MessageReactionEvent::class; case MESSAGE_REACTION = MessageReactionEvent::class;
case DELETED_BUSINESS_MESSAGES = DeletedBusinessMessagesEvent::class; case DELETED_BUSINESS_MESSAGES = DeletedBusinessMessagesEvent::class;
case EDITED_BUSINESS_MESSAGE = EditedBusinessMessageEvent::class; case EDITED_BUSINESS_MESSAGE = EditedBusinessMessageEvent::class;
case BUSINESS_MESSAGE = BusinessMessageEvent::class;
} }

View file

@ -0,0 +1,29 @@
<?php
namespace TgBotLib\Events;
use TgBotLib\Abstracts\UpdateEvent;
use TgBotLib\Bot;
use TgBotLib\Enums\UpdateEventType;
use TgBotLib\Objects\Message;
abstract class BusinessMessageEvent extends UpdateEvent
{
/**
* @inheritDoc
*/
public static function getEventType(): UpdateEventType
{
return UpdateEventType::BUSINESS_MESSAGE;
}
/**
* New incoming business message
*
* @return Message
*/
protected function getBusinessMessage(): Message
{
return $this->update->getBusinessMessage();
}
}