Load API ID and hash from env

This commit is contained in:
Lonami Exo 2022-10-20 21:18:33 +02:00
parent a341466749
commit 0f412f7334
1 changed files with 15 additions and 2 deletions

View File

@ -25,8 +25,21 @@ type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
const LOG_MIN_LEVEL: Level = Level::Trace;
const LOG_TAG: &str = ".native.talari";
const API_ID: i32 = 0;
const API_HASH: &str = "";
const API_ID: i32 = {
let mut index = 0;
let mut value = 0;
let api_id = env!("TALARIA_API_ID");
let bytes = api_id.as_bytes();
while index < bytes.len() {
match bytes[index] {
b @ b'0'..=b'9' => value = value * 10 + (b - b'0') as i32,
_ => panic!("non-digit character found in API ID"),
}
index += 1
}
value
};
const API_HASH: &str = env!("TALARIA_API_HASH");
static RUNTIME: OnceCell<Runtime> = OnceCell::new();
static CLIENT: OnceCell<Client> = OnceCell::new();