fix
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 18s

This commit is contained in:
2025-12-13 10:21:11 +09:00
parent 053d0e2b26
commit bd20f7af19
7 changed files with 114 additions and 55 deletions

View File

@@ -167,7 +167,9 @@ pub fn c_bot(c: &Context) {
|| com.contains("うらない") == true
|| com.contains("うらなって") == true
{
let _output = Command::new(data_scpt(&"ai"))
let script_path = data_scpt(&"ai");
println!("[fortune] script: {}", script_path);
let output = Command::new(&script_path)
.arg(&"atproto").arg(&"fortune")
.arg(&handle)
.arg(&did)
@@ -178,11 +180,25 @@ pub fn c_bot(c: &Context) {
.arg(&host)
.arg(&prompt)
.arg(&prompt_sub)
.output()
.expect("zsh");
.output();
match output {
Ok(out) => {
let stdout = String::from_utf8_lossy(&out.stdout);
let stderr = String::from_utf8_lossy(&out.stderr);
println!("[fortune] stdout: {}", stdout);
if !stderr.is_empty() {
println!("[fortune] stderr: {}", stderr);
}
}
Err(e) => {
println!("[fortune] error: {}", e);
}
}
w_cid(cid.to_string(), log_file(&"n1"), true);
} else if com == "card" || com == "/card" {
let output = Command::new(data_scpt(&"ai"))
let script_path = data_scpt(&"ai");
println!("[card] script: {}", script_path);
let output = Command::new(&script_path)
.arg(&"atproto").arg(&"card")
.arg(&handle)
.arg(&did)
@@ -193,29 +209,48 @@ pub fn c_bot(c: &Context) {
.arg(&host)
.arg(&prompt)
.arg(&prompt_sub)
.output()
.expect("zsh");
let d = String::from_utf8_lossy(&output.stdout);
let dd = "\n".to_owned() + &d.to_string();
let text_limit = c_char(dd);
if text_limit.len() > 3 {
//handlev = handle.replace(".", "-").to_string();
handlev = d.lines().collect::<Vec<_>>()[0].to_string();
link = "https://card.syui.ai/".to_owned() + &handlev;
e = link.chars().count();
let str_rep = reply_link::post_request(
text_limit.to_string(),
link.to_string(),
s,
e.try_into().unwrap(),
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);
.output();
match output {
Ok(out) => {
let d = String::from_utf8_lossy(&out.stdout);
let stderr = String::from_utf8_lossy(&out.stderr);
println!("[card] stdout: {}", d);
if !stderr.is_empty() {
println!("[card] stderr: {}", stderr);
}
let dd = "\n".to_owned() + &d.to_string();
let text_limit = c_char(dd);
if text_limit.len() > 3 {
let lines: Vec<&str> = d.lines().collect();
handlev = lines.get(0).unwrap_or(&"").trim().to_string();
// 空白を含む場合や空の場合はhandleから生成
if handlev.is_empty() || handlev.contains(' ') {
handlev = handle.split('.').next().unwrap_or("").to_string();
}
if !handlev.is_empty() {
link = "https://card.syui.ai/".to_owned() + &handlev;
e = link.chars().count();
let str_rep = reply_link::post_request(
text_limit.to_string(),
link.to_string(),
s,
e.try_into().unwrap(),
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);
}
}
}
Err(e) => {
println!("[card] script error: {}", e);
w_cid(cid.to_string(), log_file(&"n1"), true);
}
}
} else if com == "fav" || com == "/fav" {
let output = Command::new(data_scpt(&"ai"))
@@ -814,7 +849,9 @@ pub fn c_bot_feed(c: &Context) {
}
w_cid(cid.to_string(), log_file(&"n1"), true);
} else if com == "card" || com == "/card" {
let output = Command::new(data_scpt(&"ai"))
let script_path = data_scpt(&"ai");
println!("[card] script: {}", script_path);
let output = Command::new(&script_path)
.arg(&"atproto").arg(&"card")
.arg(&handle)
.arg(&did)
@@ -825,29 +862,48 @@ pub fn c_bot_feed(c: &Context) {
.arg(&host)
.arg(&prompt)
.arg(&prompt_sub)
.output()
.expect("zsh");
let d = String::from_utf8_lossy(&output.stdout);
let dd = "\n".to_owned() + &d.to_string();
let text_limit = c_char(dd);
if text_limit.len() > 3 {
//handlev = handle.replace(".", "-").to_string();
handlev = d.lines().collect::<Vec<_>>()[0].to_string();
link = "https://card.syui.ai/".to_owned() + &handlev;
e = link.chars().count();
let str_rep = reply_link::post_request(
text_limit.to_string(),
link.to_string(),
s,
e.try_into().unwrap(),
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);
.output();
match output {
Ok(out) => {
let d = String::from_utf8_lossy(&out.stdout);
let stderr = String::from_utf8_lossy(&out.stderr);
println!("[card] stdout: {}", d);
if !stderr.is_empty() {
println!("[card] stderr: {}", stderr);
}
let dd = "\n".to_owned() + &d.to_string();
let text_limit = c_char(dd);
if text_limit.len() > 3 {
let lines: Vec<&str> = d.lines().collect();
handlev = lines.get(0).unwrap_or(&"").trim().to_string();
// 空白を含む場合や空の場合はhandleから生成
if handlev.is_empty() || handlev.contains(' ') {
handlev = handle.split('.').next().unwrap_or("").to_string();
}
if !handlev.is_empty() {
link = "https://card.syui.ai/".to_owned() + &handlev;
e = link.chars().count();
let str_rep = reply_link::post_request(
text_limit.to_string(),
link.to_string(),
s,
e.try_into().unwrap(),
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);
}
}
}
Err(e) => {
println!("[card] script error: {}", e);
w_cid(cid.to_string(), log_file(&"n1"), true);
}
}
} else if com == "fav" || com == "/fav" {
let output = Command::new(data_scpt(&"ai"))