Compare commits
5 Commits
main
...
cfe71a9547
| Author | SHA1 | Date | |
|---|---|---|---|
|
cfe71a9547
|
|||
|
7dd71cd9d5
|
|||
|
184aa09f8f
|
|||
|
071f8c3299
|
|||
|
f4948f319e
|
Submodule .config/ai/scpt updated: 7a4d642e41...03a64c3652
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,6 +1,6 @@
|
|||||||
Cargo.lock
|
Cargo.lock
|
||||||
target
|
target
|
||||||
#*.json
|
*.json
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
**.DS_Store
|
**.DS_Store
|
||||||
scpt/json/
|
scpt/json/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "aibot"
|
name = "ai"
|
||||||
authors = ["syui"]
|
authors = ["syui"]
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
FROM syui/aios
|
FROM syui/aios
|
||||||
|
ADD .ssh /root/.ssh
|
||||||
|
|
||||||
WORKDIR /root
|
WORKDIR /root
|
||||||
ADD ./test/entrypoint.sh .
|
ADD ./test/entrypoint.sh .
|
||||||
RUN chmod +x /root/entrypoint.sh
|
RUN chmod +x /root/entrypoint.sh
|
||||||
|
RUN pacman -Syu bc --noconfirm
|
||||||
|
|
||||||
ENTRYPOINT ["/root/entrypoint.sh"]
|
ENTRYPOINT ["/root/entrypoint.sh"]
|
||||||
|
|||||||
47
README.md
47
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)
|
- host : [yui.syui.ai](https://bsky.app/profile/yui.syui.ai), [ai.syu.is](https://web.syu.is/profile/ai.syu.is)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ aibot
|
$ ai
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ docker run -it syui/aios aibot
|
$ docker run -it syui/aios ai
|
||||||
```
|
```
|
||||||
|
|
||||||
### build
|
### build
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ cargo build
|
$ cargo build
|
||||||
$ ./target/debug/aibot ai
|
$ ./target/debug/ai ai
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ aibot ai -t avatar
|
$ ai ai -t avatar
|
||||||
```
|
```
|
||||||
|
|
||||||
### login
|
### login
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# ai login $handle -p $password
|
# ai login $handle -p $password
|
||||||
$ aibot l yui.syui.ai -p password
|
$ ai l yui.syui.ai -p password
|
||||||
|
|
||||||
$ cat ~/.config/ai/token.toml
|
$ cat ~/.config/ai/token.toml
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# ai l $handle -p $password -s $server
|
# 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
|
### refresh
|
||||||
|
|
||||||
```
|
```
|
||||||
$ aibot r
|
$ ai r
|
||||||
```
|
```
|
||||||
|
|
||||||
### notify
|
### notify
|
||||||
|
|
||||||
```
|
```
|
||||||
$ aibot n
|
$ ai n
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
$ aibot n | jq .
|
$ ai n | jq .
|
||||||
```
|
```
|
||||||
|
|
||||||
### bot
|
### bot
|
||||||
|
|
||||||
```
|
```
|
||||||
$ aibot bot
|
$ ai bot
|
||||||
```
|
```
|
||||||
|
|
||||||
|command|sub|type|link|auth|
|
|command|sub|type|link|auth|
|
||||||
@@ -108,7 +108,7 @@ $ docker compose build
|
|||||||
$ docker compose up -d
|
$ docker compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
## pds:card
|
## pds
|
||||||
|
|
||||||
- https://atproto.com/ja/guides/lexicon
|
- https://atproto.com/ja/guides/lexicon
|
||||||
- https://at.syu.is/at/did:plc:uqzpqmrjnptsxezjx4xuh2mn/ai.syui.card/3lagpwihqxi2v
|
- https://at.syu.is/at/did:plc:uqzpqmrjnptsxezjx4xuh2mn/ai.syui.card/3lagpwihqxi2v
|
||||||
@@ -116,29 +116,4 @@ $ docker compose up -d
|
|||||||
```sh
|
```sh
|
||||||
# oauth(button)
|
# oauth(button)
|
||||||
[yui]ai.syui.card.verify -> [user]ai.syui.card
|
[yui]ai.syui.card.verify -> [user]ai.syui.card
|
||||||
|
|
||||||
[yui]
|
|
||||||
$ ./target/debug/ai card-verify -i 0 -p 0 -r 0 -h syui.ai -d did:plc:uqzpqmrjnptsxezjx4xuh2mn
|
|
||||||
{"uri":"at://did:plc:4hqjfn7m6n5hno3doamuhgef/ai.syui.card.verify/3lagpvhppmd2q"}
|
|
||||||
|
|
||||||
[user]
|
|
||||||
$ ./target/debug/ai card -i 0 -p 0 -r 0 -v at://did:plc:4hqjfn7m6n5hno3doamuhgef/ai.syui.card.verify/3lagpvhppmd2q
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## pds:game
|
|
||||||
|
|
||||||
- https://atproto.com/ja/specs/record-key
|
|
||||||
- https://at.syu.is/at/did:plc:uqzpqmrjnptsxezjx4xuh2mn/ai.syui.game/self
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# oauth(play)
|
|
||||||
[yui]ai.syui.game.user -> [user]ai.syui.game
|
|
||||||
|
|
||||||
[account]
|
|
||||||
# https://at.syu.is/at/did:plc:4hqjfn7m6n5hno3doamuhgef/ai.syui.game.user/syui
|
|
||||||
## [rkey]
|
|
||||||
1. echo $handle|cut -d . -f 1
|
|
||||||
2. $handle
|
|
||||||
3. tid
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|||||||
36
src/bot.rs
36
src/bot.rs
@@ -431,42 +431,6 @@ 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 == "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" {
|
} 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"))
|
||||||
|
|||||||
15
src/data.rs
15
src/data.rs
@@ -8,7 +8,7 @@ use std::io::Write;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
pub fn data_file(s: &str) -> String {
|
pub fn data_file(s: &str) -> String {
|
||||||
let file = "/.config/syui/ai/bot/";
|
let file = "/.config/ai/";
|
||||||
let mut f = shellexpand::tilde("~").to_string();
|
let mut f = shellexpand::tilde("~").to_string();
|
||||||
f.push_str(&file);
|
f.push_str(&file);
|
||||||
let path = Path::new(&f);
|
let path = Path::new(&f);
|
||||||
@@ -24,7 +24,7 @@ pub fn data_file(s: &str) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn log_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();
|
let mut f = shellexpand::tilde("~").to_string();
|
||||||
f.push_str(&file);
|
f.push_str(&file);
|
||||||
let path = Path::new(&f);
|
let path = Path::new(&f);
|
||||||
@@ -107,7 +107,6 @@ pub struct BaseUrl {
|
|||||||
pub record_list: String,
|
pub record_list: String,
|
||||||
pub record_create: String,
|
pub record_create: String,
|
||||||
pub record_delete: String,
|
pub record_delete: String,
|
||||||
pub record_put: String,
|
|
||||||
pub session_create: String,
|
pub session_create: String,
|
||||||
pub session_refresh: String,
|
pub session_refresh: String,
|
||||||
pub session_get: String,
|
pub session_get: String,
|
||||||
@@ -143,7 +142,6 @@ pub fn url(s: &str) -> String {
|
|||||||
let baseurl = BaseUrl {
|
let baseurl = BaseUrl {
|
||||||
profile_get: "com.atproto.identity.resolveHandle".to_string(),
|
profile_get: "com.atproto.identity.resolveHandle".to_string(),
|
||||||
thread_get: "app.bsky.feed.getPostThread".to_string(),
|
thread_get: "app.bsky.feed.getPostThread".to_string(),
|
||||||
record_put: "com.atproto.repo.putRecord".to_string(),
|
|
||||||
record_create: "com.atproto.repo.createRecord".to_string(),
|
record_create: "com.atproto.repo.createRecord".to_string(),
|
||||||
record_delete: "com.atproto.repo.deleteRecord".to_string(),
|
record_delete: "com.atproto.repo.deleteRecord".to_string(),
|
||||||
describe: "com.atproto.repo.describeRepo".to_string(),
|
describe: "com.atproto.repo.describeRepo".to_string(),
|
||||||
@@ -175,7 +173,6 @@ pub fn url(s: &str) -> String {
|
|||||||
"record_list" => t.to_string() + &baseurl.record_list,
|
"record_list" => t.to_string() + &baseurl.record_list,
|
||||||
"record_create" => t.to_string() + &baseurl.record_create,
|
"record_create" => t.to_string() + &baseurl.record_create,
|
||||||
"record_delete" => t.to_string() + &baseurl.record_delete,
|
"record_delete" => t.to_string() + &baseurl.record_delete,
|
||||||
"record_put" => t.to_string() + &baseurl.record_put,
|
|
||||||
"session_create" => t.to_string() + &baseurl.session_create,
|
"session_create" => t.to_string() + &baseurl.session_create,
|
||||||
"session_refresh" => t.to_string() + &baseurl.session_refresh,
|
"session_refresh" => t.to_string() + &baseurl.session_refresh,
|
||||||
"session_get" => t.to_string() + &baseurl.session_get,
|
"session_get" => t.to_string() + &baseurl.session_get,
|
||||||
@@ -263,7 +260,7 @@ pub fn data_refresh(s: &str) -> String {
|
|||||||
|
|
||||||
pub fn data_scpt(s: &str) -> String {
|
pub fn data_scpt(s: &str) -> String {
|
||||||
let s = String::from(s);
|
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();
|
let mut f = shellexpand::tilde("~").to_string();
|
||||||
f.push_str(&file);
|
f.push_str(&file);
|
||||||
return f;
|
return f;
|
||||||
@@ -603,7 +600,7 @@ pub fn w_cid(cid: String, file: String, t: bool) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn c_follow_all() {
|
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();
|
let mut f = shellexpand::tilde("~").to_string();
|
||||||
f.push_str(&file);
|
f.push_str(&file);
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
@@ -617,7 +614,7 @@ pub fn c_openai_key(c: &Context) {
|
|||||||
let api = c.args[0].to_string();
|
let api = c.args[0].to_string();
|
||||||
let o = "api='".to_owned() + &api.to_string() + &"'".to_owned();
|
let o = "api='".to_owned() + &api.to_string() + &"'".to_owned();
|
||||||
let o = o.to_string();
|
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 l = l.to_string();
|
||||||
let mut l = fs::File::create(l).unwrap();
|
let mut l = fs::File::create(l).unwrap();
|
||||||
if o != "" {
|
if o != "" {
|
||||||
@@ -628,7 +625,7 @@ pub fn c_openai_key(c: &Context) {
|
|||||||
|
|
||||||
impl Open {
|
impl Open {
|
||||||
pub fn new() -> Result<Self, ConfigError> {
|
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()
|
let s = Config::builder()
|
||||||
.add_source(File::with_name(&d))
|
.add_source(File::with_name(&d))
|
||||||
.add_source(config::Environment::with_prefix("APP"))
|
.add_source(config::Environment::with_prefix("APP"))
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
pub mod post_card;
|
|
||||||
pub mod post_card_verify;
|
|
||||||
pub mod post_game;
|
|
||||||
pub mod post_game_user;
|
|
||||||
pub mod post_game_login;
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
extern crate reqwest;
|
|
||||||
use crate::data_toml;
|
|
||||||
use crate::data_refresh;
|
|
||||||
use crate::url;
|
|
||||||
use iso8601_timestamp::Timestamp;
|
|
||||||
use serde_json::json;
|
|
||||||
|
|
||||||
pub async fn post_request(col: String, account: String) -> String {
|
|
||||||
let token = data_refresh(&"access");
|
|
||||||
let did = data_toml(&"did");
|
|
||||||
let handle = data_toml(&"handle");
|
|
||||||
let url = url(&"record_put");
|
|
||||||
let d = Timestamp::now_utc();
|
|
||||||
let d = d.to_string();
|
|
||||||
let post = Some(json!({
|
|
||||||
"repo": handle.to_string(),
|
|
||||||
"did": did.to_string(),
|
|
||||||
"collection": col.to_string(),
|
|
||||||
"rkey": "self".to_string(),
|
|
||||||
"record": {
|
|
||||||
"account": account.to_string(),
|
|
||||||
"createdAt": d.to_string(),
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
let client = reqwest::Client::new();
|
|
||||||
let res = client
|
|
||||||
.post(url)
|
|
||||||
.json(&post)
|
|
||||||
.header("Authorization", "Bearer ".to_owned() + &token)
|
|
||||||
.send()
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.text()
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
extern crate reqwest;
|
|
||||||
use crate::data_toml;
|
|
||||||
use crate::data_refresh;
|
|
||||||
use crate::url;
|
|
||||||
use iso8601_timestamp::Timestamp;
|
|
||||||
use serde_json::json;
|
|
||||||
|
|
||||||
pub async fn post_request(col: String, username: String, login: bool, account: String) -> String {
|
|
||||||
let token = data_refresh(&"access");
|
|
||||||
let did = data_toml(&"did");
|
|
||||||
let handle = data_toml(&"handle");
|
|
||||||
let url = url(&"record_put");
|
|
||||||
let d = Timestamp::now_utc();
|
|
||||||
let d = d.to_string();
|
|
||||||
|
|
||||||
let post = Some(json!({
|
|
||||||
"repo": handle.to_string(),
|
|
||||||
"did": did.to_string(),
|
|
||||||
"collection": col.to_string(),
|
|
||||||
"rkey": "self".to_string(),
|
|
||||||
"record": {
|
|
||||||
"login": login,
|
|
||||||
"username": username.to_string(),
|
|
||||||
"account": account.to_string(),
|
|
||||||
"createdAt": d.to_string(),
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
let client = reqwest::Client::new();
|
|
||||||
let res = client
|
|
||||||
.post(url)
|
|
||||||
.json(&post)
|
|
||||||
.header("Authorization", "Bearer ".to_owned() + &token)
|
|
||||||
.send()
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.text()
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
extern crate reqwest;
|
|
||||||
use crate::data_toml;
|
|
||||||
use crate::data_refresh;
|
|
||||||
use crate::url;
|
|
||||||
use iso8601_timestamp::Timestamp;
|
|
||||||
use serde_json::json;
|
|
||||||
|
|
||||||
pub async fn post_request(col: String, user_name: String, user_did: String, user_handle: String, aiten: i32, limit: i32, chara: String, lv: i32, exp: i32, hp: i32, rank: i32, mode: i32, attach: i32, critical: i32, critical_d: i32) -> String {
|
|
||||||
let token = data_refresh(&"access");
|
|
||||||
let did = data_toml(&"did");
|
|
||||||
let handle = data_toml(&"handle");
|
|
||||||
let url = url(&"record_put");
|
|
||||||
let d = Timestamp::now_utc();
|
|
||||||
let d = d.to_string();
|
|
||||||
let post = Some(json!({
|
|
||||||
"repo": handle.to_string(),
|
|
||||||
"did": did.to_string(),
|
|
||||||
"collection": col.to_string(),
|
|
||||||
"rkey": user_name.to_string(),
|
|
||||||
"record": {
|
|
||||||
"did": user_did.to_string(),
|
|
||||||
"handle": user_handle.to_string(),
|
|
||||||
"aiten": aiten,
|
|
||||||
"limit": limit,
|
|
||||||
"character": {
|
|
||||||
chara.to_string(): {
|
|
||||||
"lv": lv,
|
|
||||||
"exp": exp,
|
|
||||||
"hp": hp,
|
|
||||||
"rank": rank,
|
|
||||||
"mode": mode,
|
|
||||||
"attach": attach,
|
|
||||||
"critical": critical,
|
|
||||||
"critical_d": critical_d,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"createdAt": d.to_string(),
|
|
||||||
"updatedAt": d.to_string(),
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
let client = reqwest::Client::new();
|
|
||||||
let res = client
|
|
||||||
.post(url)
|
|
||||||
.json(&post)
|
|
||||||
.header("Authorization", "Bearer ".to_owned() + &token)
|
|
||||||
.send()
|
|
||||||
.await
|
|
||||||
.unwrap()
|
|
||||||
.text()
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
193
src/main.rs
193
src/main.rs
@@ -12,11 +12,6 @@ use crate::data::url;
|
|||||||
use crate::data::w_cfg;
|
use crate::data::w_cfg;
|
||||||
use crate::data::w_refresh;
|
use crate::data::w_refresh;
|
||||||
use crate::feed_watch::c_feed_watch;
|
use crate::feed_watch::c_feed_watch;
|
||||||
use crate::game::post_card;
|
|
||||||
use crate::game::post_card_verify;
|
|
||||||
use crate::game::post_game;
|
|
||||||
use crate::game::post_game_user;
|
|
||||||
use crate::game::post_game_login;
|
|
||||||
|
|
||||||
use data::ProfileIdentityResolve;
|
use data::ProfileIdentityResolve;
|
||||||
|
|
||||||
@@ -35,7 +30,8 @@ pub mod notify_read;
|
|||||||
pub mod openai;
|
pub mod openai;
|
||||||
pub mod post;
|
pub mod post;
|
||||||
pub mod post_link;
|
pub mod post_link;
|
||||||
pub mod game;
|
pub mod post_card;
|
||||||
|
pub mod post_card_verify;
|
||||||
pub mod profile;
|
pub mod profile;
|
||||||
pub mod refresh;
|
pub mod refresh;
|
||||||
pub mod reply;
|
pub mod reply;
|
||||||
@@ -197,7 +193,7 @@ fn main() {
|
|||||||
)
|
)
|
||||||
.command(
|
.command(
|
||||||
Command::new("card-verify")
|
Command::new("card-verify")
|
||||||
.description("<at://verify> -c <collection> -i <id> -p <cp> -r <rank> -rare <normal> -H <syui.ai> -d <did>")
|
.description("<at://verify> -c <collection> -i <id> -p <cp> -r <rank> -rare <normal> -h <syui.ai> -d <did>")
|
||||||
.action(card_verify)
|
.action(card_verify)
|
||||||
.flag(
|
.flag(
|
||||||
Flag::new("col", FlagType::String)
|
Flag::new("col", FlagType::String)
|
||||||
@@ -220,100 +216,13 @@ fn main() {
|
|||||||
)
|
)
|
||||||
.flag(
|
.flag(
|
||||||
Flag::new("handle", FlagType::String)
|
Flag::new("handle", FlagType::String)
|
||||||
.alias("H"),
|
.alias("handle"),
|
||||||
)
|
)
|
||||||
.flag(
|
.flag(
|
||||||
Flag::new("did", FlagType::String)
|
Flag::new("did", FlagType::String)
|
||||||
.alias("did"),
|
.alias("did"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.command(
|
|
||||||
Command::new("game")
|
|
||||||
.description("a <at://yui.syui.ai/ai.syui.game.user/username>")
|
|
||||||
.action(game)
|
|
||||||
.flag(
|
|
||||||
Flag::new("col", FlagType::String)
|
|
||||||
.alias("c"),
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("account", FlagType::String)
|
|
||||||
.alias("a"),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.command(
|
|
||||||
Command::new("game-login")
|
|
||||||
.description("l <bool> -u <username> -c <collection>")
|
|
||||||
.action(game_login)
|
|
||||||
.flag(
|
|
||||||
Flag::new("col", FlagType::String)
|
|
||||||
.alias("c"),
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("login", FlagType::Bool)
|
|
||||||
.alias("l"),
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("username", FlagType::String)
|
|
||||||
.alias("u"),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.command(
|
|
||||||
Command::new("game-user")
|
|
||||||
.description("-chara ai -l 20240101 -ten 0 --lv 0 --exp 0 --hp 0 --rank 0 --mode 0 --attach 0 --critical 0 --critical_d 0")
|
|
||||||
.action(game_user)
|
|
||||||
.flag(
|
|
||||||
Flag::new("username", FlagType::String)
|
|
||||||
.alias("u"),
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("col", FlagType::String)
|
|
||||||
.alias("c"),
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("did", FlagType::String)
|
|
||||||
.alias("d"),
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("handle", FlagType::String)
|
|
||||||
.alias("H"),
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("character", FlagType::String)
|
|
||||||
.alias("chara"),
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("aiten", FlagType::Int)
|
|
||||||
.alias("ten"),
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("limit", FlagType::Int)
|
|
||||||
.alias("l"),
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("lv", FlagType::Int)
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("hp", FlagType::Int)
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("attach", FlagType::Int)
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("exp", FlagType::Int)
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("critical", FlagType::Int)
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("critical_d", FlagType::Int)
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("rank", FlagType::Int)
|
|
||||||
)
|
|
||||||
.flag(
|
|
||||||
Flag::new("mode", FlagType::Int)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.command(
|
.command(
|
||||||
Command::new("like")
|
Command::new("like")
|
||||||
.description("like <cid> -u <uri>")
|
.description("like <cid> -u <uri>")
|
||||||
@@ -394,10 +303,6 @@ fn main() {
|
|||||||
Flag::new("post", FlagType::String)
|
Flag::new("post", FlagType::String)
|
||||||
.alias("p"),
|
.alias("p"),
|
||||||
)
|
)
|
||||||
.flag(
|
|
||||||
Flag::new("col", FlagType::String)
|
|
||||||
.alias("c"),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.command(
|
.command(
|
||||||
Command::new("follow")
|
Command::new("follow")
|
||||||
@@ -673,8 +578,6 @@ async fn c_card_verify(c: &Context) -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let rare = c.string_flag("rare").unwrap_or_else(|_| "normal".to_string());
|
let rare = c.string_flag("rare").unwrap_or_else(|_| "normal".to_string());
|
||||||
let user_handle = c.string_flag("handle").unwrap_or_else(|_| "syui.ai".to_string());
|
let user_handle = c.string_flag("handle").unwrap_or_else(|_| "syui.ai".to_string());
|
||||||
let user_did = c.string_flag("did").unwrap_or_else(|_| "did:plc:uqzpqmrjnptsxezjx4xuh2mn".to_string());
|
let user_did = c.string_flag("did").unwrap_or_else(|_| "did:plc:uqzpqmrjnptsxezjx4xuh2mn".to_string());
|
||||||
|
|
||||||
//match id === 1 let img = "xxx";
|
|
||||||
let str = post_card_verify::post_request(col, img, id, cp, rank, rare, user_handle, user_did);
|
let str = post_card_verify::post_request(col, img, id, cp, rank, rare, user_handle, user_did);
|
||||||
println!("{}", str.await);
|
println!("{}", str.await);
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -691,92 +594,6 @@ fn card_verify(c: &Context) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn c_game(c: &Context) -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let account = c.string_flag("account").unwrap_or_else(|_| "at://did:plc:4hqjfn7m6n5hno3doamuhgef/ai.syui.game.user/syui".to_string());
|
|
||||||
let col = c.string_flag("col").unwrap_or_else(|_| "ai.syui.game".to_string());
|
|
||||||
let handle = data_toml(&"handle");
|
|
||||||
if handle == "syui.ai" {
|
|
||||||
let str = post_game::post_request(col, account);
|
|
||||||
println!("{}", str.await);
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(Box::new(std::io::Error::new(std::io::ErrorKind::PermissionDenied, "Not authorized")))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn game(c: &Context) {
|
|
||||||
refresh(c);
|
|
||||||
tokio::runtime::Runtime::new()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(async {
|
|
||||||
if let Err(e) = c_game(c).await {
|
|
||||||
eprintln!("Error: {}", e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn c_game_user(c: &Context) -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let col = c.string_flag("col").unwrap_or_else(|_| "ai.syui.game.user".to_string());
|
|
||||||
let user_name = c.string_flag("username").unwrap_or_else(|_| "syui".to_string());
|
|
||||||
let user_handle = c.string_flag("handle").unwrap_or_else(|_| "syui.ai".to_string());
|
|
||||||
let user_did = c.string_flag("did").unwrap_or_else(|_| "did:plc:uqzpqmrjnptsxezjx4xuh2mn".to_string());
|
|
||||||
let chara = c.string_flag("character").unwrap_or_else(|_| "ai".to_string());
|
|
||||||
let limit = c.int_flag("limit")?.try_into()?;
|
|
||||||
let aiten = c.int_flag("aiten")?.try_into()?;
|
|
||||||
let lv = c.int_flag("lv")?.try_into()?;
|
|
||||||
let exp = c.int_flag("exp")?.try_into()?;
|
|
||||||
let hp = c.int_flag("hp")?.try_into()?;
|
|
||||||
let rank = c.int_flag("rank")?.try_into()?;
|
|
||||||
let mode = c.int_flag("mode")?.try_into()?;
|
|
||||||
let attach = c.int_flag("attach")?.try_into()?;
|
|
||||||
let critical = c.int_flag("critical")?.try_into()?;
|
|
||||||
let critical_d = c.int_flag("critical_d")?.try_into()?;
|
|
||||||
|
|
||||||
if data_toml(&"handle") == "yui.syui.ai" {
|
|
||||||
let str = post_game_user::post_request(col, user_name, user_did, user_handle, aiten, limit, chara, lv, exp, hp, rank, mode, attach, critical, critical_d);
|
|
||||||
println!("{}", str.await);
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(Box::new(std::io::Error::new(std::io::ErrorKind::PermissionDenied, "Not authorized")))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn game_user(c: &Context) {
|
|
||||||
refresh(c);
|
|
||||||
tokio::runtime::Runtime::new()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(async {
|
|
||||||
if let Err(e) = c_game_user(c).await {
|
|
||||||
eprintln!("Error: {}", e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn c_game_login(c: &Context) -> Result<(), Box<dyn std::error::Error>> {
|
|
||||||
let col = c.string_flag("col").unwrap_or_else(|_| "ai.syui.game.login".to_string());
|
|
||||||
let user_name = c.string_flag("username").unwrap_or_else(|_| "syui".to_string());
|
|
||||||
let account = "at://did:plc:4hqjfn7m6n5hno3doamuhgef/ai.syui.game.user/".to_string() + &user_name;
|
|
||||||
let login = c.bool_flag("login");
|
|
||||||
if data_toml(&"handle") == "yui.syui.ai" {
|
|
||||||
let str = post_game_login::post_request(col, user_name, login, account);
|
|
||||||
println!("{}", str.await);
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(Box::new(std::io::Error::new(std::io::ErrorKind::PermissionDenied, "Not authorized")))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn game_login(c: &Context) {
|
|
||||||
refresh(c);
|
|
||||||
tokio::runtime::Runtime::new()
|
|
||||||
.unwrap()
|
|
||||||
.block_on(async {
|
|
||||||
if let Err(e) = c_game_login(c).await {
|
|
||||||
eprintln!("Error: {}", e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn repost(c: &Context) {
|
fn repost(c: &Context) {
|
||||||
refresh(c);
|
refresh(c);
|
||||||
let m = c.args[0].to_string();
|
let m = c.args[0].to_string();
|
||||||
@@ -831,7 +648,6 @@ fn mention(c: &Context) {
|
|||||||
let h = async {
|
let h = async {
|
||||||
let str = profile::get_request(m.to_string()).await;
|
let str = profile::get_request(m.to_string()).await;
|
||||||
let profile: ProfileIdentityResolve = serde_json::from_str(&str).unwrap();
|
let profile: ProfileIdentityResolve = serde_json::from_str(&str).unwrap();
|
||||||
let col = c.string_flag("col").unwrap_or_else(|_| "app.bsky.feed.post".to_string());
|
|
||||||
let udid = profile.did;
|
let udid = profile.did;
|
||||||
let handle = m.to_string();
|
let handle = m.to_string();
|
||||||
let at = "@".to_owned() + &handle;
|
let at = "@".to_owned() + &handle;
|
||||||
@@ -839,7 +655,6 @@ fn mention(c: &Context) {
|
|||||||
let s = 0;
|
let s = 0;
|
||||||
if let Ok(post) = c.string_flag("post") {
|
if let Ok(post) = c.string_flag("post") {
|
||||||
let str = mention::post_request(
|
let str = mention::post_request(
|
||||||
col,
|
|
||||||
post.to_string(),
|
post.to_string(),
|
||||||
at.to_string(),
|
at.to_string(),
|
||||||
udid.to_string(),
|
udid.to_string(),
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ use crate::url;
|
|||||||
use iso8601_timestamp::Timestamp;
|
use iso8601_timestamp::Timestamp;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
pub async fn post_request(col: String, text: String, at: String, udid: String, s: i32, e: i32) -> String {
|
pub async fn post_request(text: String, at: String, udid: String, s: i32, e: i32) -> String {
|
||||||
let token = data_refresh(&"access");
|
let token = data_refresh(&"access");
|
||||||
let did = data_toml(&"did");
|
let did = data_toml(&"did");
|
||||||
let handle = data_toml(&"handle");
|
let handle = data_toml(&"handle");
|
||||||
|
|
||||||
let url = url(&"record_create");
|
let url = url(&"record_create");
|
||||||
//let col = "app.bsky.feed.post".to_string();
|
let col = "app.bsky.feed.post".to_string();
|
||||||
|
|
||||||
let d = Timestamp::now_utc();
|
let d = Timestamp::now_utc();
|
||||||
let d = d.to_string();
|
let d = d.to_string();
|
||||||
@@ -22,7 +22,7 @@ pub async fn post_request(col: String, text: String, at: String, udid: String, s
|
|||||||
"collection": col.to_string(),
|
"collection": col.to_string(),
|
||||||
"record": {
|
"record": {
|
||||||
"text": at.to_string() + &" ".to_string() + &text.to_string(),
|
"text": at.to_string() + &" ".to_string() + &text.to_string(),
|
||||||
"$type": col.to_string(),
|
"$type": "app.bsky.feed.post",
|
||||||
"createdAt": d.to_string(),
|
"createdAt": d.to_string(),
|
||||||
"facets": [
|
"facets": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ pub async fn post_request(verify: String, id: i32, cp: i32, rank: i32, rare: Str
|
|||||||
let token = data_refresh(&"access");
|
let token = data_refresh(&"access");
|
||||||
let did = data_toml(&"did");
|
let did = data_toml(&"did");
|
||||||
let handle = data_toml(&"handle");
|
let handle = data_toml(&"handle");
|
||||||
|
|
||||||
let url = url(&"record_create");
|
let url = url(&"record_create");
|
||||||
|
|
||||||
let d = Timestamp::now_utc();
|
let d = Timestamp::now_utc();
|
||||||
let d = d.to_string();
|
let d = d.to_string();
|
||||||
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
#!/bin/zsh
|
#!/bin/zsh
|
||||||
|
|
||||||
#ai l $HANDLE -p $PASSWORD -s $HOST
|
ai l $HANDLE -p $PASSWORD -s $HOST && ai bot -a $ADMIN
|
||||||
ai bot -a $ADMIN
|
|
||||||
|
|||||||
Reference in New Issue
Block a user