Skip to main content

simple_methods_demo/
simple-methods-demo.rs

1//! Демонстрация простых методов отправки.
2
3use maxbot::{ContactData, InlineKeyboardButton, InlineKeyboardBuilder, MaxClient, MaxClientSimpleExt};
4
5#[tokio::main]
6async fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let client = MaxClient::from_env().expect("MAXBOT_TOKEN not set");
8    let chat_id = std::env::var("CHAT_ID")
9        .expect("CHAT_ID not set")
10        .parse::<i64>()?;
11
12    client.send_plain_text_to_chat(chat_id, "Hello from simple method!").await?;
13    client.send_markdown_to_chat(chat_id, "**Bold** text").await?;
14    client.send_html_to_chat(chat_id, "<b>Bold</b> text").await?;
15    client.send_sticker_to_chat(chat_id, "154ed15bb").await?;
16    client.send_location_to_chat(chat_id, 55.7558, 37.6176).await?;
17
18    let contact = ContactData {
19        name: Some("Max Bot".to_string()),
20        contact_id: Some(client.get_me().await?.user.user_id),
21        vcf_info: None,
22        vcf_phone: None,
23    };
24    client.send_contact_to_chat(chat_id, contact).await?;
25
26    client.send_share_to_chat(chat_id, "https://dev.max.ru", Some("API MAX")).await?;
27
28    let keyboard = InlineKeyboardBuilder::new()
29        .button(InlineKeyboardButton::callback("Нажми", "data"))
30        .build()?;
31    client.send_keyboard_to_chat(chat_id, "Кнопка:", keyboard).await?;
32
33    Ok(())
34}