From ba6e991b235901822d9ce54653c46ba9b0db6b01 Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 4 Nov 2024 01:17:15 -0500 Subject: [PATCH] Add method to retrieve any available message --- src/TgBotLib/Objects/Update.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/TgBotLib/Objects/Update.php b/src/TgBotLib/Objects/Update.php index 6522424..8524fb0 100644 --- a/src/TgBotLib/Objects/Update.php +++ b/src/TgBotLib/Objects/Update.php @@ -295,6 +295,24 @@ return $this->removed_chat_boost; } + /** + * Retrieves any type of message that is currently available. This method checks for the presence of a standard message, + * an edited message, a channel post, an edited channel post, a business message, or an edited business message, + * and returns the first one found. + * + * @return Message|null + */ + public function getAnyMessage(): ?Message + { + return + $this->message ?? + $this->edited_message ?? + $this->channel_post ?? + $this->edited_channel_post ?? + $this->business_message ?? + $this->edited_business_message; + } + /** * @inheritDoc */