add bot comment system
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5s
This commit is contained in:
parent
840320d0d2
commit
e17819aeeb
@ -1 +1 @@
|
|||||||
Subproject commit 69a235a0aa7c9965de1d76a70f35099fcdcbedf5
|
Subproject commit 1ef638646a11e9ff6cc0aac0813bd808d4163361
|
28
docs/wiki.md
28
docs/wiki.md
@ -72,12 +72,32 @@ $ curl -sLO https://raw.githubusercontent.com/rdmurphy/atproto-openapi-types/mai
|
|||||||
$ .config/ai/scpt/test/pds.zsh e
|
$ .config/ai/scpt/test/pds.zsh e
|
||||||
```
|
```
|
||||||
|
|
||||||
## manga
|
## cmt
|
||||||
|
|
||||||
|
blogなどにblueskyアカウントのpostを表示します。
|
||||||
|
|
||||||
|
以下でbotがblogのコメントシステムを開きます。
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ ai bot --manga_uri at://did:plc:dconvttcori3mrh2wrmehvwt/app.bsky.feed.post/3kp4zdnlo5s2j
|
@yui.syui.ai /comment https://syui.ai/blog/post/2024/04/25/bluesky/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
開いたbotのpostに返信することで、特定のblog path上でpostを表示します。
|
||||||
|
|
||||||
|
<blockquote class="bluesky-embed" data-bluesky-uri="at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.post/3kqxbtmwlje2h" data-bluesky-cid="bafyreiasxp5g3nkkd6g7lxh55qaxcc7ylefaljmbcp627nu2geks62c57m"><p lang="">please reply with your comments here ↓
|
||||||
|
</p>— ai (<a href="https://bsky.app/profile/did:plc:4hqjfn7m6n5hno3doamuhgef?ref_src=embed">@yui.syui.ai</a>) <a href="https://bsky.app/profile/did:plc:4hqjfn7m6n5hno3doamuhgef/post/3kqxbtmwlje2h?ref_src=embed">Apr 25, 2024 at 20:18</a></blockquote><script async src="https://embed.bsky.app/static/embed.js" charset="utf-8"></script>
|
||||||
|
|
||||||
|
```ts
|
||||||
|
<link href="https://syui.ai/js/comment/app.js" rel="preload" as="script">
|
||||||
|
<link href="https://syui.ai/js/comment/chunk-vendors.js" rel="preload" as="script">
|
||||||
|
<div id="comment"></div>
|
||||||
|
<script async src="https://embed.bsky.app/static/embed.js" charset="utf-8"></script>
|
||||||
|
<script src="https://syui.ai/js/comment/chunk-vendors.js"></script>
|
||||||
|
<script src="https://syui.ai/js/comment/app.js"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## example json
|
||||||
|
|
||||||
```json
|
```json
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -165,10 +185,6 @@ $ ai bot --manga_uri at://did:plc:dconvttcori3mrh2wrmehvwt/app.bsky.feed.post/3k
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh
|
|
||||||
$ ai bot -a syui.ai --manga_uri at://did:plc:4hqjfn7m6n5hno3doamuhgef/app.bsky.feed.post/3kp5qn72s232q
|
|
||||||
```
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"uri": "at://did:plc:uqzpqmrjnptsxezjx4xuh2mn/app.bsky.feed.post/3kp5qniyzm42h",
|
"uri": "at://did:plc:uqzpqmrjnptsxezjx4xuh2mn/app.bsky.feed.post/3kp5qniyzm42h",
|
||||||
|
47
src/bot.rs
47
src/bot.rs
@ -46,6 +46,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
cid_root = &n[i].record.reply.as_ref().unwrap().root.cid;
|
cid_root = &n[i].record.reply.as_ref().unwrap().root.cid;
|
||||||
uri_root = &n[i].record.reply.as_ref().unwrap().root.uri;
|
uri_root = &n[i].record.reply.as_ref().unwrap().root.uri;
|
||||||
}
|
}
|
||||||
|
let check_uri_comment = w_cid(uri_root.to_string(), log_file(&"c1"), false);
|
||||||
|
|
||||||
let mut text = "";
|
let mut text = "";
|
||||||
if !n[i].record.text.is_none() {
|
if !n[i].record.text.is_none() {
|
||||||
@ -96,11 +97,6 @@ pub fn c_bot(c: &Context) {
|
|||||||
admin = c.string_flag("admin").unwrap();
|
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();
|
let mut avatar = "".to_string();
|
||||||
if let Some(v) = &n[i].author.avatar {
|
if let Some(v) = &n[i].author.avatar {
|
||||||
avatar = v.to_string();
|
avatar = v.to_string();
|
||||||
@ -423,6 +419,34 @@ pub fn c_bot(c: &Context) {
|
|||||||
.await;
|
.await;
|
||||||
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 check_uri_comment == true {
|
||||||
|
println!("admin:{}", admin);
|
||||||
|
let output = Command::new(data_scpt(&"ai"))
|
||||||
|
.arg(&"atproto").arg(&"comment")
|
||||||
|
.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 if { com == "sh" || com == "/sh" } && handle == &admin {
|
} else if { com == "sh" || com == "/sh" } && handle == &admin {
|
||||||
println!("admin:{}", admin);
|
println!("admin:{}", admin);
|
||||||
let output = Command::new(data_scpt(&"ai"))
|
let output = Command::new(data_scpt(&"ai"))
|
||||||
@ -486,10 +510,10 @@ 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 uri_root == &manga_uri {
|
} else if { com == "comment" || com == "/comment" } && { handle == &admin || handle == "yui.bsky.social" } && check_uri_comment == false {
|
||||||
println!("manga_uri:{}", manga_uri);
|
println!("admin:{}", admin);
|
||||||
let output = Command::new(data_scpt(&"ai"))
|
let output = Command::new(data_scpt(&"ai"))
|
||||||
.arg(&"atproto").arg(&"manga")
|
.arg(&"atproto").arg(&"comment")
|
||||||
.arg(&handle)
|
.arg(&handle)
|
||||||
.arg(&did)
|
.arg(&did)
|
||||||
.arg(&cid)
|
.arg(&cid)
|
||||||
@ -514,6 +538,7 @@ pub fn c_bot(c: &Context) {
|
|||||||
.await;
|
.await;
|
||||||
println!("{}", str_rep);
|
println!("{}", str_rep);
|
||||||
w_cid(cid.to_string(), log_file(&"n1"), true);
|
w_cid(cid.to_string(), log_file(&"n1"), true);
|
||||||
|
w_cid(uri_root.to_string(), log_file(&"c1"), true);
|
||||||
} else {
|
} else {
|
||||||
// openai
|
// openai
|
||||||
let str_openai = openai::post_request(prompt_chat.to_string()).await;
|
let str_openai = openai::post_request(prompt_chat.to_string()).await;
|
||||||
@ -565,7 +590,10 @@ pub fn c_bot_feed(c: &Context) {
|
|||||||
let uri_root = uri;
|
let uri_root = uri;
|
||||||
let check_cid = w_cid(cid.to_string(), log_file(&"n1"), false);
|
let check_cid = w_cid(cid.to_string(), log_file(&"n1"), false);
|
||||||
let check_cid_run = w_cid(cid.to_string(), log_file(&"n2"), false);
|
let check_cid_run = w_cid(cid.to_string(), log_file(&"n2"), false);
|
||||||
|
//let mut avatar = "".to_string();
|
||||||
|
//if let Some(v) = &n[i].post.author.avatar {
|
||||||
|
// avatar = v.to_string();
|
||||||
|
//}
|
||||||
let mut text = "";
|
let mut text = "";
|
||||||
if !n[i].post.record.text.is_none() {
|
if !n[i].post.record.text.is_none() {
|
||||||
text = &n[i].post.record.text.as_ref().unwrap();
|
text = &n[i].post.record.text.as_ref().unwrap();
|
||||||
@ -950,6 +978,7 @@ pub fn c_bot_feed(c: &Context) {
|
|||||||
.await;
|
.await;
|
||||||
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 == "quiz" || com == "/quiz" {
|
} else if com == "quiz" || com == "/quiz" {
|
||||||
println!("admin:{}", admin);
|
println!("admin:{}", admin);
|
||||||
let output = Command::new(data_scpt(&"ai"))
|
let output = Command::new(data_scpt(&"ai"))
|
||||||
|
@ -34,6 +34,7 @@ pub fn log_file(s: &str) -> String {
|
|||||||
match &*s {
|
match &*s {
|
||||||
"n1" => f + &"notify_cid.txt",
|
"n1" => f + &"notify_cid.txt",
|
||||||
"n2" => f + &"notify_cid_run.txt",
|
"n2" => f + &"notify_cid_run.txt",
|
||||||
|
"c1" => f + &"comment_cid.txt",
|
||||||
_ => f + &s,
|
_ => f + &s,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,9 +66,6 @@ fn main() {
|
|||||||
Flag::new("feed", FlagType::String)
|
Flag::new("feed", FlagType::String)
|
||||||
.alias("f"),
|
.alias("f"),
|
||||||
)
|
)
|
||||||
.flag(
|
|
||||||
Flag::new("manga_uri", FlagType::String)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.command(
|
.command(
|
||||||
Command::new("follow_all")
|
Command::new("follow_all")
|
||||||
|
Loading…
Reference in New Issue
Block a user