From 87a333d7445460c14b5830619ecb4dddea73e321 Mon Sep 17 00:00:00 2001 From: syui Date: Fri, 22 Mar 2024 00:32:23 +0900 Subject: [PATCH] fix card handle --- .config/ai/scpt | 2 +- README.md | 2 +- docs/wiki.md | 7 +++++ src/bot.rs | 69 ++++++++++++++++++++++++------------------------- 4 files changed, 43 insertions(+), 37 deletions(-) diff --git a/.config/ai/scpt b/.config/ai/scpt index dc082b2..6408d69 160000 --- a/.config/ai/scpt +++ b/.config/ai/scpt @@ -1 +1 @@ -Subproject commit dc082b2001fb5f824ab18f62da56090471e777d0 +Subproject commit 6408d69188d2db30ed0f5560118c86b8342fc3cd diff --git a/README.md b/README.md index be53288..ef5dcdf 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ $ ai bot |@yui.syui.ai fav|{cid}|mention, reply| [card.syui.ai](https://card.syui.ai) |user| |@yui.syui.ai egg|{password}|mention, reply| [card.syui.ai](https://card.syui.ai) |user| |@yui.syui.ai 占い||mention, reply| [yui.syui.ai](https://yui.syui.ai) |user| -|@yui.syui.ai nyan|🍰|mention, reply| [yui.syui.ai](https://yui.syui.ai) |user| +|@yui.syui.ai nyan|🍬|mention, reply| [yui.syui.ai](https://yui.syui.ai) |user| |@yui.syui.ai diffusers|{keyword}|mention, reply| [huggingface.co/diffusers](https://huggingface.co/docs/diffusers/index) |user| |@yui.syui.ai sh|{command}|mention, reply| [archlinux.org](https://wiki.archlinux.org/title/Systemd-nspawn) |admin| diff --git a/docs/wiki.md b/docs/wiki.md index be06d8d..99f4806 100644 --- a/docs/wiki.md +++ b/docs/wiki.md @@ -1,3 +1,10 @@ +### test-notify + +```sh +./target/debug/ai n|jq -r ".notifications|.[].cid" >> ~/.config/ai/txt/notify_cid* +./target/debug/ai bot +``` + ### docker ```sh diff --git a/src/bot.rs b/src/bot.rs index 9d2087b..8db84a8 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -192,36 +192,22 @@ pub fn c_bot(c: &Context) { let dd = "\n".to_owned() + &d.to_string(); let text_limit = c_char(dd); if text_limit.len() > 3 { - if d.contains("handle") == false { - 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(), - ) + //handlev = handle.replace(".", "-").to_string(); + handlev = d.lines().collect::>()[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); - } else { - handlev = handle.replace(".", "-").to_string(); - link = "https://card.syui.ai/".to_owned() + &handlev; - e = link.chars().count(); - let str_rep = reply_link::post_request( - d.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); - } + println!("{}", str_rep); w_cid(cid.to_string(), log_file(&"n1"), true); } } else if com == "fav" { @@ -242,8 +228,11 @@ pub fn c_bot(c: &Context) { let dd = "\n".to_owned() + &d.to_string(); let text_limit = c_char(dd); if text_limit.len() > 3 { + handlev = d.lines().collect::>()[0].to_string(); + link = "https://card.syui.ai/".to_owned() + &handlev; + e = link.chars().count(); let str_rep = reply_link::post_request( - d.to_string(), + text_limit.to_string(), link.to_string(), s, e.try_into().unwrap(), @@ -274,8 +263,11 @@ pub fn c_bot(c: &Context) { let dd = "\n".to_owned() + &d.to_string(); let text_limit = c_char(dd); if text_limit.len() > 3 { + handlev = d.lines().collect::>()[0].to_string(); + link = "https://card.syui.ai/".to_owned() + &handlev; + e = link.chars().count(); let str_rep = reply_link::post_request( - d.to_string(), + text_limit.to_string(), link.to_string(), s, e.try_into().unwrap(), @@ -333,9 +325,12 @@ pub fn c_bot(c: &Context) { .output() .expect("zsh"); let d = String::from_utf8_lossy(&output.stdout); - let d = "\n".to_owned() + &d.to_string(); - let text_limit = c_char(d); + let dd = "\n".to_owned() + &d.to_string(); + let text_limit = c_char(dd); if text_limit.len() > 3 { + handlev = d.lines().collect::>()[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(), @@ -365,8 +360,12 @@ pub fn c_bot(c: &Context) { .output() .expect("zsh"); let d = String::from_utf8_lossy(&output.stdout); - let d = "\n".to_owned() + &d.to_string(); - let text_limit = c_char(d); + let dd = "\n".to_owned() + &d.to_string(); + let text_limit = c_char(dd); + handlev = d.lines().collect::>()[0].to_string(); + link = "https://card.syui.ai/".to_owned() + &handlev; + println!("{}", e); + e = link.chars().count(); if text_limit.len() > 3 { let str_rep = reply_link::post_request( text_limit.to_string(),