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 (did == null) { did = "did:plc:4hqjfn7m6n5hno3doamuhgef" };
if (user) { prompt = "[[b;#87cefa;]" + user + "][[b;#FFFF00;]@aios] ~$ " }; if (user) { prompt = "[[b;#87cefa;]" + user + "][[b;#FFFF00;]@aios] ~$ " };
var tab = "[[b;#87cefa;]<tab>]"; 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 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_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\ var ascii_ai = "\n\
@ -60,27 +83,52 @@ $(function() {
"; ";
let list = 'https://bsky.social/xrpc/com.atproto.repo.listRecords?repo='; let list = 'https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=';
axios.get(list + did + '&collection=app.bsky.feed.post&limit=1') function bsky_record() {
.then(function (response) { var u;
timeline = JSON.stringify(response.data.records[0].value,null,"\t"); 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') function bsky_ver() {
.then(function (response) { var u;
bsky_ver = JSON.stringify(response.data,null,"\t"); 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/" let plc_server = "https://plc.directory/"
axios.get(plc_server + did + '/log') function bsky_plc() {
.then(function (response) { var u;
plc = JSON.stringify(response.data,null,"\t"); 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='; let desc = 'https://bsky.social/xrpc/com.atproto.repo.describeRepo?repo=';
axios.get(desc + did + '&collection=app.bsky.actor.profile') function bsky_desc() {
.then(function (response) { var u;
bsky_did = JSON.stringify(response.data,null,"\t"); 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() { function test_json() {
var u; var u;
@ -125,11 +173,27 @@ $(function() {
var command, inputs; var command, inputs;
inputs = input.split(/ +/) inputs = input.split(/ +/)
command = inputs[0]; 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); print_slowly(term, ascii_logo);
} else if (command === 'ai' && option === 'p') {
term.echo(ascii_ai);
term.echo(test_json()); term.echo(test_json());
} else if (inputs[0] === 'plc' && inputs[1] != undefined) { } else if (command === 'ai' && option === 'plc') {
url = desc + inputs[1] + '&collection=app.bsky.actor.profile'; if (inputs[2] != undefined) { did = inputs[2]; }
url = desc + did + '&collection=app.bsky.actor.profile';
$.ajaxSetup({async: false}); $.ajaxSetup({async: false});
$.getJSON(url, function(data) { $.getJSON(url, function(data) {
did = JSON.stringify(data.did,null,"\t").replaceAll('"', '') did = JSON.stringify(data.did,null,"\t").replaceAll('"', '')
@ -139,45 +203,35 @@ $(function() {
term.echo(JSON.stringify(data,null,"\t")); term.echo(JSON.stringify(data,null,"\t"));
});$.ajaxSetup({async: true}); });$.ajaxSetup({async: true});
});$.ajaxSetup({async: true}); });$.ajaxSetup({async: true});
} else if (inputs[0] === 'plc') { } else if (command === 'ai' && option === 'record') {
term.echo(plc); if (inputs[2] != undefined) { did = inputs[2]; }
term.echo("$ plc <handle>"); url = list + did + '&collection=app.bsky.feed.post&limit=1';
} else if (inputs[0] === 'timeline' && inputs[1] != undefined) {
url = list + inputs[1] + '&collection=app.bsky.feed.post&limit=1';
$.ajaxSetup({async: false}); $.ajaxSetup({async: false});
$.getJSON(url, function(data) { $.getJSON(url, function(data) {
term.echo(JSON.stringify(data,null,"\t")); term.echo(JSON.stringify(data,null,"\t"));
});$.ajaxSetup({async: true}); });$.ajaxSetup({async: true});
} else if (inputs[0] === 'timeline') { } else if (command === 'ai' && option === 'did') {
term.echo(timeline); if (inputs[2] != undefined) { handle = inputs[2]; }
term.echo("$ timeline <handle>"); url = desc + handle + '&collection=app.bsky.actor.profile';
} else if (inputs[0] === 'did' && inputs[1] != undefined) {
url = desc + inputs[1] + '&collection=app.bsky.actor.profile';
$.ajaxSetup({async: false}); $.ajaxSetup({async: false});
$.getJSON(url, function(data) { $.getJSON(url, function(data) {
term.echo(JSON.stringify(data.did,null,"\t")); term.echo(JSON.stringify(data.did,null,"\t").replaceAll('"', ''));
});$.ajaxSetup({async: true}); });$.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'; url = desc + did + '&collection=app.bsky.actor.profile';
$.ajaxSetup({async: false}); $.ajaxSetup({async: false});
$.getJSON(url, function(data) { $.getJSON(url, function(data) {
term.echo(JSON.stringify(data.did,null,"\t")); term.echo(JSON.stringify(data,null,"\t"));
});$.ajaxSetup({async: true}); });$.ajaxSetup({async: true});
term.echo("$ did <handle>"); } else if (command === 'ai' && option === 'v') {
} else if (inputs[0] === 'handle' && inputs[1] != undefined) { url = 'https://bsky.social/xrpc/_health';
url = desc + inputs[1] + '&collection=app.bsky.actor.profile';
$.ajaxSetup({async: false}); $.ajaxSetup({async: false});
$.getJSON(url, function(data) { $.getJSON(url, function(data) {
term.echo(JSON.stringify(data,null,"\t")); term.echo(JSON.stringify(data,null,"\t"));
});$.ajaxSetup({async: true}); });$.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 { } else {
term.error(command + " is not a valid command"); term.echo(ai_help);
term.echo(command_all);
} }
} }

View File

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