summaryrefslogtreecommitdiffstats
path: root/src/main.rs
blob: 289ad02f3db568055bd53cecb80a70225f12a373 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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();
}
*/