mirror of
https://github.com/mii443/rs-docker-bot.git
synced 2025-08-23 00:25:30 +00:00
send log without file writing
This commit is contained in:
@ -122,45 +122,17 @@ async fn on_message(ctx: &serenity::Context, data: &Data, message: &Message) {
|
|||||||
|
|
||||||
if content.len() >= 1000 {
|
if content.len() >= 1000 {
|
||||||
content = "Result log out of length.".to_string();
|
content = "Result log out of length.".to_string();
|
||||||
{
|
|
||||||
let mut result_log =
|
|
||||||
std::fs::File::create(format!("./log/result-{}.txt", container.name))
|
|
||||||
.unwrap();
|
|
||||||
result_log
|
|
||||||
.write_all(buf.lock().unwrap().as_bytes())
|
|
||||||
.unwrap();
|
|
||||||
result_log.flush().unwrap();
|
|
||||||
}
|
|
||||||
let result_log =
|
|
||||||
tokio::fs::File::open(format!("./log/result-{}.txt", container.name))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
edit_message = edit_message.new_attachment(
|
edit_message = edit_message.new_attachment(CreateAttachment::bytes(
|
||||||
CreateAttachment::file(&result_log, "result_log.txt")
|
buf.lock().unwrap().as_bytes(),
|
||||||
.await
|
"result_log.txt",
|
||||||
.unwrap(),
|
));
|
||||||
);
|
|
||||||
|
|
||||||
if !((*compile_buf.lock().unwrap()).is_empty()) {
|
if !((*compile_buf.lock().unwrap()).is_empty()) {
|
||||||
{
|
edit_message = edit_message.new_attachment(CreateAttachment::bytes(
|
||||||
let mut compile_log =
|
compile_buf.lock().unwrap().as_bytes(),
|
||||||
std::fs::File::create(format!("./log/compile-{}.txt", container.name))
|
"compile_log.txt",
|
||||||
.unwrap();
|
));
|
||||||
compile_log
|
|
||||||
.write_all(compile_buf.lock().unwrap().as_bytes())
|
|
||||||
.unwrap();
|
|
||||||
compile_log.flush().unwrap();
|
|
||||||
}
|
|
||||||
let result_log =
|
|
||||||
tokio::fs::File::open(format!("./log/compile-{}.txt", container.name))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
edit_message = edit_message.new_attachment(
|
|
||||||
CreateAttachment::file(&result_log, "compile_log.txt")
|
|
||||||
.await
|
|
||||||
.unwrap(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user