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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// 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.
//! Raw / escape-hatch API caller.
//!
//! Use [`Bot::raw`] to call **any** Telegram Bot API method by name, using a
//! chainable builder. This lets you use new or niche Bot API features without
//! waiting for a typed wrapper to be generated.
//!
//! # Example
//!
//! ```rust,no_run
//! use ferobot::Bot;
//! use serde_json::Value;
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), ferobot::BotError> {
//! let bot = Bot::new("YOUR_TOKEN").await?;
//!
//! // Call sendMessage with chained params
//! let msg: Value = bot
//! .raw("sendMessage")
//! .param("chat_id", 123456789_i64)
//! .param("text", "Hello from raw!")
//! .param("parse_mode", "HTML")
//! .call()
//! .await?;
//!
//! println!("message_id = {}", msg["message_id"]);
//!
//! // Use any feature flag e.g. sendMessage with reply_parameters
//! let _: Value = bot
//! .raw("sendMessage")
//! .param("chat_id", 123456789_i64)
//! .param("text", "Replying!")
//! .param("reply_parameters", serde_json::json!({ "message_id": 42 }))
//! .call()
//! .await?;
//!
//! // Upload a file via multipart
//! let photo = ferobot::InputFile::memory("photo.jpg", std::fs::read("photo.jpg").unwrap());
//! let _: Value = bot
//! .raw("sendPhoto")
//! .param("chat_id", 123456789_i64)
//! .file("photo", photo)
//! .call()
//! .await?;
//! # Ok(())
//! # }
//! ```
use ;
use crate::;
/// A chainable raw API request builder returned by [`Bot::raw`].
///
/// Build up parameters with [`.param()`](RawRequest::param), optionally attach
/// a file upload with [`.file()`](RawRequest::file), then execute with
/// [`.call::<T>()`](RawRequest::call).