1
0

Compare commits

...

12 Commits

Author SHA1 Message Date
6fe572c1ad
fix
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
2024-03-30 02:52:33 +09:00
42fb82d8f6
fix
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
2024-03-29 17:35:35 +09:00
617ee3d39d
fix
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
2024-03-29 16:50:09 +09:00
b745b71fcd
fix fortune
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
2024-03-29 16:34:55 +09:00
127dde8b49
fix sp
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
2024-03-29 04:11:58 +09:00
99d7757cfd
fix
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 14s
2024-03-24 15:41:40 +09:00
0c2b3544ca
fix card handle
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 14m19s
2024-03-22 00:32:23 +09:00
54d867e420
fix
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
2024-03-13 19:08:16 +09:00
eb1c01910b
fix
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 8s
2024-03-13 10:42:37 +09:00
72b7fc1a52
fix print
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s
2024-03-10 13:43:46 +09:00
de2404c09f
fix
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
2024-03-10 13:39:45 +09:00
f57eebc6dc
add host
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 15s
2024-03-07 06:09:17 +09:00
5 changed files with 90 additions and 59 deletions

@ -1 +1 @@
Subproject commit bd22a134aa736b2f32d414a88f81bdfa084587ec
Subproject commit ebcee0f982abcd11155bcab70929c9e341c4e60f

5
.gitignore vendored
View File

@ -12,3 +12,8 @@ scpt/json/
.ssh/*.pub
.ssh/*config
.env
pnpm-lock.yaml
**Cargo.lock
*/target/
*/**/*.rs.bk

View File

