1
0
This commit is contained in:
syui 2024-04-04 15:52:32 +09:00
parent eee3f30692
commit af71ef3527
Signed by: syui
GPG Key ID: 5417CFEBAD92DF56

View File

@ -2,9 +2,13 @@ $(function() {
var prompt = "[[b;#87cefa;]ai][[b;#FFFF00;]@aios] ~$ ";
let url = new URL(window.location.href);
let user = url.searchParams.get('user');
let id = url.searchParams.get('id');
if (id == null) { id = 2 };
let did = url.searchParams.get('did');
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","bsky"];
var command_all = ["ai","timeline", "bsky_ver", "handle", "did", "plc"];
var handle = "yui.syui.ai";
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';
@ -55,11 +59,29 @@ $(function() {
\n\
";
axios.get('https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=' + handle + '&collection=app.bsky.feed.post&limit=1')
let list = 'https://bsky.social/xrpc/com.atproto.repo.listRecords?repo=';
axios.get(list + handle + '&collection=app.bsky.feed.post&limit=1')
.then(function (response) {
timeline = JSON.stringify(response.data.records[0].value,null,"\t");
})
axios.get('https://bsky.social/xrpc/_health')
.then(function (response) {
bsky_ver = JSON.stringify(response.data,null,"\t");
})
let plc_server = "https://plc.directory/"
axios.get(plc_server + did + '/log')
.then(function (response) {
plc = JSON.stringify(response.data,null,"\t");
})
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");
})
axios.get('/json/ai.json')
.then(function (response) {
user_profile = JSON.stringify(response.data,null,"\t");
@ -102,8 +124,54 @@ $(function() {
if (inputs[0] === 'ai') {
print_slowly(term, ascii_logo);
term.echo(user_profile);
} else if (inputs[0] === 'bsky') {
print_slowly(term, timeline);
} else if (inputs[0] === 'plc' && inputs[1] != undefined) {
url = desc + inputs[1] + '&collection=app.bsky.actor.profile';
$.ajaxSetup({async: false});
$.getJSON(url, function(data) {
did = JSON.stringify(data.did,null,"\t").replaceAll('"', '')
url = plc_server + did + '/log';
$.ajaxSetup({async: false});
$.getJSON(url, function(data) {
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';
$.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';
$.ajaxSetup({async: false});
$.getJSON(url, function(data) {
term.echo(JSON.stringify(data.did,null,"\t"));
});$.ajaxSetup({async: true});
} else if (inputs[0] === 'did') {
url = desc + did + '&collection=app.bsky.actor.profile';
$.ajaxSetup({async: false});
$.getJSON(url, function(data) {
term.echo(JSON.stringify(data.did,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';
$.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);