From 0f412f7334ff5e210aa63186806a16f96c6346ad Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 20 Oct 2022 21:18:33 +0200 Subject: [PATCH] Load API ID and hash from env --- native/src/lib.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/native/src/lib.rs b/native/src/lib.rs index 0048979..9201a7d 100644 --- a/native/src/lib.rs +++ b/native/src/lib.rs @@ -25,8 +25,21 @@ type Result = std::result::Result>; 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 = OnceCell::new(); static CLIENT: OnceCell = OnceCell::new();