Compare commits
4 Commits
main
...
6e1b0c597b
| Author | SHA1 | Date | |
|---|---|---|---|
|
6e1b0c597b
|
|||
|
b3f0cdd622
|
|||
|
454de01881
|
|||
|
57365a41a5
|
Submodule .config/ai/scpt updated: 7a4d642e41...e55225eb57
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "aibot"
|
||||
name = "ai"
|
||||
authors = ["syui"]
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
FROM syui/aios
|
||||
ADD .ssh /root/.ssh
|
||||
|
||||
WORKDIR /root
|
||||
ADD ./test/entrypoint.sh .
|
||||
RUN chmod +x /root/entrypoint.sh
|
||||
RUN pacman -Syu bc --noconfirm
|
||||
|
||||
ENTRYPOINT ["/root/entrypoint.sh"]
|
||||
|
||||
20
README.md
20
README.md
@@ -7,58 +7,58 @@
|
||||
- host : [yui.syui.ai](https://bsky.app/profile/yui.syui.ai), [ai.syu.is](https://web.syu.is/profile/ai.syu.is)
|
||||
|
||||
```sh
|
||||
$ aibot
|
||||
$ ai
|
||||
```
|
||||
|
||||
```sh
|
||||
$ docker run -it syui/aios aibot
|
||||
$ docker run -it syui/aios ai
|
||||
```
|
||||
|
||||
### build
|
||||
|
||||
```sh
|
||||
$ cargo build
|
||||
$ ./target/debug/aibot ai
|
||||
$ ./target/debug/ai ai
|
||||
```
|
||||
|
||||
```sh
|
||||
$ aibot ai -t avatar
|
||||
$ ai ai -t avatar
|
||||
```
|
||||
|
||||
### login
|
||||
|
||||
```sh
|
||||
# ai login $handle -p $password
|
||||
$ aibot l yui.syui.ai -p password
|
||||
$ ai l yui.syui.ai -p password
|
||||
|
||||
$ cat ~/.config/ai/token.toml
|
||||
```
|
||||
|
||||
```sh
|
||||
# ai l $handle -p $password -s $server
|
||||
$ aibot l ai.syu.is -p password -s syu.is
|
||||
$ ai l ai.syu.is -p password -s syu.is
|
||||
```
|
||||
|
||||
### refresh
|
||||
|
||||
```
|
||||
$ aibot r
|
||||
$ ai r
|
||||
```
|
||||
|
||||
### notify
|
||||
|
||||
```
|
||||
$ aibot n
|
||||
$ ai n
|
||||
```
|
||||
|
||||
```
|
||||
$ aibot n | jq .
|
||||
$ ai n | jq .
|
||||
```
|
||||
|
||||
### bot
|
||||
|
||||
```
|
||||
$ aibot bot
|
||||
$ ai bot
|
||||
```
|
||||
|
||||
|command|sub|type|link|auth|
|
||||
|
||||
36
src/bot.rs
36
src/bot.rs
@@ -431,42 +431,6 @@ pub fn c_bot(c: &Context) {
|
||||
println!("{}", str_rep);
|
||||
w_cid(cid.to_string(), log_file(&"n1"), true);
|
||||
}
|
||||
} else if com == "game" || com == "/game" {
|
||||
let output = Command::new(data_scpt(&"ai"))
|
||||
.arg(&"atproto").arg(&"game")
|
||||
.arg(&handle)
|
||||
.arg(&did)
|
||||
.arg(&cid)
|
||||
.arg(&uri)
|
||||
.arg(&cid_root)
|
||||
.arg(&uri_root)
|
||||
.arg(&host)
|
||||
.arg(&prompt)
|
||||
.arg(&prompt_sub)
|
||||
.output()
|
||||
.expect("zsh");
|
||||
let d = String::from_utf8_lossy(&output.stdout);
|
||||
let dd = "\n".to_owned() + &d.to_string();
|
||||
let text_limit = c_char(dd);
|
||||
handlev = d.lines().collect::<Vec<_>>()[0].to_string();
|
||||
link = "https://card.syui.ai/".to_owned() + &handlev;
|
||||
println!("{}", e);
|
||||
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 if com == "quiz" || com == "/quiz" {
|
||||
println!("admin:{}", admin);
|
||||
let output = Command::new(data_scpt(&"ai"))
|
||||
|
||||
12
src/data.rs
12
src/data.rs
@@ -8,7 +8,7 @@ use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
pub fn data_file(s: &str) -> String {
|
||||
let file = "/.config/syui/ai/bot/";
|
||||
let file = "/.config/ai/";
|
||||
let mut f = shellexpand::tilde("~").to_string();
|
||||
f.push_str(&file);
|
||||
let path = Path::new(&f);
|
||||
@@ -24,7 +24,7 @@ pub fn data_file(s: &str) -> String {
|
||||
}
|
||||
|
||||
pub fn log_file(s: &str) -> String {
|
||||
let file = "/.config/syui/ai/bot/txt/";
|
||||
let file = "/.config/ai/txt/";
|
||||
let mut f = shellexpand::tilde("~").to_string();
|
||||
f.push_str(&file);
|
||||
let path = Path::new(&f);
|
||||
@@ -263,7 +263,7 @@ pub fn data_refresh(s: &str) -> String {
|
||||
|
||||
pub fn data_scpt(s: &str) -> String {
|
||||
let s = String::from(s);
|
||||
let file = "/.config/syui/ai/bot/scpt/".to_owned() + &s + &".zsh";
|
||||
let file = "/.config/ai/scpt/".to_owned() + &s + &".zsh";
|
||||
let mut f = shellexpand::tilde("~").to_string();
|
||||
f.push_str(&file);
|
||||
return f;
|
||||
@@ -603,7 +603,7 @@ pub fn w_cid(cid: String, file: String, t: bool) -> bool {
|
||||
}
|
||||
|
||||
pub fn c_follow_all() {
|
||||
let file = "/.config/syui/ai/bot/scpt/follow_all.zsh";
|
||||
let file = "/.config/ai/scpt/follow_all.zsh";
|
||||
let mut f = shellexpand::tilde("~").to_string();
|
||||
f.push_str(&file);
|
||||
use std::process::Command;
|
||||
@@ -617,7 +617,7 @@ pub fn c_openai_key(c: &Context) {
|
||||
let api = c.args[0].to_string();
|
||||
let o = "api='".to_owned() + &api.to_string() + &"'".to_owned();
|
||||
let o = o.to_string();
|
||||
let l = shellexpand::tilde("~") + "/.config/syui/ai/bot/openai.toml";
|
||||
let l = shellexpand::tilde("~") + "/.config/ai/openai.toml";
|
||||
let l = l.to_string();
|
||||
let mut l = fs::File::create(l).unwrap();
|
||||
if o != "" {
|
||||
@@ -628,7 +628,7 @@ pub fn c_openai_key(c: &Context) {
|
||||
|
||||
impl Open {
|
||||
pub fn new() -> Result<Self, ConfigError> {
|
||||
let d = shellexpand::tilde("~") + "/.config/syui/ai/bot/openai.toml";
|
||||
let d = shellexpand::tilde("~") + "/.config/ai/openai.toml";
|
||||
let s = Config::builder()
|
||||
.add_source(File::with_name(&d))
|
||||
.add_source(config::Environment::with_prefix("APP"))
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/bin/zsh
|
||||
|
||||
#ai l $HANDLE -p $PASSWORD -s $HOST
|
||||
ai bot -a $ADMIN
|
||||
ai l $HANDLE -p $PASSWORD -s $HOST && ai bot -a $ADMIN
|
||||
|
||||
Reference in New Issue
Block a user