From f9741c250d628c9aaef7d51a6a9f63baf6a11f1d Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 9 Dec 2024 12:19:42 -0500 Subject: [PATCH] Added `containsMedia` method to `Message` object to check if the message contains media. --- CHANGELOG.md | 4 +++- src/TgBotLib/Objects/Message.php | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9edcd6..1614807 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [8.0.2] - Ongoing +## [8.0.2] - 2024-12-09 This update introduces some quality of life improvements. + * Added `containsMedia` method to `Message` object to check if the message contains media. + ## [8.0.1] - 2024-12-04 diff --git a/src/TgBotLib/Objects/Message.php b/src/TgBotLib/Objects/Message.php index eea2524..de99c31 100644 --- a/src/TgBotLib/Objects/Message.php +++ b/src/TgBotLib/Objects/Message.php @@ -1061,6 +1061,16 @@ return null; } + /** + * Checks if any media content is present in the message. + * + * @return bool True if media content is present, false otherwise. + */ + public function containsMedia(): bool + { + return $this->getPhoto() !== null || $this->getAnimation() !== null || $this->getAudio() !== null || $this->getDocument() !== null || $this->getSticker() !== null || $this->getVideo() !== null || $this->getVideoNote() !== null || $this->getVoice() !== null; + } + /** * @inheritDoc */