added struct Me

This commit is contained in:
p0lunin 2020-02-04 23:13:31 +02:00
parent 95b190e573
commit a95bb5b2d9
2 changed files with 19 additions and 3 deletions

View file

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

View file

@ -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::*;