@ -69,7 +69,7 @@ $ ai bot
|@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 占い||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 sh|{command}|mention, reply| [archlinux.org](https://wiki.archlinux.org/title/Systemd-nspawn) |admin|

View File

@ -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
$ docker run -it syui/aios ai
@ -11,7 +18,7 @@ $ cp -rf ~/.config/ai ./.config/
$ docker compose up
```
### cron
## cron
```sh
$ sudo pacman -S fcron
@ -19,7 +26,7 @@ $ fcrontab -e
* * * * * $HOME/bot/test/ai.zsh c
```
### ssh
## ssh
```sh
$ ssh-keygen -f /.ssh/diffusers.key -t ed25519
@ -50,3 +57,18 @@ services:
- ./.config:/root/.config
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
```

View File

@ -10,6 +10,7 @@ use crate::reply_link;
use crate::data::c_char;
use crate::data::data_scpt;
use crate::data::data_toml;
use crate::data::log_file;
use crate::data::w_cid;
use crate::data::Notify;
@ -22,7 +23,7 @@ pub fn c_bot(c: &Context) {
notify = notify::get_request(100).await;
}
let notify: Notify = serde_json::from_str(&notify).unwrap();
let host = data_toml(&"host");
let n = notify.notifications;
let length = &n.len();
let su = 0..*length;
@ -80,8 +81,8 @@ pub fn c_bot(c: &Context) {
println!("{}", read);
println!("{}", handle);
println!(
"cid:{}\nuri:{}\ncid_root:{}\nuri_root:{}",
cid, uri, cid_root, uri_root
"cid:{}\nuri:{}\ncid_root:{}\nuri_root:{}\nhost:{}",
cid, uri, cid_root, uri_root, host
);
println!("reason:{}\ncom:{}\nprompt:{}", reason, com, prompt);
println!("prompt_sub:{}", prompt_sub);
@ -117,7 +118,7 @@ pub fn c_bot(c: &Context) {
w_cid(cid.to_string(), log_file(&"n1"), true);
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 s = 0;
let e = link.chars().count();
@ -134,7 +135,7 @@ pub fn c_bot(c: &Context) {
.await;
w_cid(cid.to_string(), log_file(&"n1"), true);
println!("{}", str_rep);
} else if com == "diffusers" {
} else if com == "diffusers" || com == "/diffusers" {
let _output = Command::new(data_scpt(&"ai"))
.arg(&"atproto").arg(&"diffusers")
.arg(&handle)
@ -143,6 +144,7 @@ pub fn c_bot(c: &Context) {
.arg(&uri)
.arg(&cid_root)
.arg(&uri_root)
.arg(&host)
.arg(&prompt)
.arg(&prompt_sub)
.output()
@ -152,7 +154,7 @@ pub fn c_bot(c: &Context) {
|| 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(&handle)
.arg(&did)
@ -160,18 +162,13 @@ pub fn c_bot(c: &Context) {
.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 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);
}
} else if com == "card" {
w_cid(cid.to_string(), log_file(&"n1"), true);
} else if com == "card" || com == "/card" {
let output = Command::new(data_scpt(&"ai"))
.arg(&"atproto").arg(&"card")
.arg(&handle)
@ -180,6 +177,7 @@ pub fn c_bot(c: &Context) {
.arg(&uri)
.arg(&cid_root)
.arg(&uri_root)
.arg(&host)
.arg(&prompt)
.arg(&prompt_sub)
.output()
@ -188,39 +186,25 @@ pub fn c_bot(c: &Context) {
let dd = "\n".to_owned() + &d.to_string();
let text_limit = c_char(dd);
if text_limit.len() > 3 {
if d.contains("handle") == false {
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(),
)
//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(
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);
} 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);
}
println!("{}", str_rep);
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"))
.arg(&"atproto").arg(&"fav")
.arg(&handle)
@ -229,6 +213,7 @@ pub fn c_bot(c: &Context) {
.arg(&uri)
.arg(&cid_root)
.arg(&uri_root)
.arg(&host)
.arg(&prompt)
.arg(&prompt_sub)
.output()
@ -237,8 +222,11 @@ pub fn c_bot(c: &Context) {
let dd = "\n".to_owned() + &d.to_string();
let text_limit = c_char(dd);
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(
d.to_string(),
text_limit.to_string(),
link.to_string(),
s,
e.try_into().unwrap(),
@ -251,7 +239,7 @@ pub fn c_bot(c: &Context) {
println!("{}", str_rep);
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"))
.arg(&"atproto").arg(&"egg")
.arg(&handle)
@ -260,6 +248,7 @@ pub fn c_bot(c: &Context) {
.arg(&uri)
.arg(&cid_root)
.arg(&uri_root)
.arg(&host)
.arg(&prompt)
.arg(&prompt_sub)
.output()
@ -268,8 +257,11 @@ pub fn c_bot(c: &Context) {
let dd = "\n".to_owned() + &d.to_string();
let text_limit = c_char(dd);
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(
d.to_string(),
text_limit.to_string(),
link.to_string(),
s,
e.try_into().unwrap(),
@ -282,7 +274,7 @@ pub fn c_bot(c: &Context) {
println!("{}", str_rep);
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"))
.arg(&"atproto").arg(&"nyan")
.arg(&handle)
@ -291,6 +283,7 @@ pub fn c_bot(c: &Context) {
.arg(&uri)
.arg(&cid_root)
.arg(&uri_root)
.arg(&host)
.arg(&prompt)
.arg(&prompt_sub)
.output()
@ -311,7 +304,7 @@ pub fn c_bot(c: &Context) {
println!("{}", str_rep);
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"))
.arg(&"atproto").arg(&"ten")
.arg(&handle)
@ -320,14 +313,18 @@ pub fn c_bot(c: &Context) {
.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 d = "\n".to_owned() + &d.to_string();
let text_limit = c_char(d);
let dd = "\n".to_owned() + &d.to_string();
let text_limit = c_char(dd);
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(
text_limit.to_string(),
link.to_string(),
@ -342,7 +339,7 @@ pub fn c_bot(c: &Context) {
println!("{}", str_rep);
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"))
.arg(&"atproto").arg(&"coin")
.arg(&handle)
@ -351,13 +348,18 @@ pub fn c_bot(c: &Context) {
.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 d = "\n".to_owned() + &d.to_string();
let text_limit = c_char(d);
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(),
@ -383,6 +385,7 @@ pub fn c_bot(c: &Context) {
.arg(&uri)
.arg(&cid_root)
.arg(&uri_root)
.arg(&host)
.arg(&prompt)
.arg(&prompt_sub)
.output()
@ -410,6 +413,7 @@ pub fn c_bot(c: &Context) {
.arg(&uri)
.arg(&cid_root)
.arg(&uri_root)
.arg(&host)
.arg(&prompt)
.arg(&prompt_sub)
.output()