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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! # maxoxide
//!
//! An async Rust library for building bots on the [Max messenger](https://max.ru) platform,
//! inspired by [teloxide](https://github.com/teloxide/teloxide).
//!
//! ## Quick start
//!
//! ```no_run
//! use maxoxide::{Bot, Dispatcher, Context};
//! use maxoxide::types::Update;
//!
//! #[tokio::main]
//! async fn main() {
//! tracing_subscriber::fmt::init();
//!
//! let bot = Bot::from_env(); // reads MAX_BOT_TOKEN
//! let mut dp = Dispatcher::new(bot);
//!
//! // Echo every message back.
//! dp.on_message(|ctx: Context| async move {
//! if let Update::MessageCreated { message, .. } = &ctx.update {
//! let text = message.text().unwrap_or("(no text)").to_string();
//! ctx.bot.send_text_to_chat(message.chat_id(), text).await?;
//! }
//! Ok(())
//! });
//!
//! dp.start_polling().await;
//! }
//! ```
//!
//! ## Recipient IDs
//!
//! MAX uses two different identifiers that are easy to confuse:
//!
//! - `user_id` is the global MAX ID of a user.
//! - `chat_id` is the ID of a concrete dialog, group, or channel.
//!
//! In a private dialog you often have both:
//!
//! - `message.sender.user_id` is the stable user identifier.
//! - `message.chat_id()` is the identifier of that specific dialog with the bot.
//!
//! Use the chat-based helpers when you already know a dialog/group `chat_id`:
//!
//! ```no_run
//! # use maxoxide::Bot;
//! # async fn example(bot: Bot, chat_id: i64) -> maxoxide::Result<()> {
//! bot.send_text_to_chat(chat_id, "Reply into the existing dialog").await?;
//! # Ok(())
//! # }
//! ```
//!
//! Use the user-based helpers when you only know the global MAX `user_id`:
//!
//! ```no_run
//! # use maxoxide::Bot;
//! # async fn example(bot: Bot, user_id: i64) -> maxoxide::Result<()> {
//! bot.send_text_to_user(user_id, "Send by global user ID").await?;
//! # Ok(())
//! # }
//! ```
// Re-export the most commonly used items at the crate root.
pub use Bot;
pub use ;
pub use ;
pub use reqwest;