Compare commits
3 Commits
9bbe699ed1
...
d6a2c975e9
Author | SHA1 | Date | |
---|---|---|---|
d6a2c975e9 | |||
38a14cd0d7 | |||
3b2c9eb1a2 |
30
src/bot.rs
30
src/bot.rs
@ -550,19 +550,12 @@ pub fn c_bot_feed(c: &Context) {
|
||||
let mut link = "https://card.syui.ai/".to_owned() + &handlev;
|
||||
let s = 0;
|
||||
let mut e = link.chars().count();
|
||||
|
||||
let com = vec[0].trim().to_string();
|
||||
let mut prompt = "".to_string();
|
||||
|
||||
let mut prompt_sub = "".to_string();
|
||||
let mut prompt_chat = "".to_string();
|
||||
|
||||
if com == "@ai" {
|
||||
prompt_chat = vec[1..].join(" ");
|
||||
} else {
|
||||
prompt = vec[1..].join(" ");
|
||||
if vec.len() > 1 {
|
||||
prompt_sub = vec[2..].join(" ");
|
||||
}
|
||||
let com = vec[0].trim().to_string();
|
||||
let prompt = vec[1..].join(" ");
|
||||
if vec.len() > 1 {
|
||||
prompt_sub = vec[2..].join(" ");
|
||||
}
|
||||
|
||||
if prompt.is_empty() == false || com.is_empty() == false {
|
||||
@ -931,19 +924,6 @@ pub fn c_bot_feed(c: &Context) {
|
||||
println!("{}", str_rep);
|
||||
w_cid(cid.to_string(), log_file(&"n1"), true);
|
||||
}
|
||||
} else if com == "@ai" {
|
||||
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(),
|
||||
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);
|
||||
}
|
||||
println!("---");
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
extern crate reqwest;
|
||||
use crate::data_toml;
|
||||
use crate::data_refresh;
|
||||
use crate::url;
|
||||
use serde_json::json;
|
||||
|
||||
pub async fn post_request(rkey: String, col: String) -> String {
|
||||
let token = data_refresh(&"access");
|
||||
//let did = data_toml(&"did");
|
||||
let handle = data_toml(&"handle");
|
||||
|
||||
let url = url(&"record_delete");
|
||||
|
||||
let post = Some(json!({
|
||||
"repo": handle.to_string(),
|
||||
"rkey": rkey.to_string(),
|
||||
"collection": col.to_string()
|
||||
}));
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let res = client
|
||||
.post(url)
|
||||
.json(&post)
|
||||
.header("Authorization", "Bearer ".to_owned() + &token)
|
||||
.send()
|
||||
.await
|
||||
.unwrap()
|
||||
.text()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
return res;
|
||||
}
|
24
src/main.rs
24
src/main.rs
@ -39,7 +39,6 @@ pub mod session;
|
||||
pub mod timeline_author;
|
||||
pub mod token;
|
||||
pub mod feed_get;
|
||||
pub mod delete_record;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
@ -126,16 +125,6 @@ fn main() {
|
||||
.alias("l"),
|
||||
)
|
||||
)
|
||||
.command(
|
||||
Command::new("delete")
|
||||
.description("d <rkey>")
|
||||
.alias("d")
|
||||
.action(delete)
|
||||
.flag(
|
||||
Flag::new("col", FlagType::String)
|
||||
.alias("c"),
|
||||
)
|
||||
)
|
||||
.command(
|
||||
Command::new("like")
|
||||
.description("like <cid> -u <uri>")
|
||||
@ -426,19 +415,6 @@ fn post(c: &Context) {
|
||||
return res;
|
||||
}
|
||||
|
||||
fn delete(c: &Context) {
|
||||
refresh(c);
|
||||
let m = c.args[0].to_string();
|
||||
let h = async {
|
||||
if let Ok(col) = c.string_flag("col") {
|
||||
let str = delete_record::post_request(m.to_string(), col);
|
||||
println!("{}", str.await);
|
||||
}
|
||||
};
|
||||
let res = tokio::runtime::Runtime::new().unwrap().block_on(h);
|
||||
return res;
|
||||
}
|
||||
|
||||
fn like(c: &Context) {
|
||||
refresh(c);
|
||||
let m = c.args[0].to_string();
|
||||
|
Loading…
Reference in New Issue
Block a user