maxbot 0.1.13

Автоматизация работы с чат-ботами на платформе MAX (max.ru)
Documentation
// Демонстрация получения информации о групповом чате по chat_id

use maxbot::MaxClient;
use std::env;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let token = env::var("MAXBOT_TOKEN").expect("Missing MAXBOT_TOKEN");
    let chat_id = env::var("CHAT_ID")
        .expect("Missing CHAT_ID")
        .parse::<i64>()?;

    if let Ok(proxy_url) = env::var("MAXBOT_PROXY") {
        maxbot::set_global_base_url(proxy_url);
    }

    let client = MaxClient::new(token);
    let chat = client.get_chat(chat_id).await?;

    println!("Chat ID: {}", chat.chat_id);
    println!("Type: {}", chat.r#type);
    println!("Status: {}", chat.status);
    if let Some(title) = chat.title {
        println!("Title: {}", title);
    }
    if let Some(icon) = chat.icon {
        println!("Icon URL: {}", icon.url);
    }
    println!("Last event time: {}", chat.last_event_time);
    println!("Participants count: {}", chat.participants_count);
    if let Some(owner_id) = chat.owner_id {
        println!("Owner ID: {}", owner_id);
    }
    println!("Is public: {}", chat.is_public);
    if let Some(link) = chat.link {
        println!("Link: {}", link);
    }
    if let Some(desc) = chat.description {
        println!("Description: {}", desc);
    }
    if let Some(dialog_user) = chat.dialog_with_user {
        println!("Dialog with user: {} (ID: {})", dialog_user.first_name, dialog_user.user_id);
    }
    if let Some(pinned) = chat.pinned_message {
        println!("Pinned message exists: {:?}", pinned);
    }

    Ok(())
}