1
0
This commit is contained in:
syui 2024-04-06 02:14:12 +09:00
parent 06710243ad
commit 8b02d43124
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56
2 changed files with 103 additions and 50 deletions

View File

@ -8,9 +8,32 @@ $(function() {
if (did == null) { did = "did:plc:4hqjfn7m6n5hno3doamuhgef" };
if (user) { prompt = "[[b;#87cefa;]" + user + "][[b;#FFFF00;]@aios] ~$ " };
var tab = "[[b;#87cefa;]<tab>]";
var command_all = ["ai", "timeline", "bsky_ver", "handle", "did", "plc"];
var command_all = ["ai","ls","ai.json"];
var handle = "yui.syui.ai";
var file_all = "ai.json";
var ai_help = "\n\
\nCommands:\
\n ai\
\n\
\nFlags:\
\n\t\t-h, --help\
\n\
\nOptions:\
\n\ta\t\t\t\t: logo\
\n\tv\t\t\t\t: pds version\
\n\tp\t\t\t\t: ai profile\
\n\tdid\t<handle> : did\
\n\tplc\t<handle> : plc\
\n\trecord <handle> : timeline\
\n\
\nex:\
\n\t$ ai v\t: {\"version\":\"0.0.1\"}\
\n\t\
\nhttps://git.syui.ai/ai/bot\
\n\t\
";
var ascii_logo = '\n\ \n\ \n⢠⣿⣧\ \n⣰⣿⣿⣿⣧⡀\ \n⣰⣿⣿⣿⣿⣿⣷⡀\ \n⣼⣿⣿⣿⣿⣿⣿⣿⣿⡄\ \n⢀⣀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⣀\ \n⢀⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⣀\ \n⣠⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⡀\ \n⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⡀\ \n⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀\ \n⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠋⠉⠈⠉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡄\ \n⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠉⠈⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄\ \n⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀\ \n⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇\ \n⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁⢹⣿⣿⣿⣿⣿⣿⣿⣿⣿\ \n⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠈⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇\ \n⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇\ \n⢹⣿⣿⣿⣿⣿⣿⣿⣿⣷⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁\ \n⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⡿\ \n⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀\ \n⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⡀⣠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷\ \n⢠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⡀⣀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧\ \n⢠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣦⣤⣤⣤⣤⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇\ \n⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆\ \n⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆\ \n⠘⠛⠛⠛⠛⠉⠉⠉⠉⠁⠈⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠋⠉⠉⠉⠉⠙⠛⠛⠛⠛\ \n⠈⠙⠛⠿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠟⠋⠉\ \n⠈⠉⠉⠉⠉\ \n\n';
var ascii_ai = "\n\
@ -60,27 +83,52 @@ $(function() {
";
let list = 'https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=';
axios.get(list + did + '&collection=app.bsky.feed.post&limit=1')
.then(function (response) {
timeline = JSON.stringify(response.data.records[0].value,null,"\t");
})
function bsky_record() {
var u;
u = axios.get(list + did + '&collection=app.bsky.feed.post&limit=1')
.then(function (response) {
return JSON.stringify(response.data.records[0].value,null,"\t");
})
return u;
}
axios.get('https://bsky.social/xrpc/_health')
.then(function (response) {
bsky_ver = JSON.stringify(response.data,null,"\t");
})
function bsky_ver() {
var u;
u = axios.get('https://bsky.social/xrpc/_health')
.then(function (response) {
return JSON.stringify(response.data,null,"\t");
})
return u;
}
let plc_server = "https://plc.directory/"
axios.get(plc_server + did + '/log')
.then(function (response) {
plc = JSON.stringify(response.data,null,"\t");
})
function bsky_plc() {
var u;
u = axios.get(plc_server + did + '/log')
.then(function (response) {
return JSON.stringify(response.data,null,"\t");
})
return u;
}
let desc = 'https://bsky.social/xrpc/com.atproto.repo.describeRepo?repo=';
axios.get(desc + did + '&collection=app.bsky.actor.profile')
.then(function (response) {
bsky_did = JSON.stringify(response.data,null,"\t");
})
function bsky_desc() {
var u;
u = axios.get(desc + did + '&collection=app.bsky.actor.profile')
.then(function (response) {
return JSON.stringify(response.data,null,"\t");
})
return u;
}
function bsky_did() {
var u;
u = axios.get(desc + handle + '&collection=app.bsky.actor.profile')
.then(function (response) {
return JSON.stringify(response.data.did,null,"\t").replaceAll('"', '');
})
return u;
}
function test_json() {
var u;
@ -125,11 +173,27 @@ $(function() {
var command, inputs;
inputs = input.split(/ +/)
command = inputs[0];
if (inputs[0] === 'ai') {
option = inputs[1];
if (did == null) { did = "did:plc:4hqjfn7m6n5hno3doamuhgef" };
if (handle == null) { handle = "did:plc:4hqjfn7m6n5hno3doamuhgef" };
if (command === 'ai' && inputs[1] === undefined) {
term.echo(ai_help);
} else if (command === 'ls') {
term.echo(file_all);
} else if (command === 'cat') {
if (option === 'ai.json') {
term.echo(test_json());
} else {
term.echo(file_all);
}
} else if (command === 'ai' && option === 'a') {
print_slowly(term, ascii_logo);
} else if (command === 'ai' && option === 'p') {
term.echo(ascii_ai);
term.echo(test_json());
} else if (inputs[0] === 'plc' && inputs[1] != undefined) {
url = desc + inputs[1] + '&collection=app.bsky.actor.profile';
} else if (command === 'ai' && option === 'plc') {
if (inputs[2] != undefined) { did = inputs[2]; }
url = desc + did + '&collection=app.bsky.actor.profile';
$.ajaxSetup({async: false});
$.getJSON(url, function(data) {
did = JSON.stringify(data.did,null,"\t").replaceAll('"', '')
@ -139,45 +203,35 @@ $(function() {
term.echo(JSON.stringify(data,null,"\t"));
});$.ajaxSetup({async: true});
});$.ajaxSetup({async: true});
} else if (inputs[0] === 'plc') {
term.echo(plc);
term.echo("$ plc <handle>");
} else if (inputs[0] === 'timeline' && inputs[1] != undefined) {
url = list + inputs[1] + '&collection=app.bsky.feed.post&limit=1';
} else if (command === 'ai' && option === 'record') {
if (inputs[2] != undefined) { did = inputs[2]; }
url = list + did + '&collection=app.bsky.feed.post&limit=1';
$.ajaxSetup({async: false});
$.getJSON(url, function(data) {
term.echo(JSON.stringify(data,null,"\t"));
});$.ajaxSetup({async: true});
} else if (inputs[0] === 'timeline') {
term.echo(timeline);
term.echo("$ timeline <handle>");
} else if (inputs[0] === 'did' && inputs[1] != undefined) {
url = desc + inputs[1] + '&collection=app.bsky.actor.profile';
} else if (command === 'ai' && option === 'did') {
if (inputs[2] != undefined) { handle = inputs[2]; }
url = desc + handle + '&collection=app.bsky.actor.profile';
$.ajaxSetup({async: false});
$.getJSON(url, function(data) {
term.echo(JSON.stringify(data.did,null,"\t"));
term.echo(JSON.stringify(data.did,null,"\t").replaceAll('"', ''));
});$.ajaxSetup({async: true});
} else if (inputs[0] === 'did') {
} else if (command === 'ai' && option === 'handle') {
if (inputs[2] != undefined) { did = inputs[2]; }
url = desc + did + '&collection=app.bsky.actor.profile';
$.ajaxSetup({async: false});
$.getJSON(url, function(data) {
term.echo(JSON.stringify(data.did,null,"\t"));
term.echo(JSON.stringify(data,null,"\t"));
});$.ajaxSetup({async: true});
term.echo("$ did <handle>");
} else if (inputs[0] === 'handle' && inputs[1] != undefined) {
url = desc + inputs[1] + '&collection=app.bsky.actor.profile';
} else if (command === 'ai' && option === 'v') {
url = 'https://bsky.social/xrpc/_health';
$.ajaxSetup({async: false});
$.getJSON(url, function(data) {
term.echo(JSON.stringify(data,null,"\t"));
});$.ajaxSetup({async: true});
} else if (inputs[0] === 'handle') {
term.echo(bsky_did);
term.echo("$ handle <handle>");
} else if (inputs[0] === 'bsky_ver') {
term.echo(bsky_ver);
} else {
term.error(command + " is not a valid command");
term.echo(command_all);
term.echo(ai_help);
}
}

View File

@ -1,7 +1,6 @@
{
"did": "did:plc:4hqjfn7m6n5hno3doamuhgef",
"handle": "yui.syui.ai",
"displayName": "ai",
"day":"01/23",
"size":"123cm"
"day": "01/23",
"size": "123cm"
}