Define the 'core' layout

This commit is contained in:
Temirkhan Myrzamadi 2019-09-02 11:17:20 +06:00
parent 9ffb2d45ef
commit 83287a7544
10 changed files with 8 additions and 37 deletions

View file

@ -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
View file

View file

0
src/core/inline_mode.rs Normal file
View file

View 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
View file

0
src/core/stickers.rs Normal file
View file

View file

View file