diff --git a/CHANGELOG.md b/CHANGELOG.md index f9f518f6..efe3a738 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `UserId::{url, is_anonymous, is_channel, is_telegram}` convenience functions ([#197][pr197]) - `User::{tme_url, preferably_tme_url}` convenience functions ([#197][pr197]) - `Me::username` and `Deref` implementation for `Me` ([#197][pr197]) +- `Me::{mention, tme_url}` ([#197][pr197]) [pr197]: https://github.com/teloxide/teloxide-core/pull/197 diff --git a/src/types/me.rs b/src/types/me.rs index d404690a..5bc6a7cd 100644 --- a/src/types/me.rs +++ b/src/types/me.rs @@ -32,6 +32,16 @@ impl Me { .as_deref() .expect("Bots must have usernames") } + + /// Returns a username mention of this bot. + pub fn mention(&self) -> String { + format!("@{}", self.username()) + } + + /// Returns an URL that links to this bot in the form of `t.me/<...>`. + pub fn tme_url(&self) -> reqwest::Url { + format!("https://t.me/{}", self.username()).parse().unwrap() + } } impl Deref for Me {