diff --git a/.config/ai/scpt/mitractl.zsh b/.config/ai/scpt/mitractl.zsh new file mode 100755 index 0000000..8eb5ae9 --- /dev/null +++ b/.config/ai/scpt/mitractl.zsh @@ -0,0 +1,21 @@ +#!/bin/zsh + +#repeat 30 docker exec -it mitra-mitra-1 zsh -c "/app/mitractl generate-invite-code" |grep invite >> .config/ai/txt/mitra_invite.txt + +#name=mitra-mitra-1 +#docker exec -it $name bash -c "/app/mitractl generate-invite-code"|grep invite + +f=~/.config/ai/txt/mitra_invite.txt +cat $f|awk "NR==1" + +case $OSTYPE in + darwin*) + sed -i "" 1d $f + ;; + linux*) + sed -i 1d $f + ;; + *) + sed -i 1d $f + ;; +esac diff --git a/src/bot.rs b/src/bot.rs index b521946..540327e 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -59,15 +59,18 @@ pub fn c_bot(c: &Context) { let mut com = "".to_string(); let mut prompt = "".to_string(); let mut prompt_sub = "".to_string(); + let mut prompt_chat = "".to_string(); if reason == "mention" { com = vec[1].trim().to_string(); prompt = vec[2..].join(" "); + prompt_chat = vec[1..].join(" "); if vec.len() > 2 { prompt_sub = vec[3..].join(" "); } } else if reason == "reply" { com = vec[0].trim().to_string(); prompt = vec[1..].join(" "); + prompt_chat = vec[0..].join(" "); if vec.len() > 1 { prompt_sub = vec[2..].join(" "); } @@ -309,9 +312,35 @@ pub fn c_bot(c: &Context) { .await; println!("{}", str_rep); w_cid(cid.to_string(), log_file(&"n1"), true); + } else if { com == "mitractl" || com == "/mitractl" } && handle == &admin { + println!("admin:{}", admin); + let output = Command::new(data_scpt(&"mitractl")) + .arg(&prompt) + .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); + link = "https://m.syu.is".to_string(); + e = link.chars().count(); + if text_limit.len() > 3 { + 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); + } } else { // openai - let str_openai = openai::post_request(prompt.to_string()).await; + let str_openai = openai::post_request(prompt_chat.to_string()).await; let text_limit = c_char(str_openai); let str_rep = reply::post_request( text_limit.to_string(),