1
0

add mitra

This commit is contained in:
syui 2024-02-23 15:23:14 +09:00
parent 6855cc78b4
commit 23d41cdc5c
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56
2 changed files with 51 additions and 1 deletions

21
.config/ai/scpt/mitractl.zsh Executable file
View File

@ -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

View File

@ -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(),