Compare commits
18 Commits
36bf489bdf
...
d310e21250
Author | SHA1 | Date |
---|---|---|
|
d310e21250 | 3 months ago |
|
452c1a0086 | 3 months ago |
|
a4230eae2f | 3 months ago |
|
2307b5006b | 3 months ago |
|
fd5406f7d2 | 3 months ago |
|
f90f1be997 | 3 months ago |
|
d44ef061da | 3 months ago |
|
c7dda61adf | 3 months ago |
|
757816adbf | 3 months ago |
|
0caa668e9c | 3 months ago |
|
0d992091cd | 3 months ago |
|
b5b47a155c | 3 months ago |
|
d4f72fe80e | 3 months ago |
|
da98d6818b | 3 months ago |
|
aad0ce0319 | 3 months ago |
|
42fb1513a1 | 3 months ago |
|
3f4f3acd90 | 3 months ago |
|
bf3006fd7a | 3 months ago |
@ -0,0 +1,79 @@
|
||||
#!/bin/zsh
|
||||
|
||||
home=/home/syui
|
||||
name=arch
|
||||
a=$home/$name
|
||||
|
||||
function arch_in(){
|
||||
mkdir -p $a
|
||||
sudo pacstrap -c $a base
|
||||
#sudo echo pts/0 >> $a/etc/securetty
|
||||
#sudo echo pts/1 >> $a/etc/securetty
|
||||
sudo rm -rf /var/lib/machines/$name
|
||||
sudo rm -rf /var/lib/machines/${name}back
|
||||
sudo mv $a /var/lib/machines/
|
||||
sudo machinectl clone arch archback
|
||||
}
|
||||
|
||||
function arch_rm(){
|
||||
sudo machinectl remove $name
|
||||
}
|
||||
|
||||
function arch_up(){
|
||||
sudo machinectl poweroff $name > /dev/null 2>&1
|
||||
sleep 5
|
||||
sudo machinectl terminate $name > /dev/null 2>&1
|
||||
sleep 5
|
||||
sudo machinectl start ${name}back
|
||||
sleep 5
|
||||
ssh ${name}back pacman -Syu --noconfirm
|
||||
sleep 5
|
||||
sudo machinectl poweroff ${name}back
|
||||
}
|
||||
|
||||
function arch_st(){
|
||||
sudo machinectl start $name
|
||||
}
|
||||
|
||||
function arch_of(){
|
||||
sudo machinectl poweroff $name
|
||||
}
|
||||
|
||||
function arch_ex(){
|
||||
sudo machinectl shell $name
|
||||
$1
|
||||
poweroff
|
||||
}
|
||||
|
||||
function arch_re(){
|
||||
sudo machinectl poweroff $name > /dev/null 2>&1
|
||||
sleep 5
|
||||
sudo machinectl terminate $name > /dev/null 2>&1
|
||||
sleep 5
|
||||
sudo machinectl remove $name
|
||||
sleep 5
|
||||
sudo machinectl clone ${name}back $name
|
||||
sleep 5
|
||||
sudo machinectl start $name
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"update"|"-u")
|
||||
arch_up
|
||||
arch_re
|
||||
echo "machinectl update done"
|
||||
;;
|
||||
"reset"|"-r")
|
||||
arch_re
|
||||
echo "machinectl reset done"
|
||||
;;
|
||||
*)
|
||||
sudo machinectl start $name
|
||||
t=`ssh $name "$*"`
|
||||
if [ -z "$t" ];then
|
||||
ssh -tt $name "$*"
|
||||
else
|
||||
echo "$t"
|
||||
fi
|
||||
;;
|
||||
esac
|
@ -0,0 +1,44 @@
|
||||
#!/bin/zsh
|
||||
|
||||
dir=${0:a:h}
|
||||
f=$dir/diffusion_prompt.txt
|
||||
|
||||
seed=$RANDOM
|
||||
|
||||
sd_prompt_a="masterpiece, high quality, very_high_resolution, large_filesize, full color"
|
||||
|
||||
case "$1" in
|
||||
"--anime"|"-a")
|
||||
## kawaii girl random prompt
|
||||
ra=$(($RANDOM % 2 + 1))
|
||||
rp="beautiful kawaii "`echo "little girl,girl"|cut -d , -f $ra|tr -d ,`
|
||||
rb=$(($RANDOM % 3 + 1))
|
||||
rbp="with "`echo "gold,silver,black"|cut -d , -f $rb|tr -d ,`" hair"
|
||||
rc=$(($RANDOM % 4 + 1))
|
||||
rcp=`echo "wavy,long,straight,"|cut -d , -f $rc|tr -d ,`
|
||||
rd=$(($RANDOM % 3 + 1))
|
||||
rdp="in "`echo "fluttery white onepice,simple white onepice,normal white school uniform"|cut -d , -f $rd|tr -d ,`
|
||||
sd_prompt_a="$sd_prompt_a, $rp $rdp $rcp $rbp"
|
||||
echo $sd_prompt_a >! $f
|
||||
;;
|
||||
"")
|
||||
exit
|
||||
;;
|
||||
*)
|
||||
echo $sd_prompt_a $* >! $f
|
||||
;;
|
||||
esac
|
||||
cat $f
|
||||
q=`cat $f`
|
||||
|
||||
rm -rf $dir/png
|
||||
mkdir -p $dir/png
|
||||
ssh win Remove-Item -Recurse -Force stable-diffusion/outputs
|
||||
ssh win Remove-Item -Recurse -Force msbot
|
||||
ssh win mkdir stable-diffusion/outputs
|
||||
ssh win mkdir msbot
|
||||
ssh win "conda activate ldm;cd ./stable-diffusion/;python optimizedSD/optimized_txt2img.py --prompt \"${q}\" --H 512 --W 512 --seed $seed --n_iter 1 --n_samples 1 --ddim_steps 50"
|
||||
diff_dir=`ssh win ls stable-diffusion/outputs/txt2img-samples -Name|cut -b 1-2`
|
||||
ssh win "cd stable-diffusion/outputs/txt2img-samples;mv $diff_dir* $diff_dir -Force;mv $diff_dir/*.png ~/msbot/t.png -Force"
|
||||
ssh win ".\scoop\apps\imagemagick\current\convert.exe msbot/t.png msbot/t.jpg"
|
||||
scp -r win:msbot/t.jpg $dir/png/t.jpg
|
@ -0,0 +1,31 @@
|
||||
extern crate reqwest;
|
||||
use crate::token_toml;
|
||||
use crate::url;
|
||||
use crate::Handle;
|
||||
|
||||
pub async fn post_request(handle: String) -> String {
|
||||
|
||||
let token = token_toml(&"access");
|
||||
let did = token_toml(&"did");
|
||||
let url = url(&"update_handle");
|
||||
|
||||
println!("DNS txt : _atproto.{}, did={}.", handle, did);
|
||||
|
||||
let handle = Handle {
|
||||
handle: handle.to_string()
|
||||
};
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let res = client
|
||||
.post(url)
|
||||
.json(&handle)
|
||||
.header("Authorization", "Bearer ".to_owned() + &token)
|
||||
.send()
|
||||
.await
|
||||
.unwrap()
|
||||
.text()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
return res
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
extern crate reqwest;
|
||||
use crate::token_toml;
|
||||
use crate::url;
|
||||
use serde_json::json;
|
||||
use iso8601_timestamp::Timestamp;
|
||||
|
||||
pub async fn post_request(text: String, at: String, udid: String, s: i32, e: i32) -> String {
|
||||
|
||||
let token = token_toml(&"access");
|
||||
let did = token_toml(&"did");
|
||||
|
||||
let url = url(&"record_create");
|
||||
let col = "app.bsky.feed.post".to_string();
|
||||
|
||||
let d = Timestamp::now_utc();
|
||||
let d = d.to_string();
|
||||
|
||||
let post = Some(json!({
|
||||
"did": did.to_string(),
|
||||
"collection": col.to_string(),
|
||||
"record": {
|
||||
"text": at.to_string() + &" ".to_string() + &text.to_string(),
|
||||
"createdAt": d.to_string(),
|
||||
"entities": [
|
||||
{
|
||||
"type": "mention".to_string(),
|
||||
"index": {
|
||||
"end": e,
|
||||
"start": s
|
||||
},
|
||||
"value": udid.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
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
extern crate reqwest;
|
||||
use crate::token_toml;
|
||||
use crate::url;
|
||||
//use serde_json::json;
|
||||
|
||||
pub async fn get_request(limit: i32) -> String {
|
||||
|
||||
let token = token_toml(&"access");
|
||||
let url = url(&"notify_list");
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let res = client
|
||||
.get(url)
|
||||
.query(&[("limit", limit)])
|
||||
.header("Authorization", "Bearer ".to_owned() + &token)
|
||||
.send()
|
||||
.await
|
||||
.unwrap()
|
||||
.text()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
return res
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
extern crate reqwest;
|
||||
use crate::token_toml;
|
||||
use crate::url;
|
||||
use serde_json::json;
|
||||
|
||||
pub async fn post_request(time: String) -> String {
|
||||
|
||||
let token = token_toml(&"access");
|
||||
let url = url(&"notify_update");
|
||||
|
||||
let post = Some(json!({
|
||||
"seenAt": time.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
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
extern crate reqwest;
|
||||
use crate::token_toml;
|
||||
use crate::url;
|
||||
use serde_json::json;
|
||||
use iso8601_timestamp::Timestamp;
|
||||
|
||||
pub async fn post_request(text: String) -> String {
|
||||
|
||||
let token = token_toml(&"access");
|
||||
let did = token_toml(&"did");
|
||||
|
||||
let url = url(&"record_create");
|
||||
let col = "app.bsky.feed.post".to_string();
|
||||
|
||||
let d = Timestamp::now_utc();
|
||||
let d = d.to_string();
|
||||
|
||||
let post = Some(json!({
|
||||
"did": did.to_string(),
|
||||
"collection": col.to_string(),
|
||||
"record": {
|
||||
"text": text.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
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
extern crate reqwest;
|
||||
use crate::token_toml;
|
||||
use crate::url;
|
||||
use serde_json::json;
|
||||
use iso8601_timestamp::Timestamp;
|
||||
|
||||
pub async fn post_request(text: String, link: String, s: i32, e: i32) -> String {
|
||||
|
||||
let token = token_toml(&"access");
|
||||
let did = token_toml(&"did");
|
||||
|
||||
let url = url(&"record_create");
|
||||
let col = "app.bsky.feed.post".to_string();
|
||||
|
||||
let d = Timestamp::now_utc();
|
||||
let d = d.to_string();
|
||||
|
||||
let post = Some(json!({
|
||||
"did": did.to_string(),
|
||||
"collection": col.to_string(),
|
||||
"record": {
|
||||
"text": link.to_string() + &" ".to_string() + &text.to_string(),
|
||||
"createdAt": d.to_string(),
|
||||
"entities": [
|
||||
{
|
||||
"type": "link".to_string(),
|
||||
"index": {
|
||||
"end": e,
|
||||
"start": s
|
||||
},
|
||||
"value": link.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
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
extern crate reqwest;
|
||||
use crate::token_toml;
|
||||
use crate::url;
|
||||
|
||||
pub async fn get_request(user: String) -> String {
|
||||
|
||||
let token = token_toml(&"access");
|
||||
let url = url(&"profile_get") + &"?actor=" + &user;
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let res = client
|
||||
.get(url)
|
||||
.header("Authorization", "Bearer ".to_owned() + &token)
|
||||
.send()
|
||||
.await
|
||||
.unwrap()
|
||||
.text()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
return res
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
extern crate reqwest;
|
||||
use crate::token_toml;
|
||||
use crate::url;
|
||||
use serde_json::json;
|
||||
use iso8601_timestamp::Timestamp;
|
||||
|
||||
pub async fn post_request(text: String, cid: String, uri: String) -> String {
|
||||
|
||||
let token = token_toml(&"access");
|
||||
let did = token_toml(&"did");
|
||||
|
||||
let url = url(&"record_create");
|
||||
//let url = "https://bsky.social/xrpc/com.atproto.repo.createRecord";
|
||||
let col = "app.bsky.feed.post".to_string();
|
||||
|
||||
let d = Timestamp::now_utc();
|
||||
let d = d.to_string();
|
||||
|
||||
let post = Some(json!({
|
||||
"did": did.to_string(),
|
||||
"collection": col.to_string(),
|
||||
"record": {
|
||||
"text": text.to_string(),
|
||||
"createdAt": d.to_string(),
|
||||
"reply": {
|
||||
"root": {
|
||||
"cid": cid.to_string(),
|
||||
"uri": uri.to_string()
|
||||
},
|
||||
"parent": {
|
||||
"cid": cid.to_string(),
|
||||
"uri": uri.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
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
extern crate reqwest;
|
||||
use crate::token_toml;
|
||||
use crate::url;
|
||||
use serde_json::json;
|
||||
use iso8601_timestamp::Timestamp;
|
||||
|
||||
pub async fn post_request(text: String, cid: String, uri: String, mid: String, itype: String) -> String {
|
||||
|
||||
let token = token_toml(&"access");
|
||||
let did = token_toml(&"did");
|
||||
|
||||
let url = url(&"record_create");
|
||||
//let url = "https://bsky.social/xrpc/com.atproto.repo.createRecord";
|
||||
let col = "app.bsky.feed.post".to_string();
|
||||
|
||||
let d = Timestamp::now_utc();
|
||||
let d = d.to_string();
|
||||
|
||||
//{
|
||||
// "did": "",
|
||||
// "collection": "",
|
||||
// "record": {
|
||||
// "text": "",
|
||||
// "createdAt": "",
|
||||
// "": "",
|
||||
// "embed": {
|
||||
// "$type": "app.bsky.embed.images",
|
||||
// "images": [
|
||||
// {
|
||||
// "image": {
|
||||
// "cid": "",
|
||||
// "mimeType": ""
|
||||
// },
|
||||
// "alt": ""
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
let post = Some(json!({
|
||||
"did": did.to_string(),
|
||||
"collection": col.to_string(),
|
||||
"record": {
|
||||
"text": text.to_string(),
|
||||
"createdAt": d.to_string(),
|
||||
"embed": {
|
||||
"$type": "app.bsky.embed.images",
|
||||
"images": [
|
||||
{
|
||||
"image": {
|
||||
"cid": mid.to_string(),
|
||||
"mimeType": itype.to_string()
|
||||
},
|
||||
"alt": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
"reply": {
|
||||
"root": {
|
||||
"cid": cid.to_string(),
|
||||
"uri": uri.to_string()
|
||||
},
|
||||
"parent": {
|
||||
"cid": cid.to_string(),
|
||||
"uri": uri.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
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
extern crate reqwest;
|
||||
use crate::token_toml;
|
||||
use crate::url;
|
||||
|
||||
pub async fn get_request() -> String {
|
||||
|
||||
let token = token_toml(&"access");
|
||||
let url = url(&"timeline_get");
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let res = client
|
||||
.get(url)
|
||||
.header("Authorization", "Bearer ".to_owned() + &token)
|
||||
.send()
|
||||
.await
|
||||
.unwrap()
|
||||
.text()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
return res
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
extern crate reqwest;
|
||||
use crate::Deeps;
|
||||
use crate::DeepData;
|
||||
use reqwest::header::AUTHORIZATION;
|
||||
use reqwest::header::CONTENT_TYPE;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub async fn post_request(prompt: String, lang: String) -> String {
|
||||
let lang = lang.to_string();
|
||||
let data = Deeps::new().unwrap();
|
||||
let data = Deeps {
|
||||
api: data.api,
|
||||
};
|
||||
let api = "DeepL-Auth-Key ".to_owned() + &data.api;
|
||||
let mut params = HashMap::new();
|
||||
params.insert("text", &prompt);
|
||||
params.insert("target_lang", &lang);
|
||||
let client = reqwest::Client::new();
|
||||
let res = client
|
||||
.post("https://api-free.deepl.com/v2/translate")
|
||||
.header(AUTHORIZATION, api)
|
||||
.header(CONTENT_TYPE, "json")
|
||||
.form(¶ms)
|
||||
.send()
|
||||
.await
|
||||
.unwrap()
|
||||
.text()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let p: DeepData = serde_json::from_str(&res).unwrap();
|
||||
let o = &p.translations[0].text;
|
||||
return o.to_string()
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,45 @@
|
||||
extern crate reqwest;
|
||||
use crate::Opens;
|
||||
use crate::OpenData;
|
||||
use serde_json::{json};
|
||||
|
||||
pub async fn post_request(prompt: String, model: String) -> String {
|
||||
let data = Opens::new().unwrap();
|
||||
let data = Opens {
|
||||
api: data.api,
|
||||
};
|
||||
|
||||
let temperature = 0.7;
|
||||
let max_tokens = 250;
|
||||
let top_p = 1;
|
||||
let frequency_penalty = 0;
|
||||
let presence_penalty = 0;
|
||||
let stop = "[\"###\"]";
|
||||
|
||||
let post = Some(json!({
|
||||
"prompt": &prompt.to_string(),
|
||||
"model": &model.to_string(),
|
||||
"temperature": temperature,
|
||||
"max_tokens": max_tokens,
|
||||
"top_p": top_p,
|
||||
"frequency_penalty": frequency_penalty,
|
||||
"presence_penalty": presence_penalty,
|
||||
"stop": stop,
|
||||
}));
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let res = client
|
||||
.post("https://api.openai.com/v1/completions")
|
||||
.header("Authorization", "Bearer ".to_owned() + &data.api)
|
||||
.json(&post)
|
||||
.send()
|
||||
.await
|
||||
.unwrap()
|
||||
.text()
|
||||
.await
|
||||
.unwrap();
|
||||
let p: OpenData = serde_json::from_str(&res).unwrap();
|
||||
let o = &p.choices[0].text;
|
||||
|
||||
return o.to_string()
|
||||
}
|
Loading…
Reference in New Issue