Compare commits
5 Commits
6fe572c1ad
...
7bbc3370d7
Author | SHA1 | Date | |
---|---|---|---|
7bbc3370d7 | |||
d6777a0c6a | |||
87a333d744 | |||
2f0bfe08b0 | |||
97856f3765 |
@ -1 +1 @@
|
|||||||
Subproject commit bd22a134aa736b2f32d414a88f81bdfa084587ec
|
Subproject commit ebcee0f982abcd11155bcab70929c9e341c4e60f
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -12,3 +12,8 @@ scpt/json/
|
|||||||
.ssh/*.pub
|
.ssh/*.pub
|
||||||
.ssh/*config
|
.ssh/*config
|
||||||
.env
|
.env
|
||||||
|
|
||||||
|
pnpm-lock.yaml
|
||||||
|
**Cargo.lock
|
||||||
|
*/target/
|
||||||
|
*/**/*.rs.bk
|
||||||
|
@ -69,7 +69,7 @@ $ ai bot
|
|||||||
|@yui.syui.ai fav|{cid}|mention, reply| [card.syui.ai](https://card.syui.ai) |user|
|
|@yui.syui.ai fav|{cid}|mention, reply| [card.syui.ai](https://card.syui.ai) |user|
|
||||||
|@yui.syui.ai egg|{password}|mention, reply| [card.syui.ai](https://card.syui.ai) |user|
|
|@yui.syui.ai egg|{password}|mention, reply| [card.syui.ai](https://card.syui.ai) |user|
|
||||||
|@yui.syui.ai 占い||mention, reply| [yui.syui.ai](https://yui.syui.ai) |user|
|
|@yui.syui.ai 占い||mention, reply| [yui.syui.ai](https://yui.syui.ai) |user|
|
||||||
|@yui.syui.ai nyan|🍰|mention, reply| [yui.syui.ai](https://yui.syui.ai) |user|
|
|@yui.syui.ai nyan|🍬|mention, reply| [yui.syui.ai](https://yui.syui.ai) |user|
|
||||||
|@yui.syui.ai diffusers|{keyword}|mention, reply| [huggingface.co/diffusers](https://huggingface.co/docs/diffusers/index) |user|
|
|@yui.syui.ai diffusers|{keyword}|mention, reply| [huggingface.co/diffusers](https://huggingface.co/docs/diffusers/index) |user|
|
||||||
|@yui.syui.ai sh|{command}|mention, reply| [archlinux.org](https://wiki.archlinux.org/title/Systemd-nspawn) |admin|
|
|@yui.syui.ai sh|{command}|mention, reply| [archlinux.org](https://wiki.archlinux.org/title/Systemd-nspawn) |admin|
|
||||||
|
|
||||||
|
28
docs/wiki.md
28
docs/wiki.md
@ -1,4 +1,11 @@
|
|||||||
### docker
|
## test-notify
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./target/debug/ai n|jq -r ".notifications|.[].cid" >> ~/.config/ai/txt/notify_cid*
|
||||||
|
./target/debug/ai bot
|
||||||
|
```
|
||||||
|
|
||||||
|
## docker
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ docker run -it syui/aios ai
|
$ docker run -it syui/aios ai
|
||||||
@ -11,7 +18,7 @@ $ cp -rf ~/.config/ai ./.config/
|
|||||||
$ docker compose up
|
$ docker compose up
|
||||||
```
|
```
|
||||||
|
|
||||||
### cron
|
## cron
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ sudo pacman -S fcron
|
$ sudo pacman -S fcron
|
||||||
@ -19,7 +26,7 @@ $ fcrontab -e
|
|||||||
* * * * * $HOME/bot/test/ai.zsh c
|
* * * * * $HOME/bot/test/ai.zsh c
|
||||||
```
|
```
|
||||||
|
|
||||||
### ssh
|
## ssh
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ ssh-keygen -f /.ssh/diffusers.key -t ed25519
|
$ ssh-keygen -f /.ssh/diffusers.key -t ed25519
|
||||||
@ -50,3 +57,18 @@ services:
|
|||||||
- ./.config:/root/.config
|
- ./.config:/root/.config
|
||||||
command: ai bot -a syui.syu.is
|
command: ai bot -a syui.syu.is
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## openapi
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# https://github.com/rdmurphy/atproto-openapi-types
|
||||||
|
$ curl -sLO https://raw.githubusercontent.com/rdmurphy/atproto-openapi-types/main/spec/api.json
|
||||||
|
```
|
||||||
|
|
||||||
|
## plc
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# 何度か実行するとplcをlatestまでexportされる
|
||||||
|
$ .config/ai/scpt/test/pds.zsh e
|
||||||
|
```
|
||||||
|
|
||||||
|
88
src/bot.rs
88
src/bot.rs
@ -10,6 +10,7 @@ use crate::reply_link;
|
|||||||
|
|
||||||
use crate::data::c_char;
|
use crate::data::c_char;
|
||||||
use crate::data::data_scpt;
|
use crate::data::data_scpt;
|
||||||
|
use crate::data::data_toml;
|
||||||
use crate::data::log_file;
|
use crate::data::log_file;
|
||||||
use crate::data::w_cid;
|
use crate::data::w_cid;
|
||||||
use crate::data::Notify;
|
use crate::data::Notify;
|
||||||
@ -22,7 +23,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
notify = notify::get_request(100).await;
|
notify = notify::get_request(100).await;
|
||||||
}
|
}
|
||||||
let notify: Notify = serde_json::from_str(¬ify).unwrap();
|
let notify: Notify = serde_json::from_str(¬ify).unwrap();
|
||||||
|
let host = data_toml(&"host");
|
||||||
let n = notify.notifications;
|
let n = notify.notifications;
|
||||||
let length = &n.len();
|
let length = &n.len();
|
||||||
let su = 0..*length;
|
let su = 0..*length;
|
||||||
@ -80,8 +81,8 @@ pub fn c_bot(c: &Context) {
|
|||||||
println!("{}", read);
|
println!("{}", read);
|
||||||
println!("{}", handle);
|
println!("{}", handle);
|
||||||
println!(
|
println!(
|
||||||
"cid:{}\nuri:{}\ncid_root:{}\nuri_root:{}",
|
"cid:{}\nuri:{}\ncid_root:{}\nuri_root:{}\nhost:{}",
|
||||||
cid, uri, cid_root, uri_root
|
cid, uri, cid_root, uri_root, host
|
||||||
);
|
);
|
||||||
println!("reason:{}\ncom:{}\nprompt:{}", reason, com, prompt);
|
println!("reason:{}\ncom:{}\nprompt:{}", reason, com, prompt);
|
||||||
println!("prompt_sub:{}", prompt_sub);
|
println!("prompt_sub:{}", prompt_sub);
|
||||||
@ -117,7 +118,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
w_cid(cid.to_string(), log_file(&"n1"), true);
|
w_cid(cid.to_string(), log_file(&"n1"), true);
|
||||||
println!("{}", str_rep);
|
println!("{}", str_rep);
|
||||||
}
|
}
|
||||||
} else if com == "help" {
|
} else if com == "help" || com == "/help" {
|
||||||
let link = "https://git.syui.ai/ai/bot/wiki/help".to_string();
|
let link = "https://git.syui.ai/ai/bot/wiki/help".to_string();
|
||||||
let s = 0;
|
let s = 0;
|
||||||
let e = link.chars().count();
|
let e = link.chars().count();
|
||||||
@ -134,7 +135,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
.await;
|
.await;
|
||||||
w_cid(cid.to_string(), log_file(&"n1"), true);
|
w_cid(cid.to_string(), log_file(&"n1"), true);
|
||||||
println!("{}", str_rep);
|
println!("{}", str_rep);
|
||||||
} else if com == "diffusers" {
|
} else if com == "diffusers" || com == "/diffusers" {
|
||||||
let _output = Command::new(data_scpt(&"ai"))
|
let _output = Command::new(data_scpt(&"ai"))
|
||||||
.arg(&"atproto").arg(&"diffusers")
|
.arg(&"atproto").arg(&"diffusers")
|
||||||
.arg(&handle)
|
.arg(&handle)
|
||||||
@ -143,6 +144,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
.arg(&uri)
|
.arg(&uri)
|
||||||
.arg(&cid_root)
|
.arg(&cid_root)
|
||||||
.arg(&uri_root)
|
.arg(&uri_root)
|
||||||
|
.arg(&host)
|
||||||
.arg(&prompt)
|
.arg(&prompt)
|
||||||
.arg(&prompt_sub)
|
.arg(&prompt_sub)
|
||||||
.output()
|
.output()
|
||||||
@ -152,7 +154,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
|| com.contains("うらない") == true
|
|| com.contains("うらない") == true
|
||||||
|| com.contains("うらなって") == true
|
|| com.contains("うらなって") == true
|
||||||
{
|
{
|
||||||
let output = Command::new(data_scpt(&"ai"))
|
let _output = Command::new(data_scpt(&"ai"))
|
||||||
.arg(&"atproto").arg(&"fortune")
|
.arg(&"atproto").arg(&"fortune")
|
||||||
.arg(&handle)
|
.arg(&handle)
|
||||||
.arg(&did)
|
.arg(&did)
|
||||||
@ -160,18 +162,13 @@ pub fn c_bot(c: &Context) {
|
|||||||
.arg(&uri)
|
.arg(&uri)
|
||||||
.arg(&cid_root)
|
.arg(&cid_root)
|
||||||
.arg(&uri_root)
|
.arg(&uri_root)
|
||||||
|
.arg(&host)
|
||||||
.arg(&prompt)
|
.arg(&prompt)
|
||||||
.arg(&prompt_sub)
|
.arg(&prompt_sub)
|
||||||
.output()
|
.output()
|
||||||
.expect("zsh");
|
.expect("zsh");
|
||||||
let d = String::from_utf8_lossy(&output.stdout);
|
|
||||||
let d = d.to_string();
|
|
||||||
let text_limit = c_char(d);
|
|
||||||
if text_limit.len() > 3 {
|
|
||||||
println!("{}", text_limit);
|
|
||||||
w_cid(cid.to_string(), log_file(&"n1"), true);
|
w_cid(cid.to_string(), log_file(&"n1"), true);
|
||||||
}
|
} else if com == "card" || com == "/card" {
|
||||||
} else if com == "card" {
|
|
||||||
let output = Command::new(data_scpt(&"ai"))
|
let output = Command::new(data_scpt(&"ai"))
|
||||||
.arg(&"atproto").arg(&"card")
|
.arg(&"atproto").arg(&"card")
|
||||||
.arg(&handle)
|
.arg(&handle)
|
||||||
@ -180,6 +177,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
.arg(&uri)
|
.arg(&uri)
|
||||||
.arg(&cid_root)
|
.arg(&cid_root)
|
||||||
.arg(&uri_root)
|
.arg(&uri_root)
|
||||||
|
.arg(&host)
|
||||||
.arg(&prompt)
|
.arg(&prompt)
|
||||||
.arg(&prompt_sub)
|
.arg(&prompt_sub)
|
||||||
.output()
|
.output()
|
||||||
@ -188,7 +186,10 @@ pub fn c_bot(c: &Context) {
|
|||||||
let dd = "\n".to_owned() + &d.to_string();
|
let dd = "\n".to_owned() + &d.to_string();
|
||||||
let text_limit = c_char(dd);
|
let text_limit = c_char(dd);
|
||||||
if text_limit.len() > 3 {
|
if text_limit.len() > 3 {
|
||||||
if d.contains("handle") == false {
|
//handlev = handle.replace(".", "-").to_string();
|
||||||
|
handlev = d.lines().collect::<Vec<_>>()[0].to_string();
|
||||||
|
link = "https://card.syui.ai/".to_owned() + &handlev;
|
||||||
|
e = link.chars().count();
|
||||||
let str_rep = reply_link::post_request(
|
let str_rep = reply_link::post_request(
|
||||||
text_limit.to_string(),
|
text_limit.to_string(),
|
||||||
link.to_string(),
|
link.to_string(),
|
||||||
@ -201,26 +202,9 @@ pub fn c_bot(c: &Context) {
|
|||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
println!("{}", str_rep);
|
println!("{}", str_rep);
|
||||||
} else {
|
|
||||||
handlev = handle.replace(".", "-").to_string();
|
|
||||||
link = "https://card.syui.ai/".to_owned() + &handlev;
|
|
||||||
e = link.chars().count();
|
|
||||||
let str_rep = reply_link::post_request(
|
|
||||||
d.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);
|
w_cid(cid.to_string(), log_file(&"n1"), true);
|
||||||
}
|
}
|
||||||
} else if com == "fav" {
|
} else if com == "fav" || com == "/fav" {
|
||||||
let output = Command::new(data_scpt(&"ai"))
|
let output = Command::new(data_scpt(&"ai"))
|
||||||
.arg(&"atproto").arg(&"fav")
|
.arg(&"atproto").arg(&"fav")
|
||||||
.arg(&handle)
|
.arg(&handle)
|
||||||
@ -229,6 +213,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
.arg(&uri)
|
.arg(&uri)
|
||||||
.arg(&cid_root)
|
.arg(&cid_root)
|
||||||
.arg(&uri_root)
|
.arg(&uri_root)
|
||||||
|
.arg(&host)
|
||||||
.arg(&prompt)
|
.arg(&prompt)
|
||||||
.arg(&prompt_sub)
|
.arg(&prompt_sub)
|
||||||
.output()
|
.output()
|
||||||
@ -237,8 +222,11 @@ pub fn c_bot(c: &Context) {
|
|||||||
let dd = "\n".to_owned() + &d.to_string();
|
let dd = "\n".to_owned() + &d.to_string();
|
||||||
let text_limit = c_char(dd);
|
let text_limit = c_char(dd);
|
||||||
if text_limit.len() > 3 {
|
if text_limit.len() > 3 {
|
||||||
|
handlev = d.lines().collect::<Vec<_>>()[0].to_string();
|
||||||
|
link = "https://card.syui.ai/".to_owned() + &handlev;
|
||||||
|
e = link.chars().count();
|
||||||
let str_rep = reply_link::post_request(
|
let str_rep = reply_link::post_request(
|
||||||
d.to_string(),
|
text_limit.to_string(),
|
||||||
link.to_string(),
|
link.to_string(),
|
||||||
s,
|
s,
|
||||||
e.try_into().unwrap(),
|
e.try_into().unwrap(),
|
||||||
@ -251,7 +239,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
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 == "egg" {
|
} else if com == "egg" || com == "/egg" {
|
||||||
let output = Command::new(data_scpt(&"ai"))
|
let output = Command::new(data_scpt(&"ai"))
|
||||||
.arg(&"atproto").arg(&"egg")
|
.arg(&"atproto").arg(&"egg")
|
||||||
.arg(&handle)
|
.arg(&handle)
|
||||||
@ -260,6 +248,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
.arg(&uri)
|
.arg(&uri)
|
||||||
.arg(&cid_root)
|
.arg(&cid_root)
|
||||||
.arg(&uri_root)
|
.arg(&uri_root)
|
||||||
|
.arg(&host)
|
||||||
.arg(&prompt)
|
.arg(&prompt)
|
||||||
.arg(&prompt_sub)
|
.arg(&prompt_sub)
|
||||||
.output()
|
.output()
|
||||||
@ -268,8 +257,11 @@ pub fn c_bot(c: &Context) {
|
|||||||
let dd = "\n".to_owned() + &d.to_string();
|
let dd = "\n".to_owned() + &d.to_string();
|
||||||
let text_limit = c_char(dd);
|
let text_limit = c_char(dd);
|
||||||
if text_limit.len() > 3 {
|
if text_limit.len() > 3 {
|
||||||
|
handlev = d.lines().collect::<Vec<_>>()[0].to_string();
|
||||||
|
link = "https://card.syui.ai/".to_owned() + &handlev;
|
||||||
|
e = link.chars().count();
|
||||||
let str_rep = reply_link::post_request(
|
let str_rep = reply_link::post_request(
|
||||||
d.to_string(),
|
text_limit.to_string(),
|
||||||
link.to_string(),
|
link.to_string(),
|
||||||
s,
|
s,
|
||||||
e.try_into().unwrap(),
|
e.try_into().unwrap(),
|
||||||
@ -282,7 +274,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
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 == "nyan" {
|
} else if com == "nyan" || com == "/nyan" {
|
||||||
let output = Command::new(data_scpt(&"ai"))
|
let output = Command::new(data_scpt(&"ai"))
|
||||||
.arg(&"atproto").arg(&"nyan")
|
.arg(&"atproto").arg(&"nyan")
|
||||||
.arg(&handle)
|
.arg(&handle)
|
||||||
@ -291,6 +283,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
.arg(&uri)
|
.arg(&uri)
|
||||||
.arg(&cid_root)
|
.arg(&cid_root)
|
||||||
.arg(&uri_root)
|
.arg(&uri_root)
|
||||||
|
.arg(&host)
|
||||||
.arg(&prompt)
|
.arg(&prompt)
|
||||||
.arg(&prompt_sub)
|
.arg(&prompt_sub)
|
||||||
.output()
|
.output()
|
||||||
@ -311,7 +304,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
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 == "ten" {
|
} else if com == "ten" || com == "/ten" {
|
||||||
let output = Command::new(data_scpt(&"ai"))
|
let output = Command::new(data_scpt(&"ai"))
|
||||||
.arg(&"atproto").arg(&"ten")
|
.arg(&"atproto").arg(&"ten")
|
||||||
.arg(&handle)
|
.arg(&handle)
|
||||||
@ -320,14 +313,18 @@ pub fn c_bot(c: &Context) {
|
|||||||
.arg(&uri)
|
.arg(&uri)
|
||||||
.arg(&cid_root)
|
.arg(&cid_root)
|
||||||
.arg(&uri_root)
|
.arg(&uri_root)
|
||||||
|
.arg(&host)
|
||||||
.arg(&prompt)
|
.arg(&prompt)
|
||||||
.arg(&prompt_sub)
|
.arg(&prompt_sub)
|
||||||
.output()
|
.output()
|
||||||
.expect("zsh");
|
.expect("zsh");
|
||||||
let d = String::from_utf8_lossy(&output.stdout);
|
let d = String::from_utf8_lossy(&output.stdout);
|
||||||
let d = "\n".to_owned() + &d.to_string();
|
let dd = "\n".to_owned() + &d.to_string();
|
||||||
let text_limit = c_char(d);
|
let text_limit = c_char(dd);
|
||||||
if text_limit.len() > 3 {
|
if text_limit.len() > 3 {
|
||||||
|
handlev = d.lines().collect::<Vec<_>>()[0].to_string();
|
||||||
|
link = "https://card.syui.ai/".to_owned() + &handlev;
|
||||||
|
e = link.chars().count();
|
||||||
let str_rep = reply_link::post_request(
|
let str_rep = reply_link::post_request(
|
||||||
text_limit.to_string(),
|
text_limit.to_string(),
|
||||||
link.to_string(),
|
link.to_string(),
|
||||||
@ -342,7 +339,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
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 == "coin" {
|
} else if com == "coin" || com == "/coin" {
|
||||||
let output = Command::new(data_scpt(&"ai"))
|
let output = Command::new(data_scpt(&"ai"))
|
||||||
.arg(&"atproto").arg(&"coin")
|
.arg(&"atproto").arg(&"coin")
|
||||||
.arg(&handle)
|
.arg(&handle)
|
||||||
@ -351,13 +348,18 @@ pub fn c_bot(c: &Context) {
|
|||||||
.arg(&uri)
|
.arg(&uri)
|
||||||
.arg(&cid_root)
|
.arg(&cid_root)
|
||||||
.arg(&uri_root)
|
.arg(&uri_root)
|
||||||
|
.arg(&host)
|
||||||
.arg(&prompt)
|
.arg(&prompt)
|
||||||
.arg(&prompt_sub)
|
.arg(&prompt_sub)
|
||||||
.output()
|
.output()
|
||||||
.expect("zsh");
|
.expect("zsh");
|
||||||
let d = String::from_utf8_lossy(&output.stdout);
|
let d = String::from_utf8_lossy(&output.stdout);
|
||||||
let d = "\n".to_owned() + &d.to_string();
|
let dd = "\n".to_owned() + &d.to_string();
|
||||||
let text_limit = c_char(d);
|
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 {
|
if text_limit.len() > 3 {
|
||||||
let str_rep = reply_link::post_request(
|
let str_rep = reply_link::post_request(
|
||||||
text_limit.to_string(),
|
text_limit.to_string(),
|
||||||
@ -383,6 +385,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
.arg(&uri)
|
.arg(&uri)
|
||||||
.arg(&cid_root)
|
.arg(&cid_root)
|
||||||
.arg(&uri_root)
|
.arg(&uri_root)
|
||||||
|
.arg(&host)
|
||||||
.arg(&prompt)
|
.arg(&prompt)
|
||||||
.arg(&prompt_sub)
|
.arg(&prompt_sub)
|
||||||
.output()
|
.output()
|
||||||
@ -410,6 +413,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
.arg(&uri)
|
.arg(&uri)
|
||||||
.arg(&cid_root)
|
.arg(&cid_root)
|
||||||
.arg(&uri_root)
|
.arg(&uri_root)
|
||||||
|
.arg(&host)
|
||||||
.arg(&prompt)
|
.arg(&prompt)
|
||||||
.arg(&prompt_sub)
|
.arg(&prompt_sub)
|
||||||
.output()
|
.output()
|
||||||
|
Loading…
Reference in New Issue
Block a user