Add CallbackQuery::regular_message getter

This commit is contained in:
Сырцев Вадим Игоревич 2024-07-31 15:50:02 +03:00 committed by Andrey Brusnik
parent a353439e3b
commit 0cb716a9ac
No known key found for this signature in database
GPG key ID: D33232F28CFF442C
2 changed files with 10 additions and 7 deletions

View file

@ -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

View file

@ -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())
}
}