diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..289ad02 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,54 @@ +use std::env; +use tokio; + +mod client; +//mod auth; +mod update; +//mod message; + +#[tokio::main] +async fn main() { + dotenv::dotenv().ok(); + env_logger::init(); + let tg_log: Option<i32> = env::var("TG_LOG") + .ok() + .and_then(|var| var.parse().ok()); + + let mut tg = client::Client::new(tg_log); + + tokio::spawn(async move { + let _auth_state = tg.send( + &json::object!{ + "@type": "getAuthorizationState" + } + ).await; + let cache = env::current_dir().unwrap().join("cache"); + let resp = tg.send(&json::object!{ + "@type": "setTdlibParameters", + "parameters": { + "use_test_dc": false, + "api_id": env::var("API_ID").unwrap(), + "api_hash": env::var("API_HASH").unwrap(), + "device_model": "mbia", + "system_version": "Catalina", + "application_version": "0.1", + "system_language_code": "en", + "database_directory": cache.join("database").to_str().unwrap(), + "use_message_database": false, + "files_directory": cache.join("files").to_str().unwrap(), + "use_secret_chats": false, + }, + }).await; + println!("resp: {}", resp); + }); + std::thread::sleep(std::time::Duration::new(1, 0)); +} + + +/* +fn main() { + runtime::Runtime::new(|arc_msg, tx| { + tx.send(std::sync::Arc::new(runtime::Task{})).unwrap(); + }).run(); +} +*/ |