mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 06:25:10 +01:00
Define the 'core' layout
This commit is contained in:
parent
9ffb2d45ef
commit
83287a7544
10 changed files with 8 additions and 37 deletions
|
@ -1,35 +0,0 @@
|
|||
use crate::core::types::User;
|
||||
use crate::core::{Error, Response, TELEGRAM_URL_START, REQWEST_CLIENT};
|
||||
use serde_json::Value;
|
||||
use futures::compat::Future01CompatExt;
|
||||
|
||||
pub async fn get_me(bot_token: &str) -> Response<User> {
|
||||
let mut response = REQWEST_CLIENT
|
||||
.get(&format!(
|
||||
"{}{bot_token}/getMe",
|
||||
TELEGRAM_URL_START,
|
||||
bot_token = bot_token
|
||||
))
|
||||
.send()
|
||||
.compat()
|
||||
.await
|
||||
.map_err(Error::Send)?;
|
||||
|
||||
let response_json = response
|
||||
.json::<Value>()
|
||||
.compat()
|
||||
.await
|
||||
.map_err(Error::InvalidJson)?;
|
||||
|
||||
if response_json["ok"] == "false" {
|
||||
return Err(Error::Api {
|
||||
status_code: response.status(),
|
||||
description: match response_json.get("description") {
|
||||
None => None,
|
||||
Some(description) => Some(description.to_string()),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Ok(serde_json::from_value(response_json["result"].clone()).unwrap())
|
||||
}
|
0
src/core/games.rs
Normal file
0
src/core/games.rs
Normal file
0
src/core/getting_updates.rs
Normal file
0
src/core/getting_updates.rs
Normal file
0
src/core/inline_mode.rs
Normal file
0
src/core/inline_mode.rs
Normal file
|
@ -2,8 +2,14 @@ use reqwest::r#async::Client;
|
|||
|
||||
use reqwest::StatusCode;
|
||||
|
||||
mod functions;
|
||||
mod types;
|
||||
mod games;
|
||||
mod getting_updates;
|
||||
mod inline_mode;
|
||||
mod other;
|
||||
mod payments;
|
||||
mod stickers;
|
||||
mod telegram_passport;
|
||||
mod updating_messages;
|
||||
|
||||
lazy_static! {
|
||||
static ref REQWEST_CLIENT: Client = Client::new();
|
||||
|
|
0
src/core/payments.rs
Normal file
0
src/core/payments.rs
Normal file
0
src/core/stickers.rs
Normal file
0
src/core/stickers.rs
Normal file
0
src/core/telegram_passport.rs
Normal file
0
src/core/telegram_passport.rs
Normal file
0
src/core/updating_messages.rs
Normal file
0
src/core/updating_messages.rs
Normal file
Loading…
Reference in a new issue