diff --git a/Dockerfile b/Dockerfile index fb6c9fe..72c5913 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ USER root ADD .config /root/.config WORKDIR /root -ADD ./scpt/entrypoint.sh / +ADD ./test/entrypoint.sh / RUN chmod +x /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index 2b1d12e..9319343 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ $ ai bot `zsh` ```sh -$ ./ai.zsh t +$ ./test/ai.zsh t ``` ### docker diff --git a/src/bot.rs b/src/bot.rs index b65a4e3..1fd0d89 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -81,6 +81,11 @@ pub fn c_bot(c: &Context) { println!("prompt_sub:{}", prompt_sub); } + let mut admin = "".to_string(); + if c.string_flag("admin").is_ok() { + admin = c.string_flag("admin").unwrap(); + } + if check_cid == false && { reason == "mention" || reason == "reply" } || check_cid_run == false && { reason == "mention" || reason == "reply" } { w_cid(cid.to_string(), log_file(&"n2"), true); @@ -167,6 +172,15 @@ pub fn c_bot(c: &Context) { println!("{}", str_rep); w_cid(cid.to_string(), log_file(&"n1"), true); } + } else if { com == "sh" || com == "/sh" } && handle == &admin { + println!("admin:{}", admin); + let output = Command::new(data_scpt(&"arch")).arg(&prompt).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 { // openai let str_openai = openai::post_request(prompt.to_string()).await; diff --git a/src/main.rs b/src/main.rs index 0c0c6d7..d47d4ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,7 +52,11 @@ fn main() { .command( Command::new("bot") .alias("b") - .action(bot), + .action(bot) + .flag( + Flag::new("admin", FlagType::String) + .alias("a"), + ) ) .command( Command::new("follow_all") @@ -256,6 +260,7 @@ fn ascii_art(c: &Context) { } fn bot(c: &Context) { + refresh(c); loop { c_bot(c); } @@ -499,6 +504,12 @@ fn img_post(c: &Context) { fn reply_og(c: &Context) { refresh(c); + + //let mut admin = "".to_string(); + //if c.string_flag("admin").is_ok() { + // admin = c.string_flag("admin").unwrap(); + //} + let m = c.args[0].to_string(); let link = c.string_flag("link").unwrap(); let cid = c.string_flag("cid").unwrap(); diff --git a/ai.zsh b/test/ai.zsh similarity index 95% rename from ai.zsh rename to test/ai.zsh index ac112b3..5743479 100755 --- a/ai.zsh +++ b/test/ai.zsh @@ -7,7 +7,7 @@ case $OSTYPE in alias date="/opt/homebrew/bin/gdate" ;; esac -d=${0:a:h}/test +d=${0:a:h} source $d/env source $d/refresh.zsh source $d/token.zsh