19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
+
+
|
Bot,
prelude::{
Requester,
RequesterExt,
},
types::{
ChatId,
InputMedia,
Message,
ParseMode::MarkdownV2,
},
};
use std::{
borrow::Cow,
collections::{
|
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
-
+
-
-
|
.ok_or(anyhow!("Failed to extract text from message."))?;
if text.len() < 4096 - header_size {
body = text;
text_num = 1;
}
};
reply.push("```".into());
for line in body.lines() {
reply.extend(body.lines().map(|x| x.into()));
reply.push(line.into());
}
reply.push("```".into());
// and let's collect all other attachment parts
let mut files_to_send = vec![];
/*
* let's just skip html parts for now, they just duplicate text?
while html_num < html_parts {
|
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
-
+
|
.file_name(filename));
let item = if first_one {
first_one = false;
item.caption(&msg).parse_mode(MarkdownV2)
} else {
item
};
files.push(teloxide::types::InputMedia::Document(item));
files.push(InputMedia::Document(item));
}
core.sendgroup(chat, files).await?;
} else {
core.send(chat, &msg).await?;
}
}
|
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
-
+
-
+
-
-
+
+
|
TelegramTransport {
tg,
recipients,
}
}
pub async fn debug<'b, S>(&self, msg: S) -> Result<teloxide::types::Message>
pub async fn debug<'b, S>(&self, msg: S) -> Result<Message>
where S: Into<String> {
Ok(self.tg.send_message(*self.recipients.get("_").unwrap(), msg).await?)
}
pub async fn send<'b, S>(&self, to: &ChatId, msg: S) -> Result<teloxide::types::Message>
pub async fn send<'b, S>(&self, to: &ChatId, msg: S) -> Result<Message>
where S: Into<String> {
Ok(self.tg.send_message(*to, msg).await?)
}
pub async fn sendgroup<M>(&self, to: &ChatId, media: M) -> Result<Vec<teloxide::types::Message>>
where M: IntoIterator<Item = teloxide::types::InputMedia> {
pub async fn sendgroup<M>(&self, to: &ChatId, media: M) -> Result<Vec<Message>>
where M: IntoIterator<Item = InputMedia> {
Ok(self.tg.send_media_group(*to, media).await?)
}
}
#[async_std::main]
async fn main() {
let settings: config::Config = config::Config::builder()
|