From cdc2bbd9117d85b49e7d22140a65047f921db262 Mon Sep 17 00:00:00 2001 From: syui Date: Thu, 25 Apr 2024 16:05:51 +0900 Subject: [PATCH] fix --- src/bot.rs | 71 +++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/bot.rs b/src/bot.rs index c77ae13..6f3e4b0 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -46,7 +46,7 @@ pub fn c_bot(c: &Context) { cid_root = &n[i].record.reply.as_ref().unwrap().root.cid; uri_root = &n[i].record.reply.as_ref().unwrap().root.uri; } - let check_cid_comment = w_cid(cid_root.to_string(), log_file(&"c1"), false); + let check_uri_comment = w_cid(uri_root.to_string(), log_file(&"c1"), false); let mut text = ""; if !n[i].record.text.is_none() { @@ -424,7 +424,7 @@ pub fn c_bot(c: &Context) { .await; println!("{}", str_rep); w_cid(cid.to_string(), log_file(&"n1"), true); - } else if check_cid_comment == true && handle == &admin { + } else if check_uri_comment == true && handle == &admin { println!("admin:{}", admin); let output = Command::new(data_scpt(&"ai")) .arg(&"atproto").arg(&"comment") @@ -543,6 +543,35 @@ pub fn c_bot(c: &Context) { .await; println!("{}", str_rep); w_cid(cid.to_string(), log_file(&"n1"), true); + } else if { com == "comment" || com == "/comment" } && handle == &admin && check_uri_comment == false { + println!("admin:{}", admin); + let output = Command::new(data_scpt(&"ai")) + .arg(&"atproto").arg(&"comment") + .arg(&handle) + .arg(&did) + .arg(&cid) + .arg(&uri) + .arg(&cid_root) + .arg(&uri_root) + .arg(&host) + .arg(&avatar) + .arg(&prompt_chat) + .output() + .expect("zsh"); + let d = String::from_utf8_lossy(&output.stdout); + let d = d.to_string(); + let text_limit = c_char(d); + let str_rep = reply::post_request( + text_limit.to_string(), + cid.to_string(), + uri.to_string(), + cid_root.to_string(), + uri_root.to_string(), + ) + .await; + println!("{}", str_rep); + w_cid(cid.to_string(), log_file(&"n1"), true); + w_cid(uri_root.to_string(), log_file(&"c1"), true); } else { // openai let str_openai = openai::post_request(prompt_chat.to_string()).await; @@ -594,10 +623,10 @@ pub fn c_bot_feed(c: &Context) { let uri_root = uri; let check_cid = w_cid(cid.to_string(), log_file(&"n1"), false); let check_cid_run = w_cid(cid.to_string(), log_file(&"n2"), false); - let mut avatar = "".to_string(); - if let Some(v) = &n[i].post.author.avatar { - avatar = v.to_string(); - } + //let mut avatar = "".to_string(); + //if let Some(v) = &n[i].post.author.avatar { + // avatar = v.to_string(); + //} let mut text = ""; if !n[i].post.record.text.is_none() { text = &n[i].post.record.text.as_ref().unwrap(); @@ -982,35 +1011,7 @@ pub fn c_bot_feed(c: &Context) { .await; println!("{}", str_rep); w_cid(cid.to_string(), log_file(&"n1"), true); - } else if { com == "comment" || com == "/comment" } && handle == &admin { - println!("admin:{}", admin); - let output = Command::new(data_scpt(&"ai")) - .arg(&"atproto").arg(&"comment") - .arg(&handle) - .arg(&did) - .arg(&cid) - .arg(&uri) - .arg(&cid_root) - .arg(&uri_root) - .arg(&host) - .arg(&avatar) - .arg(&prompt) - .output() - .expect("zsh"); - let d = String::from_utf8_lossy(&output.stdout); - let d = d.to_string(); - let text_limit = c_char(d); - let str_rep = reply::post_request( - text_limit.to_string(), - cid.to_string(), - uri.to_string(), - cid_root.to_string(), - uri_root.to_string(), - ) - .await; - println!("{}", str_rep); - w_cid(cid.to_string(), log_file(&"n1"), true); - w_cid(cid_root.to_string(), log_file(&"c1"), true); + } else if com == "quiz" || com == "/quiz" { println!("admin:{}", admin); let output = Command::new(data_scpt(&"ai"))