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
// Copyright (c) Ankit Chaubey <ankitchaubey.dev@gmail.com>
// SPDX-License-Identifier: MIT OR Apache-2.0
//
// ferobot: async Telegram Bot API framework written in Rust
// Repository: https://github.com/ankit-chaubey/ferobot
//
// Ferobot provides a fast and ergonomic framework for building Telegram bots
// using the official Telegram Bot API.
//
// Author: Ankit Chaubey
//
// If you use or modify this code, keep this notice at the top of your file
// and include the LICENSE-MIT or LICENSE-APACHE file from this repository.
//! Ergonomic macros for building optional parameter structs.
//!
//! # `p!` - build params inline
//!
//! Instead of writing:
//! ```rust,ignore
//! bot.send_message_with_params(chat_id, "Hi", Some(SendMessageParams {
//! parse_mode: Some("HTML".into()),
//! disable_notification: Some(true),
//! ..Default::default()
//! })).await?;
//! ```
//!
//! Write:
//! ```rust,ignore
//! use ferobot::p;
//! use ferobot::gen_methods::SendMessageParams;
//!
//! bot.send_message(chat_id, "Hi")
//! .parse_mode("HTML")
//! .disable_notification(true)
//! .await?;
//! ```
/// Build an optional Telegram params struct with named fields.
///
/// Each field value is wrapped in `Some(value.into())` automatically.
/// All other fields are filled with `Default::default()`.
/// The whole expression evaluates to `Some(ParamsStruct { ... })`.
///
/// Use `p!(T)` (no braces) to produce `None::<T>` (no options set).
///
/// # Example
/// ```rust,ignore
/// use ferobot::{p, gen_methods::{SendMessageParams, BanChatMemberParams}};
///
/// // With options (fluent chain)
/// bot.send_message(chat_id, "Hello!")
/// .parse_mode("HTML")
/// .disable_notification(true)
/// .await?;
///
/// // No options - just await directly
/// bot.send_message(chat_id, "Hello!").await?;
///
/// // Or use the raw method with a params struct
/// bot.send_message_with_params(chat_id, "Hello!", None).await?;
/// ```