Skip to main content

BotFullInfo

Struct BotFullInfo 

Source
pub struct BotFullInfo {
Show 18 fields pub id: UserId, pub is_bot: True, pub first_name: String, pub username: Option<String>, pub active_usernames: Option<Vec<String>>, pub can_join_groups: bool, pub can_read_all_group_messages: bool, pub supports_guest_queries: bool, pub supports_inline_queries: bool, pub inline_query_placeholder: Option<String>, pub needs_inline_query_location: bool, pub can_connect_to_business: bool, pub has_main_web_app: bool, pub has_topics_enabled: bool, pub allows_users_to_create_topics: bool, pub has_topic_sidebar: bool, pub can_manage_bots: bool, pub supports_join_request_queries: bool,
}
Expand description

Full information about the bot itself, returned by GetMe.

Settings absent in older Bot API responses are treated as disabled.

The official docs.

Fields§

§id: UserId

Unique identifier of the bot.

§is_bot: True

Always true.

§first_name: String

First name of the bot.

§username: Option<String>

Primary username of the bot, if assigned.

§active_usernames: Option<Vec<String>>

All active usernames of the bot, if nonempty.

§can_join_groups: bool

Whether the bot can be added to groups.

§can_read_all_group_messages: bool

Whether privacy mode is disabled for the bot.

§supports_guest_queries: bool

Whether the bot supports guest queries from chats it is not a member of.

§supports_inline_queries: bool

Whether the bot supports inline queries.

§inline_query_placeholder: Option<String>

Placeholder shown in the input field after the bot’s username in inline mode, if not using the default.

§needs_inline_query_location: bool

Whether the bot requests the user’s location with every inline query.

§can_connect_to_business: bool

Whether the bot can be connected to a user account to manage it.

§has_main_web_app: bool

Whether the bot has a main Web App.

§has_topics_enabled: bool

Whether forum topic mode is enabled in private chats with the bot.

§allows_users_to_create_topics: bool

Whether users can create and delete topics in private chats with the bot.

§has_topic_sidebar: bool

Whether topics are shown in a sidebar in private chats with the bot.

§can_manage_bots: bool

Whether the bot can create and control other bots.

§supports_join_request_queries: bool

Whether the bot can be assigned to process join request queries.

Implementations§

Source§

impl BotFullInfo

Source

pub fn username(&self) -> Option<&str>

Returns the primary username, or the first active username if there is no primary one.

Examples found in repository?
examples/buttons.rs (line 69)
63async fn message_handler(
64    bot: Bot,
65    msg: Message,
66    me: BotFullInfo,
67) -> Result<(), Box<dyn Error + Send + Sync>> {
68    if let Some(text) = msg.text() {
69        match BotCommands::parse(text, me.username().unwrap_or_default()) {
70            Ok(Command::Help) => {
71                // Just send the description of all commands.
72                bot.send_message(Command::descriptions().to_string()).chat_id(msg.chat.id).await?;
73            }
74            Ok(Command::Start) => {
75                // Create a list of buttons and send them.
76                let keyboard = make_keyboard();
77                bot.send_message("Debian versions:")
78                    .chat_id(msg.chat.id)
79                    .reply_markup(keyboard)
80                    .await?;
81            }
82
83            Err(_) => {
84                bot.send_message("Command not found!").chat_id(msg.chat.id).await?;
85            }
86        }
87    }
88
89    Ok(())
90}
Source

pub fn mention(&self) -> Option<String>

Returns a username mention of this bot, if it has a username.

Source

pub fn tme_url(&self) -> Option<Url>

Returns a t.me link to this bot, if it has a username.

Examples found in repository?
examples/deep_linking.rs (line 76)
65pub async fn start(
66    bot: Bot,
67    dialogue: MyDialogue,
68    msg: Message,
69    start: String, // Available from `case![StartCommand::Start(start)]`
70    me: BotFullInfo,
71) -> HandlerResult {
72    if start.is_empty() {
73        // This means that it is just a regular link like https://t.me/some_bot, or a /start command
74        bot.send_message(format!(
75            "Hello!\n\nThis link allows anyone to message you secretly: {}?start={}",
76            me.tme_url().ok_or("The bot needs a public username for deep links")?,
77            msg.chat.id
78        ))
79        .chat_id(msg.chat.id)
80        .await?;
81        dialogue.exit().await?;
82    } else {
83        // And this means that the link is like this: https://t.me/some_bot?start=123456789,
84        // or a /start 123456789 command
85        match start.parse::<i64>() {
86            Ok(id) => {
87                bot.send_message("Send your message:").chat_id(msg.chat.id).await?;
88                dialogue.update(State::WriteToSomeone { id: ChatId(id) }).await?;
89            }
90            Err(_) => {
91                bot.send_message("Bad link!").chat_id(msg.chat.id).await?;
92                dialogue.exit().await?;
93            }
94        }
95    }
96    Ok(())
97}
98
99pub async fn send_message(
100    bot: Bot,
101    id: ChatId, // Available from `State::WriteToSomeone`
102    msg: Message,
103    dialogue: MyDialogue,
104    me: BotFullInfo,
105) -> HandlerResult {
106    match msg.text() {
107        Some(text) => {
108            // Trying to send a message to the user
109            let sent_result = bot
110                .send_message(format!("You have a new message!\n\n<i>{text}</i>"))
111                .chat_id(id)
112                .parse_mode(ParseMode::Html)
113                .await;
114
115            // And if no error is returned, success!
116            if sent_result.is_ok() {
117                bot.send_message(format!(
118                    "Message sent!\n\nYour link is: {}?start={}",
119                    me.tme_url().ok_or("The bot needs a public username for deep links")?,
120                    msg.chat.id
121                ))
122                .chat_id(msg.chat.id)
123                .await?;
124            } else {
125                bot.send_message("Error sending message! Maybe user blocked the bot?")
126                    .chat_id(msg.chat.id)
127                    .await?;
128            }
129            dialogue.exit().await?;
130        }
131        None => {
132            bot.send_message("This bot can send only text.").chat_id(msg.chat.id).await?;
133        }
134    };
135    Ok(())
136}

Trait Implementations§

Source§

impl Clone for BotFullInfo

Source§

fn clone(&self) -> BotFullInfo

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BotFullInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BotFullInfo

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<BotFullInfo, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for BotFullInfo

Source§

impl Hash for BotFullInfo

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for BotFullInfo

Source§

fn eq(&self, other: &BotFullInfo) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for BotFullInfo

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for BotFullInfo

Auto Trait Implementations§

§

impl Forget for BotFullInfo

§

impl Freeze for BotFullInfo

§

impl Move for BotFullInfo

§

impl RefUnwindSafe for BotFullInfo

§

impl Send for BotFullInfo
where RawVecInner: Send,

§

impl Sync for BotFullInfo
where RawVecInner: Sync,

§

impl Unpin for BotFullInfo
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for BotFullInfo

§

impl UnwindSafe for BotFullInfo
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> Erasable for T

Source§

const ACK_1_1_0: bool = true

Available on non-enforce_1_1_0_semantics only.
Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more
Source§

unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>

Unerase this erased pointer. Read more
Source§

fn erase(this: NonNull<Self>) -> NonNull<Erased>

Turn this erasable pointer into an erased pointer. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSync for T
where T: Sync + ?Sized,

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more