mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-13 19:27:52 +01:00
added struct Me
This commit is contained in:
parent
95b190e573
commit
a95bb5b2d9
2 changed files with 19 additions and 3 deletions
|
@ -2,10 +2,10 @@ use super::BotWrapper;
|
|||
use crate::{
|
||||
net,
|
||||
requests::{Request, ResponseResult},
|
||||
types::User,
|
||||
Bot,
|
||||
};
|
||||
use serde::Serialize;
|
||||
use crate::types::Me;
|
||||
|
||||
/// A simple method for testing your bot's auth token. Requires no parameters.
|
||||
///
|
||||
|
@ -18,11 +18,11 @@ pub struct GetMe<'a> {
|
|||
|
||||
#[async_trait::async_trait]
|
||||
impl Request for GetMe<'_> {
|
||||
type Output = User;
|
||||
type Output = Me;
|
||||
|
||||
/// Returns basic information about the bot.
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
async fn send(&self) -> ResponseResult<User> {
|
||||
async fn send(&self) -> ResponseResult<Me> {
|
||||
net::request_json(self.bot.client(), self.bot.token(), "getMe", &self)
|
||||
.await
|
||||
}
|
||||
|
|
|
@ -46,6 +46,22 @@ impl User {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returned only in GetMe
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Me {
|
||||
#[serde(flatten)]
|
||||
pub user: User,
|
||||
|
||||
/// True, if the bot can be invited to groups.
|
||||
pub can_join_groups: bool,
|
||||
|
||||
/// True, if [privacy mode](https://core.telegram.org/bots#privacy-mode) is disabled for the bot.
|
||||
pub can_read_all_group_messages: bool,
|
||||
|
||||
/// True, if the bot supports inline queries.
|
||||
pub supports_inline_queries: bool,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Add table
Reference in a new issue