1
0
This commit is contained in:
syui 2024-02-13 19:31:08 +09:00
parent 8d3a7e6af6
commit 087310e94f
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56

View File

@ -1,9 +1,11 @@
use seahorse::Context;
use std::process::Command;
use crate::refresh;
use crate::reply;
use crate::reply_link;
use crate::notify;
use crate::openai;
use crate::notify_read;
use crate::data::log_file;
@ -49,7 +51,7 @@ pub fn c_bot(c: &Context) {
text = &n[i].record.text.as_ref().unwrap();
}
let vec: Vec<&str> = text.split_whitespace().collect();
let rep_com = &vec[0..].join(" ");
let com = vec[1].trim().to_string();
let handlev: Vec<&str> = handle.split('.').collect();
let mut handlev = handlev[0].trim().to_string();
@ -57,10 +59,20 @@ pub fn c_bot(c: &Context) {
let s = 0;
let mut e = link.chars().count();
use std::process::Command;
let mut prompt = "none".to_string();
if reason == "mention" {
prompt = vec[2..].join(" ");
} else if reason == "reply" {
prompt = vec[1..].join(" ");
}
if prompt.is_empty() == false {
println!("{}", prompt);
}
if check_cid == false && { reason == "mention" || reason == "reply" } || check_cid_run == false && { reason == "mention" || reason == "reply" } {
w_cid(cid.to_string(), log_file(&"n2"), true);
if rep_com == "/did" || rep_com == "did" {
if com == "/did" || com == "did" {
let link = "https://plc.directory/".to_owned() + &did + &"/log";
let s = 0;
let e = link.chars().count();
@ -71,12 +83,11 @@ pub fn c_bot(c: &Context) {
w_cid(cid.to_string(), log_file(&"n1"), true);
println!("{}", str_rep);
}
} else if rep_com == "/diffusers" || rep_com == "diffusers" {
let prompt = &vec[2..].join(" ");
} else if com == "/diffusers" || com == "diffusers" {
let _output = Command::new(data_scpt(&"diffusers")).arg(&did).arg(&prompt).output().expect("zsh");
let _output = Command::new(data_scpt(&"at_img")).arg(&cid).arg(&uri).output().expect("zsh");
w_cid(cid.to_string(), log_file(&"n1"), true);
} else if rep_com.contains("") == true || rep_com.contains("うらない") == true || rep_com.contains("うらなって") == true {
} else if prompt.contains("") == true || prompt.contains("うらない") == true || prompt.contains("うらなって") == true {
let output = Command::new(data_scpt(&"card_fortune")).arg(&handle).arg(&did).arg(&cid).arg(&uri).output().expect("zsh");
let d = String::from_utf8_lossy(&output.stdout);
let d = d.to_string();
@ -85,8 +96,7 @@ pub fn c_bot(c: &Context) {
println!("{}", text_limit);
w_cid(cid.to_string(), log_file(&"n1"), true);
}
} else if rep_com == "/card" || rep_com == "card" {
let prompt = &vec[2..].join(" ");
} else if com == "/card" || com == "card" {
let output = Command::new(data_scpt(&"api_card.zsh")).arg(&handle).arg(&did).arg(&prompt).output().expect("zsh");
let d = String::from_utf8_lossy(&output.stdout);
let dd = "\n".to_owned() + &d.to_string();
@ -104,8 +114,7 @@ pub fn c_bot(c: &Context) {
}
w_cid(cid.to_string(), log_file(&"n1"), true);
}
} else if rep_com == "/fav" || rep_com == "fav" {
let prompt = &vec[2..].join(" ");
} else if com == "/fav" || com == "fav" {
let output = Command::new(data_scpt(&"api_fav")).arg(&handle).arg(&did).arg(&prompt).output().expect("zsh");
let d = String::from_utf8_lossy(&output.stdout);
let dd = "\n".to_owned() + &d.to_string();
@ -115,8 +124,7 @@ pub fn c_bot(c: &Context) {
println!("{}", str_rep);
w_cid(cid.to_string(), log_file(&"n1"), true);
}
} else if rep_com == "/egg" || rep_com == "egg" {
let prompt = &vec[2..].join(" ");
} else if com == "/egg" || com == "egg" {
let output = Command::new(data_scpt(&"api_egg")).arg(&handle).arg(&did).arg(&prompt).output().expect("zsh");
let d = String::from_utf8_lossy(&output.stdout);
let dd = "\n".to_owned() + &d.to_string();
@ -126,8 +134,7 @@ pub fn c_bot(c: &Context) {
println!("{}", str_rep);
w_cid(cid.to_string(), log_file(&"n1"), true);
}
} else if rep_com == "/nyan" || rep_com == "nyan" {
let prompt = &vec[2..].join(" ");
} else if com == "/nyan" || com == "nyan" {
let output = Command::new(data_scpt(&"nyancat")).arg(&handle).arg(&did).arg(&cid).arg(&uri).arg(&prompt).output().expect("zsh");
let d = String::from_utf8_lossy(&output.stdout);
let dd = "\n".to_owned() + &d.to_string();
@ -138,7 +145,7 @@ pub fn c_bot(c: &Context) {
println!("{}", str_rep);
w_cid(cid.to_string(), log_file(&"n1"), true);
}
} else if rep_com == "/ten" || rep_com == "ten" {
} else if com == "/ten" || com == "ten" {
let option = &vec[2..].join(" ");
let sub_option = &vec[3..].join(" ");
let output = Command::new(data_scpt(&"api_ten")).arg(&handle).arg(&did).arg(&cid).arg(&uri).arg(&option).arg(&sub_option).output().expect("zsh");
@ -150,6 +157,13 @@ pub fn c_bot(c: &Context) {
println!("{}", str_rep);
w_cid(cid.to_string(), log_file(&"n1"), true);
}
} else {
// openai
let str_openai = openai::post_request(prompt.to_string()).await;
let text_limit = c_char(str_openai);
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);
}
let str_notify = notify_read::post_request(time.to_string()).await;
println!("{}", str_notify);