Add method `MessageEntity::user_mention`
use serde::{Deserialize, Serialize};
-use crate::types::User;
+use crate::types::{User, UserId};
/// This object represents one special entity in a text message.
///
@@ -28,6 +28,16 @@ impl MessageEntity {
}
}
+ /// Create a message entity representing a text link in the form of
+ /// `tg://user/?id=...` that mentions user with `user_id`.
+ pub fn user_mention(user_id: UserId, offset: usize, length: usize) -> Self {
+ Self {
+ kind: MessageEntityKind::TextLink { url: user_id.url() },
+ offset,
+ length,
+ }
+ }
+
pub fn kind(mut self, val: MessageEntityKind) -> Self {
self.kind = val;
self
