#WYSYŁANIE POWIADOMIENIA NA DISCORD
(function(_n, data, ut) {
//pobranie localStorage
let dane = {};
if (localStorage.getItem("adiherosybrutus")) {
dane = JSON.parse(localStorage.getItem("adiherosybrutus"));
}
if (dane) {
for (let i in dane) {
if (ut() > dane[i].time) {
delete dane[i];
}
}
}
//getTime
function getTime() {
let czas = new Date(),
godzina = czas.getHours(),
sekunda = czas.getSeconds(),
minuta = czas.getMinutes();
if (godzina < 10) godzina = `0${godzina}`;
if (minuta < 10) minuta = `0${minuta}`;
if (sekunda < 10) sekunda = `0${sekunda}`;
return `${godzina}:${minuta}:${sekunda}`;
}
//funkcja wysyłania na diskordzika
function sendToDiscord(lvl, nick, icon, x, y) {
$.ajax({
url: data[0],
type: 'POST',
data: JSON.stringify({
'embeds': [{
'title': `${hero.nick} ¡ ${hero.lvl}${hero.prof} znalazł herosa/tytana!`,
'color': ((Math.floor(lvl / 300 * 221) + 32) * 256 + (Math.floor(lvl / 300 * (-112)) + 120)) * 256 + Math.floor(lvl / 300 * (-204)) + 217,
'description': `${nick} (${lvl}lvl)\n${map.name} (${x}, ${y})\n${getTime()}\n${g.worldname[0].toUpperCase() + g.worldname.substring(1)}`,
'thumbnail': {
'url': `http://classic.margonem.pl${icon}`
}
}],
content: `@here Znaleźli mnie na mapie ${map.name}`,
username: nick,
avatar_url: `http://classic.margonem.pl${icon}`
}),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
async: false
});
}
//funkcja sprawdzajaca czy dane id z ts istnieje
function checkHerosData(id) {
if (dane[id]) {
if (ut() > dane[id].time) {
delete dane[id];
return true;
} else {
return false;
}
}
return true;
}
newNpc = function(e) {
_n.apply(this, arguments);
for (let i in e) {
let heros = e[i];
if (map.mode != 5 && heros.wt > 79 && g.worldname != "experimental" && checkHerosData(heros.id)) {
dane[heros.id] = {
time: ut() + (10 * 60)
}
localStorage.setItem("adiherosybrutus", JSON.stringify(dane));
sendToDiscord(heros.lvl, heros.nick, heros.icon, heros.x, heros.y);
break;
}
}
}
})(newNpc, ["https://discordapp.com/api/webhooks/636640361997008907/P8bUPy6AXyHysA9MG-NBKbFLWfv5lj3iMNYIFvP2dwfWQk2jfpFj29lsVr4svlhjdk-X"], unix_time)
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}