mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-22 07:51:17 +01:00
Username support
This commit is contained in:
parent
d4cb8e9aef
commit
f95ce50abc
@ -1,4 +1,4 @@
|
|||||||
# Crafatar [](https://travis-ci.org/Jake0oo0/Spongy/)
|
# Crafatar [](https://travis-ci.org/Jake0oo0/Crafatar/)
|
||||||
|
|
||||||
https://crafatar.com
|
https://crafatar.com
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ var cache = require('./cache');
|
|||||||
var skins = require('./skins');
|
var skins = require('./skins');
|
||||||
|
|
||||||
var valid_uuid = /^[0-9a-f]{32}$/;
|
var valid_uuid = /^[0-9a-f]{32}$/;
|
||||||
var hash_pattern = /[0-9a-f]+$/;
|
var hash_pattern = /[A-za-z0-9_-]{1,16}$|((?:[A-za-z][A-za-z]*[0-9]+[A-za-z0-9]*))/;
|
||||||
|
|
||||||
function get_hash(url) {
|
function get_hash(url) {
|
||||||
return hash_pattern.exec(url)[0].toLowerCase();
|
return hash_pattern.exec(url)[0].toLowerCase();
|
||||||
@ -22,7 +22,15 @@ function store_images(uuid, details, callback) {
|
|||||||
} else if (err) {
|
} else if (err) {
|
||||||
callback(err, null);
|
callback(err, null);
|
||||||
} else {
|
} else {
|
||||||
var skinurl = skin_url(profile);
|
var skinurl = null;
|
||||||
|
|
||||||
|
// Username handling
|
||||||
|
if (uuid.length <= 16) {
|
||||||
|
skinurl = "https://skins.minecraft.net/MinecraftSkins/" + uuid + ".png"
|
||||||
|
console.log('is username')
|
||||||
|
} else {
|
||||||
|
skinurl = skin_url(profile);
|
||||||
|
}
|
||||||
if (skinurl) {
|
if (skinurl) {
|
||||||
console.log(uuid + " " + skinurl);
|
console.log(uuid + " " + skinurl);
|
||||||
// set file paths
|
// set file paths
|
||||||
@ -107,7 +115,11 @@ var exp = {};
|
|||||||
// returns true if the +uuid+ is a valid uuid
|
// returns true if the +uuid+ is a valid uuid
|
||||||
// the uuid may be not exist, however
|
// the uuid may be not exist, however
|
||||||
exp.uuid_valid = function(uuid) {
|
exp.uuid_valid = function(uuid) {
|
||||||
return valid_uuid.test(uuid);
|
var valid = valid_uuid.test(uuid);
|
||||||
|
if (!valid && uuid.length <= 16) {
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
return valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
// handles requests for +uuid+ images with +size+
|
// handles requests for +uuid+ images with +size+
|
||||||
@ -133,7 +145,6 @@ exp.get_avatar = function(uuid, helm, size, callback) {
|
|||||||
callback(err, status, null);
|
callback(err, status, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = exp;
|
module.exports = exp;
|
||||||
@ -9,6 +9,10 @@ var exp = {};
|
|||||||
// download the Mojang profile for +uuid+
|
// download the Mojang profile for +uuid+
|
||||||
// callback contains error, profile object
|
// callback contains error, profile object
|
||||||
exp.get_profile = function(uuid, callback) {
|
exp.get_profile = function(uuid, callback) {
|
||||||
|
if (uuid.length <= 16) {
|
||||||
|
callback(null, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
request.get({
|
request.get({
|
||||||
url: session_url + uuid,
|
url: session_url + uuid,
|
||||||
timeout: config.http_timeout // ms
|
timeout: config.http_timeout // ms
|
||||||
|
|||||||
@ -2,6 +2,7 @@ var helpers = require('../modules/helpers');
|
|||||||
var router = require('express').Router();
|
var router = require('express').Router();
|
||||||
var config = require('../modules/config');
|
var config = require('../modules/config');
|
||||||
var skins = require('../modules/skins');
|
var skins = require('../modules/skins');
|
||||||
|
var networking = require('../modules/networking')
|
||||||
|
|
||||||
/* GET avatar request. */
|
/* GET avatar request. */
|
||||||
router.get('/:uuid.:ext?', function(req, res) {
|
router.get('/:uuid.:ext?', function(req, res) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user