mirror of
https://github.com/mii443/rs-docker-bot.git
synced 2025-08-22 16:15:40 +00:00
support file returning
This commit is contained in:
@ -89,7 +89,7 @@ async fn on_message(ctx: &serenity::Context, data: &Data, message: &Message) {
|
||||
let timeout = Arc::new(Mutex::new(false));
|
||||
let t = Arc::clone(&timeout);
|
||||
tokio::spawn(async move {
|
||||
sleep_until(Instant::now() + Duration::from_secs(30)).await;
|
||||
sleep_until(Instant::now() + Duration::from_secs(120)).await;
|
||||
if let Ok(_) = end_tx.send(()) {
|
||||
*t.lock().unwrap() = true;
|
||||
}
|
||||
@ -129,6 +129,23 @@ async fn on_message(ctx: &serenity::Context, data: &Data, message: &Message) {
|
||||
}
|
||||
}
|
||||
|
||||
let paths: Vec<&str> = if let Some(matc) = captures.name("paths") {
|
||||
matc.as_str()
|
||||
} else {
|
||||
""
|
||||
}
|
||||
.lines()
|
||||
.filter(|l| !l.is_empty())
|
||||
.collect();
|
||||
|
||||
for path in paths {
|
||||
if let Ok(file) = container.download_file(path).await {
|
||||
edit_message = edit_message.new_attachment(CreateAttachment::bytes(file, path));
|
||||
} else {
|
||||
content += &format!("\nFile not found: `{}`", path);
|
||||
}
|
||||
}
|
||||
|
||||
edit_message = edit_message.content(content);
|
||||
|
||||
message.edit(&ctx.http, edit_message).await.unwrap();
|
||||
|
Reference in New Issue
Block a user