From e7c06cf9d169bcbd6ed3f6e4a62b5f568c0e46fd Mon Sep 17 00:00:00 2001 From: syui Date: Tue, 2 Apr 2024 17:07:18 +0900 Subject: [PATCH] test manga --- .config/ai/scpt | 2 +- docs/wiki.md | 140 +++++++++++++++++++++++++++++++++++++++++++++ src/bot.rs | 40 ++++++++++++- src/main.rs | 3 + test/cron.zsh | 6 +- test/entrypoint.sh | 2 +- 6 files changed, 187 insertions(+), 6 deletions(-) diff --git a/.config/ai/scpt b/.config/ai/scpt index ebcee0f..a447e15 160000 --- a/.config/ai/scpt +++ b/.config/ai/scpt @@ -1 +1 @@ -Subproject commit ebcee0f982abcd11155bcab70929c9e341c4e60f +Subproject commit a447e15d0be30b3f749bcaa092ba101df63a125f diff --git a/docs/wiki.md b/docs/wiki.md index 376f7a3..6cd280f 100644 --- a/docs/wiki.md +++ b/docs/wiki.md @@ -72,3 +72,143 @@ $ curl -sLO https://raw.githubusercontent.com/rdmurphy/atproto-openapi-types/mai $ .config/ai/scpt/test/pds.zsh e ``` +## manga + +```sh +$ ai bot --manga_uri at://did:plc:dconvttcori3mrh2wrmehvwt/app.bsky.feed.post/3kp4zdnlo5s2j +``` + +```json +[ +{ + "uri": "at://did:plc:wkzuqomvkxx5eiv5nl2lvm23/app.bsky.feed.post/3kp4ze5dcek2j", + "cid": "bafyreic4g7mthhw654zgv4skt5tqbs2xqg6n7bli4gayl2nquljngnotiy", + "author": { + "did": "did:plc:wkzuqomvkxx5eiv5nl2lvm23", + "handle": "syui.syu.is", + "displayName": "syui", + "avatar": "https://api.syu.is/img/avatar/plain/did:plc:wkzuqomvkxx5eiv5nl2lvm23/bafkreifvabvstfgawt6csagh44xdevb6c2uiwpgfho3xnpdrr6o7nbkxry@jpeg", + "indexedAt": "2024-01-14T10:20:13.367Z", + "viewer": { + "muted": false, + "blockedBy": false, + "following": "at://did:plc:dconvttcori3mrh2wrmehvwt/app.bsky.graph.follow/3kiztjatnms25", + "followedBy": "at://did:plc:wkzuqomvkxx5eiv5nl2lvm23/app.bsky.graph.follow/3kirwsboeos26" + }, + "labels": [] + }, + "reason": "reply", + "reasonSubject": "at://did:plc:dconvttcori3mrh2wrmehvwt/app.bsky.feed.post/3kp4zdnlo5s2j", + "record": { + "text": "1", + "$type": "app.bsky.feed.post", + "langs": [ + "ja" + ], + "reply": { + "root": { + "cid": "bafyreiceckunxajycacn7dbuojrwb2wmurhfkleermvewwik44cn6vqo3a", + "uri": "at://did:plc:dconvttcori3mrh2wrmehvwt/app.bsky.feed.post/3kp4zdnlo5s2j" + }, + "parent": { + "cid": "bafyreiceckunxajycacn7dbuojrwb2wmurhfkleermvewwik44cn6vqo3a", + "uri": "at://did:plc:dconvttcori3mrh2wrmehvwt/app.bsky.feed.post/3kp4zdnlo5s2j" + } + }, + "createdAt": "2024-04-02T07:12:28.799Z" + }, + "isRead": true, + "indexedAt": "2024-04-02T07:12:28.799Z", + "labels": [] +}, +{ + "uri": "at://did:plc:wkzuqomvkxx5eiv5nl2lvm23/app.bsky.feed.post/3kp54af2zes2j", + "cid": "bafyreig4kvfpu557qehttt2y5eh7rcyodbxqwtnl73f3fhjsstiap3abzu", + "author": { + "did": "did:plc:wkzuqomvkxx5eiv5nl2lvm23", + "handle": "syui.syu.is", + "displayName": "syui", + "avatar": "https://api.syu.is/img/avatar/plain/did:plc:wkzuqomvkxx5eiv5nl2lvm23/bafkreifvabvstfgawt6csagh44xdevb6c2uiwpgfho3xnpdrr6o7nbkxry@jpeg", + "indexedAt": "2024-01-14T10:20:13.367Z", + "viewer": { + "muted": false, + "blockedBy": false, + "following": "at://did:plc:dconvttcori3mrh2wrmehvwt/app.bsky.graph.follow/3kiztjatnms25", + "followedBy": "at://did:plc:wkzuqomvkxx5eiv5nl2lvm23/app.bsky.graph.follow/3kirwsboeos26" + }, + "labels": [] + }, + "reason": "reply", + "reasonSubject": "at://did:plc:dconvttcori3mrh2wrmehvwt/app.bsky.feed.post/3kp4zdnlo5s2j", + "record": { + "text": "2", + "$type": "app.bsky.feed.post", + "langs": [ + "ja" + ], + "reply": { + "root": { + "cid": "bafyreiceckunxajycacn7dbuojrwb2wmurhfkleermvewwik44cn6vqo3a", + "uri": "at://did:plc:dconvttcori3mrh2wrmehvwt/app.bsky.feed.post/3kp4zdnlo5s2j" + }, + "parent": { + "cid": "bafyreiceckunxajycacn7dbuojrwb2wmurhfkleermvewwik44cn6vqo3a", + "uri": "at://did:plc:dconvttcori3mrh2wrmehvwt/app.bsky.feed.post/3kp4zdnlo5s2j" + } + }, + "createdAt": "2024-04-02T08:04:03.938Z" + }, + "isRead": true, + "indexedAt": "2024-04-02T08:04:03.938Z", + "labels": [] +} +] +``` + +```sh +$ ai bot -a syui.ai --manga_uri at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.post/3kp5qn72s232q +``` + +```json +{ + "uri": "at://did:plc:uqzpqmrjnptsxezjx4xuh2mn/app.bsky.feed.post/3kp5qniyzm42h", + "cid": "bafyreihmutmtf2clpgmx5l3qpu6xea6z25xrop74mltsycs5lfacm27u6e", + "author": { + "did": "did:plc:uqzpqmrjnptsxezjx4xuh2mn", + "handle": "syui.ai", + "displayName": "syui", + "avatar": "https://cdn.bsky.app/img/avatar/plain/did:plc:uqzpqmrjnptsxezjx4xuh2mn/bafkreid6kcc5pnn4b3ar7mj6vi3eiawhxgkcrw3edgbqeacyrlnlcoetea@jpeg", + "viewer": { + "muted": false, + "blockedBy": false, + "followedBy": "at://did:plc:uqzpqmrjnptsxezjx4xuh2mn/app.bsky.graph.follow/3kkvst5iq6r2a" + }, + "labels": [], + "description": "https://syui.ai", + "indexedAt": "2024-01-25T23:54:12.979Z" + }, + "reason": "reply", + "reasonSubject": "at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.post/3kp5qn72s232q", + "record": { + "$type": "app.bsky.feed.post", + "createdAt": "2024-04-02T14:09:18.926Z", + "langs": [ + "ja" + ], + "reply": { + "parent": { + "cid": "bafyreiewdfyh6rywpkdzpmf5markqa6tavc5smc32q7cw2wpwbqik5hnfm", + "uri": "at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.post/3kp5qn72s232q" + }, + "root": { + "cid": "bafyreiewdfyh6rywpkdzpmf5markqa6tavc5smc32q7cw2wpwbqik5hnfm", + "uri": "at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.post/3kp5qn72s232q" + } + }, + "text": "first" + }, + "isRead": true, + "indexedAt": "2024-04-02T14:09:18.926Z", + "labels": [] +} +``` diff --git a/src/bot.rs b/src/bot.rs index a01ba8d..aaa0695 100644 --- a/src/bot.rs +++ b/src/bot.rs @@ -94,6 +94,16 @@ pub fn c_bot(c: &Context) { admin = c.string_flag("admin").unwrap(); } + let mut manga_uri = "".to_string(); + if c.string_flag("manga_uri").is_ok() { + manga_uri = c.string_flag("manga_uri").unwrap(); + } + + let mut avatar = "".to_string(); + if let Some(v) = &n[i].author.avatar { + avatar = v.to_string(); + } + if check_cid == false && { reason == "mention" || reason == "reply" } || check_cid_run == false && { reason == "mention" || reason == "reply" } { @@ -446,6 +456,34 @@ pub fn c_bot(c: &Context) { println!("{}", str_rep); w_cid(cid.to_string(), log_file(&"n1"), true); } + } else if uri_root == &manga_uri { + println!("manga_uri:{}", manga_uri); + let output = Command::new(data_scpt(&"ai")) + .arg(&"atproto").arg(&"manga") + .arg(&handle) + .arg(&did) + .arg(&cid) + .arg(&uri) + .arg(&cid_root) + .arg(&uri_root) + .arg(&host) + .arg(&avatar) + .arg(&prompt_chat) + .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_chat.to_string()).await; @@ -457,7 +495,7 @@ pub fn c_bot(c: &Context) { cid_root.to_string(), uri_root.to_string(), ) - .await; + .await; println!("{}", str_rep); w_cid(cid.to_string(), log_file(&"n1"), true); } diff --git a/src/main.rs b/src/main.rs index e86ebf3..d403067 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,6 +59,9 @@ fn main() { Flag::new("admin", FlagType::String) .alias("a"), ) + .flag( + Flag::new("manga_uri", FlagType::String) + ) ) .command( Command::new("follow_all") diff --git a/test/cron.zsh b/test/cron.zsh index e9f389a..dd361d0 100644 --- a/test/cron.zsh +++ b/test/cron.zsh @@ -1,7 +1,7 @@ function cron() { - t=`docker ps |grep aios|grep Up` + t=`docker ps |grep aios|grep R` if [ -z "$t" ];then - docker compose up -d + exit fi - exit + docker compose up -d } diff --git a/test/entrypoint.sh b/test/entrypoint.sh index bed078b..cb75c63 100644 --- a/test/entrypoint.sh +++ b/test/entrypoint.sh @@ -1,3 +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 --manga_uri $MANGA_URI