From 0cb716a9acb90d580281f1f3b7c107b7bace7ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=8B=D1=80=D1=86=D0=B5=D0=B2=20=D0=92=D0=B0=D0=B4?= =?UTF-8?q?=D0=B8=D0=BC=20=D0=98=D0=B3=D0=BE=D1=80=D0=B5=D0=B2=D0=B8=D1=87?= Date: Wed, 31 Jul 2024 15:50:02 +0300 Subject: [PATCH] Add `CallbackQuery::regular_message` getter --- crates/teloxide-core/CHANGELOG.md | 1 + crates/teloxide-core/src/types/callback_query.rs | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/teloxide-core/CHANGELOG.md b/crates/teloxide-core/CHANGELOG.md index 4ee5206a..34b7ec97 100644 --- a/crates/teloxide-core/CHANGELOG.md +++ b/crates/teloxide-core/CHANGELOG.md @@ -119,6 +119,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Other Changes - Add fields `ChafFullInfo::{has_visible_history, accent_color_id, background_custom_emoji_id, profile_accent_color_id, profile_background_custom_emoji_id}` - Add `RequestId` type + - Add `CallbackQuery::regular_message` getter [pr851]: https://github.com/teloxide/teloxide/pull/851 [pr887]: https://github.com/teloxide/teloxide/pull/887 diff --git a/crates/teloxide-core/src/types/callback_query.rs b/crates/teloxide-core/src/types/callback_query.rs index 511ac32e..a31d61d7 100644 --- a/crates/teloxide-core/src/types/callback_query.rs +++ b/crates/teloxide-core/src/types/callback_query.rs @@ -60,13 +60,15 @@ impl CallbackQuery { use crate::util::flatten; use std::iter::once; - once(&self.from).chain(flatten( - self.message - .as_ref() - // If we can access the message - .and_then(|maybe| maybe.message()) - .map(Message::mentioned_users), - )) + once(&self.from).chain(flatten(self.regular_message().map(Message::mentioned_users))) + } + + #[must_use] + pub fn regular_message(&self) -> Option<&Message> { + self.message + .as_ref() + // If we can access the message + .and_then(|maybe| maybe.message()) } }