add bot comment system
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
This commit is contained in:
parent
840320d0d2
commit
3a8089c823
@ -1 +1 @@
|
|||||||
Subproject commit 69a235a0aa7c9965de1d76a70f35099fcdcbedf5
|
Subproject commit ca91a08915bbde4df793e7f5001fb2b1c9d05a94
|
63
src/bot.rs
63
src/bot.rs
@ -46,6 +46,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
cid_root = &n[i].record.reply.as_ref().unwrap().root.cid;
|
cid_root = &n[i].record.reply.as_ref().unwrap().root.cid;
|
||||||
uri_root = &n[i].record.reply.as_ref().unwrap().root.uri;
|
uri_root = &n[i].record.reply.as_ref().unwrap().root.uri;
|
||||||
}
|
}
|
||||||
|
let check_cid_comment = w_cid(cid_root.to_string(), log_file(&"c1"), false);
|
||||||
|
|
||||||
let mut text = "";
|
let mut text = "";
|
||||||
if !n[i].record.text.is_none() {
|
if !n[i].record.text.is_none() {
|
||||||
@ -423,6 +424,34 @@ pub fn c_bot(c: &Context) {
|
|||||||
.await;
|
.await;
|
||||||
println!("{}", str_rep);
|
println!("{}", str_rep);
|
||||||
w_cid(cid.to_string(), log_file(&"n1"), true);
|
w_cid(cid.to_string(), log_file(&"n1"), true);
|
||||||
|
} else if check_cid_comment == true && handle == &admin {
|
||||||
|
println!("admin:{}", admin);
|
||||||
|
let output = Command::new(data_scpt(&"ai"))
|
||||||
|
.arg(&"atproto").arg(&"comment")
|
||||||
|
.arg(&handle)
|
||||||
|
.arg(&did)
|
||||||
|
.arg(&cid)
|
||||||
|
.arg(&uri)
|
||||||
|
.arg(&cid_root)
|
||||||
|
.arg(&uri_root)
|
||||||
|
.arg(&host)
|
||||||
|
.arg(&avatar)
|
||||||
|
.arg(&prompt_chat)
|
||||||
|
.output()
|
||||||
|
.expect("zsh");
|
||||||
|
let d = String::from_utf8_lossy(&output.stdout);
|
||||||
|
let d = d.to_string();
|
||||||
|
let text_limit = c_char(d);
|
||||||
|
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);
|
||||||
} else if { com == "sh" || com == "/sh" } && handle == &admin {
|
} else if { com == "sh" || com == "/sh" } && handle == &admin {
|
||||||
println!("admin:{}", admin);
|
println!("admin:{}", admin);
|
||||||
let output = Command::new(data_scpt(&"ai"))
|
let output = Command::new(data_scpt(&"ai"))
|
||||||
@ -565,7 +594,10 @@ pub fn c_bot_feed(c: &Context) {
|
|||||||
let uri_root = uri;
|
let uri_root = uri;
|
||||||
let check_cid = w_cid(cid.to_string(), log_file(&"n1"), false);
|
let check_cid = w_cid(cid.to_string(), log_file(&"n1"), false);
|
||||||
let check_cid_run = w_cid(cid.to_string(), log_file(&"n2"), false);
|
let check_cid_run = w_cid(cid.to_string(), log_file(&"n2"), false);
|
||||||
|
let mut avatar = "".to_string();
|
||||||
|
if let Some(v) = &n[i].post.author.avatar {
|
||||||
|
avatar = v.to_string();
|
||||||
|
}
|
||||||
let mut text = "";
|
let mut text = "";
|
||||||
if !n[i].post.record.text.is_none() {
|
if !n[i].post.record.text.is_none() {
|
||||||
text = &n[i].post.record.text.as_ref().unwrap();
|
text = &n[i].post.record.text.as_ref().unwrap();
|
||||||
@ -950,6 +982,35 @@ pub fn c_bot_feed(c: &Context) {
|
|||||||
.await;
|
.await;
|
||||||
println!("{}", str_rep);
|
println!("{}", str_rep);
|
||||||
w_cid(cid.to_string(), log_file(&"n1"), true);
|
w_cid(cid.to_string(), log_file(&"n1"), true);
|
||||||
|
} else if { com == "comment" || com == "/comment" } && handle == &admin {
|
||||||
|
println!("admin:{}", admin);
|
||||||
|
let output = Command::new(data_scpt(&"ai"))
|
||||||
|
.arg(&"atproto").arg(&"comment")
|
||||||
|
.arg(&handle)
|
||||||
|
.arg(&did)
|
||||||
|
.arg(&cid)
|
||||||
|
.arg(&uri)
|
||||||
|
.arg(&cid_root)
|
||||||
|
.arg(&uri_root)
|
||||||
|
.arg(&host)
|
||||||
|
.arg(&avatar)
|
||||||
|
.arg(&prompt_chat)
|
||||||
|
.output()
|
||||||
|
.expect("zsh");
|
||||||
|
let d = String::from_utf8_lossy(&output.stdout);
|
||||||
|
let d = d.to_string();
|
||||||
|
let text_limit = c_char(d);
|
||||||
|
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);
|
||||||
|
w_cid(cid_root.to_string(), log_file(&"c1"), true);
|
||||||
} else if com == "quiz" || com == "/quiz" {
|
} else if com == "quiz" || com == "/quiz" {
|
||||||
println!("admin:{}", admin);
|
println!("admin:{}", admin);
|
||||||
let output = Command::new(data_scpt(&"ai"))
|
let output = Command::new(data_scpt(&"ai"))
|
||||||
|
@ -34,6 +34,7 @@ pub fn log_file(s: &str) -> String {
|
|||||||
match &*s {
|
match &*s {
|
||||||
"n1" => f + &"notify_cid.txt",
|
"n1" => f + &"notify_cid.txt",
|
||||||
"n2" => f + &"notify_cid_run.txt",
|
"n2" => f + &"notify_cid_run.txt",
|
||||||
|
"c1" => f + &"comment_cid.txt",
|
||||||
_ => f + &s,
|
_ => f + &s,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user