Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- registerPlugin({
- name: "Teamspeak Clanverwaltung",
- version: "Alpha 0.1",
- description: "Clanverwaltung für The Force",
- author: "_maddiboy",
- requiredModules: ["backend", "engine", "http", "event", "audio", "media"],
- engines: ">= 1.0.0",
- vars:[
- {
- name: "apiKey",
- title: "API Key (get one at https://developers.wargaming.net)",
- type: "string",
- }, {
- name: "clanRegion",
- title: "The Region of the clan",
- type: "select",
- options: ["RU","EU","NA","ASIA"],
- },
- // CW Upcoming Battles
- {
- name: "cwCheck",
- title: "List of upcoming battles",
- type: "checkbox",
- }, {
- name: "cwClans",
- indent: 4,
- title: "Clan Tags for your cw clans",
- type: "strings",
- conditions: [{
- field: "cwCheck",
- value: true,
- },
- ],
- }, {
- name: "cwChannel",
- indent: 4,
- title: "Select Channel to display Info",
- type: "channel",
- conditions: [{
- field: "cwCheck",
- value: true,
- },
- ],
- }, {
- name: "cwTime",
- indent: 4,
- title: "Insert the update time in minutes",
- type: "string",
- conditions: [{
- field: "cwCheck",
- value: true,
- },
- ],
- }
- ]
- }, function(sinusbot, config) {
- //Vers for required Modules
- var backend = require("backend");
- var engine = require("engine");
- var http = require("http");
- //Config vars
- var regionArr = ["ru","eu","na","asia"];
- var key = "?application_id=" + config.apiKey;
- var apiUrl = "https://api.worldoftanks." + regionArr[config.clanRegion];
- //######################CW Battles######################
- /*var regionArr = ["ru","eu","na","asia"];
- var region = regionArr[config.clanRegion];
- var key = "?application_id=" + config.apiKey;cwTags
- var apiUrl = "https://api.worldoftanks." + region;*/
- var cwTime = [];
- var cwTier = [];
- var cwMap = [];
- var cwVs = [];
- var output;
- function cwClanData() {
- var clanId;
- config.cwClans.forEach(function (cwClans) {
- http.simpleRequest({
- method: "GET",
- timeout: 60000,
- url: apiUrl + "/wgn/clans/list/" + key + "&game=wot&language=en&limit=1&search=" + cwClans
- }, function (error, responseId) {
- //engine.log("Claninfos erhalten");
- var clanData = JSON.parse(responseId.data);
- clanId = clanData.data[0].clan_id;
- output += "[b]Clan:[/b] " + clanData.data[0].tag;
- cwBattles(clanId);
- engine.log("Claninfos verarbeitet " + clanId);
- });
- backend.getChannelByID(config.cwChannel).setDescription(output);
- });
- }
- function cwBattles(clanId) {
- http.simpleRequest({
- method: "GET",
- timeout: 60000,
- url: apiUrl + "/wot/globalmap/clanbattles/" + key + "&clan_id=" + clanId + "&language=en",
- },function (error, responseBattle) {
- //engine.log("Battles erhalten");
- var battleData = JSON.parse(responseBattle.data);
- output += " [b]Battle Count:[/b] " + battleData.meta.count;
- if(battleData.meta.count == 0) {
- cwMap = [];
- cwVs = [];
- engine.log("Battleinfos verarbeitet " + clanId);
- } else {
- for (i in battleData) {
- var timestamp = battleData.data[i].time;
- var date = new Date(timestamp * 1000);
- if (date.getMinutes() < 10) {
- minutes = "0" + date.getMinutes();
- } else {
- minutes = date.getMinutes();
- }
- var frontId = battleData.data[i].front_id;
- var provinceId = battleData.data[i].province_id;
- cwArena(frontId, provinceId, i);
- var competitorId = battleData.data[i].competitor_id;
- cwCompetitor(competitorId, i);
- }
- for (i in cwTime) {
- output += "\n"+cwTime[i] + cwTier[i] + cwMap[i] + cwVs[i] + "\n\n";
- }
- engine.log("Battleinfos verarbeitet");
- }
- }
- )
- }
- function cwArena(frontId, provinceId, i) {
- http.simpleRequest({
- method: "GET",
- timeout: 60000,
- url: apiUrl + "/wot/globalmap/provinces/" + key + "&front_id=" + frontId + "&province_id=" + provinceId + "&language=en&fields=arena_name"
- },function (error, responseProvince) {
- var provinceData = JSON.parse(responseProvince.data);
- var battleMap = provinceData.data[0].arena_name;
- cwMap[i] = " [b]Map:[/b] " + battleMap;
- engine.log("Arenainfos verarbeitet");
- return;
- });
- }
- function cwCompetitor(competitorId, i) {
- http.simpleRequest({
- method: "GET",
- timeout: 60000,
- url: apiUrl + "/wot/globalmap/claninfo/" + key + "&clan_id=" + competitorId
- },function (error, responseCompetitor) {
- var competitorData = JSON.parse(responseCompetitor.data);
- var competitorTag = competitor.data[competitorId].tag;
- cwVs[i] = " [b] vs:[/b] [url=https://wot-life.com/eu/clan/" + competitorTag + "-" + competitorId + "/]" + competitorTag + "[/url]";
- engine.log("Competitor verarbeitet");
- return;
- });
- }
- setInterval(function refreshCwList() {
- if (config.cwCheck == true) {
- output = "[b]Upcoming CW Battles:[/b]\n";
- cwTime = [];
- cwTier = [];
- cwClanData();
- }
- }, config.cwTime * 60000);
- //######################New Script######################
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement