chris1992
Active Member
Hi ich bin ganz neu in sachen javascript nun mal ein erster versuch von mir und er ist bestimmt falsch aber wenn ihr den sinn darin versteht und dann eventuell mir alle fehler sagen könnt wäre ich super glücklich und ein bischen weiter im verständnis vom scripten.
registerPlugin({
name: 'HotSlogs',
version: '0.1',
description: '',
author: '',
engines: '>= 0.9.16',
vars: [
]
//Require module variables
var event = require('event');
var engine = require('engine');
var backend = require('backend');
var nickname = ev.client.name();
var nicknameform = nickname.replace(/#/g , "_");
var battletag = nicknameform.split(" ");
var btag = battletag[0];
var httplogs = {
method: "GET",
headers: "Content-type: application/json",
timeout: 30,
url: "https://api.hotslogs.com/Public/Players/2/" + btag
sinusbot.http(httplogs, function (error, response)) {
if (response.statusCode !== 200) {
console.log("Could not retrieve info for " + ip + " HTTP_ERROR: " + error);
return false;
}
else {
var hlrank = httplogs.LeaderboardRankings[1].LeagueRank;
var tlrank = httplogs.LeaderboardRankings[2].LeagueRank;
if (hlrank != "null" || tlrank != "null") {
if (hlrank >= tlrank){
engine.log(nickname + "Heroleague rank ist " + hlrank);
}
else {
engine.log(nickname + "Teamleague rank ist " + tlrank);
}
}
}
}
}});
registerPlugin({
name: 'HotSlogs',
version: '0.1',
description: '',
author: '',
engines: '>= 0.9.16',
vars: [
]
//Require module variables
var event = require('event');
var engine = require('engine');
var backend = require('backend');
var nickname = ev.client.name();
var nicknameform = nickname.replace(/#/g , "_");
var battletag = nicknameform.split(" ");
var btag = battletag[0];
var httplogs = {
method: "GET",
headers: "Content-type: application/json",
timeout: 30,
url: "https://api.hotslogs.com/Public/Players/2/" + btag
sinusbot.http(httplogs, function (error, response)) {
if (response.statusCode !== 200) {
console.log("Could not retrieve info for " + ip + " HTTP_ERROR: " + error);
return false;
}
else {
var hlrank = httplogs.LeaderboardRankings[1].LeagueRank;
var tlrank = httplogs.LeaderboardRankings[2].LeagueRank;
if (hlrank != "null" || tlrank != "null") {
if (hlrank >= tlrank){
engine.log(nickname + "Heroleague rank ist " + hlrank);
}
else {
engine.log(nickname + "Teamleague rank ist " + tlrank);
}
}
}
}
}});