Fixed .lolban, closes #1340

This commit is contained in:
Master Kwoth 2017-07-10 19:40:34 +02:00
parent f396fc78db
commit 5db254e8f3
2 changed files with 830 additions and 4 deletions

View File

@ -2,9 +2,11 @@
using NadekoBot.Attributes; using NadekoBot.Attributes;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using NadekoBot.Services; using NadekoBot.Services;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -29,24 +31,30 @@ namespace NadekoBot.Modules.Searches
"If you consider playing teemo, do it. If you consider teemo, you deserve him.", "If you consider playing teemo, do it. If you consider teemo, you deserve him.",
"Doesn't matter what you ban really. Enemy will ban your main and you will lose." }; "Doesn't matter what you ban really. Enemy will ban your main and you will lose." };
private static readonly Lazy<Dictionary<int, string>> champData = new Lazy<Dictionary<int, string>>(() =>
((IDictionary<string, JToken>)JObject.Parse(File.ReadAllText("data/lolchamps.json")))
.ToDictionary(x => (int)x.Value["id"], x => x.Value["name"].ToString()), true);
[NadekoCommand, Usage, Description, Aliases] [NadekoCommand, Usage, Description, Aliases]
public async Task Lolban() public async Task Lolban()
{ {
//const int showCount = 8; //const int showCount = 8;
//http://api.champion.gg/stats/champs/mostBanned?api_key=YOUR_API_TOKEN&page=1&limit=2
try try
{ {
using (var http = new HttpClient()) using (var http = new HttpClient())
{ {
var data = JArray.Parse(await http.GetStringAsync($"http://api.champion.gg/v2/champions?champData=normalized&limit=200&api_key={_creds.LoLApiKey}")); var data = JArray.Parse(await http.GetStringAsync($"http://api.champion.gg/v2/champions?champData=general&limit=200&api_key={_creds.LoLApiKey}"));
var champs = data.OrderByDescending(x => (float)x["banRate"])/*.Distinct(x => x["championId"])*/.Take(6); var champs = data.OrderByDescending(x => (double)x["banRate"]).Distinct(x => x["championId"]).Take(6);
//_log.Info(string.Join("\n", champs.Select(x => x["championId"] + " | " + x["banRate"] + " | " + x["normalized"]["banRate"])));
var eb = new EmbedBuilder().WithOkColor().WithTitle(Format.Underline(GetText("x_most_banned_champs", champs.Count()))); var eb = new EmbedBuilder().WithOkColor().WithTitle(Format.Underline(GetText("x_most_banned_champs", champs.Count())));
foreach (var champ in champs) foreach (var champ in champs)
{ {
var lChamp = champ; var lChamp = champ;
eb.AddField(efb => efb.WithName(lChamp["championId"].ToString()).WithValue((float)lChamp["banRate"] * 100 + "%").WithIsInline(true)); if (!champData.Value.TryGetValue((int)champ["championId"], out var champName))
champName = "UNKNOWN";
eb.AddField(efb => efb.WithName(champName).WithValue(((double)lChamp["banRate"] * 100).ToString("F2") + "%").WithIsInline(true));
} }
await Context.Channel.EmbedAsync(eb, Format.Italics(trashTalk[new NadekoRandom().Next(0, trashTalk.Length)])).ConfigureAwait(false); await Context.Channel.EmbedAsync(eb, Format.Italics(trashTalk[new NadekoRandom().Next(0, trashTalk.Length)])).ConfigureAwait(false);

View File

@ -0,0 +1,818 @@
{
"Aatrox": {
"id": 266,
"key": "Aatrox",
"name": "Aatrox",
"title": "the Darkin Blade"
},
"Ahri": {
"id": 103,
"key": "Ahri",
"name": "Ahri",
"title": "the Nine-Tailed Fox"
},
"Akali": {
"id": 84,
"key": "Akali",
"name": "Akali",
"title": "the Fist of Shadow"
},
"Alistar": {
"id": 12,
"key": "Alistar",
"name": "Alistar",
"title": "the Minotaur"
},
"Amumu": {
"id": 32,
"key": "Amumu",
"name": "Amumu",
"title": "the Sad Mummy"
},
"Anivia": {
"id": 34,
"key": "Anivia",
"name": "Anivia",
"title": "the Cryophoenix"
},
"Annie": {
"id": 1,
"key": "Annie",
"name": "Annie",
"title": "the Dark Child"
},
"Ashe": {
"id": 22,
"key": "Ashe",
"name": "Ashe",
"title": "the Frost Archer"
},
"AurelionSol": {
"id": 136,
"key": "AurelionSol",
"name": "Aurelion Sol",
"title": "The Star Forger"
},
"Azir": {
"id": 268,
"key": "Azir",
"name": "Azir",
"title": "the Emperor of the Sands"
},
"Bard": {
"id": 432,
"key": "Bard",
"name": "Bard",
"title": "the Wandering Caretaker"
},
"Blitzcrank": {
"id": 53,
"key": "Blitzcrank",
"name": "Blitzcrank",
"title": "the Great Steam Golem"
},
"Brand": {
"id": 63,
"key": "Brand",
"name": "Brand",
"title": "the Burning Vengeance"
},
"Braum": {
"id": 201,
"key": "Braum",
"name": "Braum",
"title": "the Heart of the Freljord"
},
"Caitlyn": {
"id": 51,
"key": "Caitlyn",
"name": "Caitlyn",
"title": "the Sheriff of Piltover"
},
"Camille": {
"id": 164,
"key": "Camille",
"name": "Camille",
"title": "the Steel Shadow"
},
"Cassiopeia": {
"id": 69,
"key": "Cassiopeia",
"name": "Cassiopeia",
"title": "the Serpent's Embrace"
},
"Chogath": {
"id": 31,
"key": "Chogath",
"name": "Cho'Gath",
"title": "the Terror of the Void"
},
"Corki": {
"id": 42,
"key": "Corki",
"name": "Corki",
"title": "the Daring Bombardier"
},
"Darius": {
"id": 122,
"key": "Darius",
"name": "Darius",
"title": "the Hand of Noxus"
},
"Diana": {
"id": 131,
"key": "Diana",
"name": "Diana",
"title": "Scorn of the Moon"
},
"Draven": {
"id": 119,
"key": "Draven",
"name": "Draven",
"title": "the Glorious Executioner"
},
"DrMundo": {
"id": 36,
"key": "DrMundo",
"name": "Dr. Mundo",
"title": "the Madman of Zaun"
},
"Ekko": {
"id": 245,
"key": "Ekko",
"name": "Ekko",
"title": "the Boy Who Shattered Time"
},
"Elise": {
"id": 60,
"key": "Elise",
"name": "Elise",
"title": "the Spider Queen"
},
"Evelynn": {
"id": 28,
"key": "Evelynn",
"name": "Evelynn",
"title": "the Widowmaker"
},
"Ezreal": {
"id": 81,
"key": "Ezreal",
"name": "Ezreal",
"title": "the Prodigal Explorer"
},
"Fiddlesticks": {
"id": 9,
"key": "Fiddlesticks",
"name": "Fiddlesticks",
"title": "the Harbinger of Doom"
},
"Fiora": {
"id": 114,
"key": "Fiora",
"name": "Fiora",
"title": "the Grand Duelist"
},
"Fizz": {
"id": 105,
"key": "Fizz",
"name": "Fizz",
"title": "the Tidal Trickster"
},
"Galio": {
"id": 3,
"key": "Galio",
"name": "Galio",
"title": "the Colossus"
},
"Gangplank": {
"id": 41,
"key": "Gangplank",
"name": "Gangplank",
"title": "the Saltwater Scourge"
},
"Garen": {
"id": 86,
"key": "Garen",
"name": "Garen",
"title": "The Might of Demacia"
},
"Gnar": {
"id": 150,
"key": "Gnar",
"name": "Gnar",
"title": "the Missing Link"
},
"Gragas": {
"id": 79,
"key": "Gragas",
"name": "Gragas",
"title": "the Rabble Rouser"
},
"Graves": {
"id": 104,
"key": "Graves",
"name": "Graves",
"title": "the Outlaw"
},
"Hecarim": {
"id": 120,
"key": "Hecarim",
"name": "Hecarim",
"title": "the Shadow of War"
},
"Heimerdinger": {
"id": 74,
"key": "Heimerdinger",
"name": "Heimerdinger",
"title": "the Revered Inventor"
},
"Illaoi": {
"id": 420,
"key": "Illaoi",
"name": "Illaoi",
"title": "the Kraken Priestess"
},
"Irelia": {
"id": 39,
"key": "Irelia",
"name": "Irelia",
"title": "the Will of the Blades"
},
"Ivern": {
"id": 427,
"key": "Ivern",
"name": "Ivern",
"title": "the Green Father"
},
"Janna": {
"id": 40,
"key": "Janna",
"name": "Janna",
"title": "the Storm's Fury"
},
"JarvanIV": {
"id": 59,
"key": "JarvanIV",
"name": "Jarvan IV",
"title": "the Exemplar of Demacia"
},
"Jax": {
"id": 24,
"key": "Jax",
"name": "Jax",
"title": "Grandmaster at Arms"
},
"Jayce": {
"id": 126,
"key": "Jayce",
"name": "Jayce",
"title": "the Defender of Tomorrow"
},
"Jhin": {
"id": 202,
"key": "Jhin",
"name": "Jhin",
"title": "the Virtuoso"
},
"Jinx": {
"id": 222,
"key": "Jinx",
"name": "Jinx",
"title": "the Loose Cannon"
},
"Kalista": {
"id": 429,
"key": "Kalista",
"name": "Kalista",
"title": "the Spear of Vengeance"
},
"Karma": {
"id": 43,
"key": "Karma",
"name": "Karma",
"title": "the Enlightened One"
},
"Karthus": {
"id": 30,
"key": "Karthus",
"name": "Karthus",
"title": "the Deathsinger"
},
"Kassadin": {
"id": 38,
"key": "Kassadin",
"name": "Kassadin",
"title": "the Void Walker"
},
"Katarina": {
"id": 55,
"key": "Katarina",
"name": "Katarina",
"title": "the Sinister Blade"
},
"Kayle": {
"id": 10,
"key": "Kayle",
"name": "Kayle",
"title": "The Judicator"
},
"Kennen": {
"id": 85,
"key": "Kennen",
"name": "Kennen",
"title": "the Heart of the Tempest"
},
"Khazix": {
"id": 121,
"key": "Khazix",
"name": "Kha'Zix",
"title": "the Voidreaver"
},
"Kindred": {
"id": 203,
"key": "Kindred",
"name": "Kindred",
"title": "The Eternal Hunters"
},
"Kled": {
"id": 240,
"key": "Kled",
"name": "Kled",
"title": "the Cantankerous Cavalier"
},
"KogMaw": {
"id": 96,
"key": "KogMaw",
"name": "Kog'Maw",
"title": "the Mouth of the Abyss"
},
"Leblanc": {
"id": 7,
"key": "Leblanc",
"name": "LeBlanc",
"title": "the Deceiver"
},
"LeeSin": {
"id": 64,
"key": "LeeSin",
"name": "Lee Sin",
"title": "the Blind Monk"
},
"Leona": {
"id": 89,
"key": "Leona",
"name": "Leona",
"title": "the Radiant Dawn"
},
"Lissandra": {
"id": 127,
"key": "Lissandra",
"name": "Lissandra",
"title": "the Ice Witch"
},
"Lucian": {
"id": 236,
"key": "Lucian",
"name": "Lucian",
"title": "the Purifier"
},
"Lulu": {
"id": 117,
"key": "Lulu",
"name": "Lulu",
"title": "the Fae Sorceress"
},
"Lux": {
"id": 99,
"key": "Lux",
"name": "Lux",
"title": "the Lady of Luminosity"
},
"Malphite": {
"id": 54,
"key": "Malphite",
"name": "Malphite",
"title": "Shard of the Monolith"
},
"Malzahar": {
"id": 90,
"key": "Malzahar",
"name": "Malzahar",
"title": "the Prophet of the Void"
},
"Maokai": {
"id": 57,
"key": "Maokai",
"name": "Maokai",
"title": "the Twisted Treant"
},
"MasterYi": {
"id": 11,
"key": "MasterYi",
"name": "Master Yi",
"title": "the Wuju Bladesman"
},
"MissFortune": {
"id": 21,
"key": "MissFortune",
"name": "Miss Fortune",
"title": "the Bounty Hunter"
},
"MonkeyKing": {
"id": 62,
"key": "MonkeyKing",
"name": "Wukong",
"title": "the Monkey King"
},
"Mordekaiser": {
"id": 82,
"key": "Mordekaiser",
"name": "Mordekaiser",
"title": "the Iron Revenant"
},
"Morgana": {
"id": 25,
"key": "Morgana",
"name": "Morgana",
"title": "Fallen Angel"
},
"Nami": {
"id": 267,
"key": "Nami",
"name": "Nami",
"title": "the Tidecaller"
},
"Nasus": {
"id": 75,
"key": "Nasus",
"name": "Nasus",
"title": "the Curator of the Sands"
},
"Nautilus": {
"id": 111,
"key": "Nautilus",
"name": "Nautilus",
"title": "the Titan of the Depths"
},
"Nidalee": {
"id": 76,
"key": "Nidalee",
"name": "Nidalee",
"title": "the Bestial Huntress"
},
"Nocturne": {
"id": 56,
"key": "Nocturne",
"name": "Nocturne",
"title": "the Eternal Nightmare"
},
"Nunu": {
"id": 20,
"key": "Nunu",
"name": "Nunu",
"title": "the Yeti Rider"
},
"Olaf": {
"id": 2,
"key": "Olaf",
"name": "Olaf",
"title": "the Berserker"
},
"Orianna": {
"id": 61,
"key": "Orianna",
"name": "Orianna",
"title": "the Lady of Clockwork"
},
"Pantheon": {
"id": 80,
"key": "Pantheon",
"name": "Pantheon",
"title": "the Artisan of War"
},
"Poppy": {
"id": 78,
"key": "Poppy",
"name": "Poppy",
"title": "Keeper of the Hammer"
},
"Quinn": {
"id": 133,
"key": "Quinn",
"name": "Quinn",
"title": "Demacia's Wings"
},
"Rakan": {
"id": 497,
"key": "Rakan",
"name": "Rakan",
"title": "The Charmer"
},
"Rammus": {
"id": 33,
"key": "Rammus",
"name": "Rammus",
"title": "the Armordillo"
},
"RekSai": {
"id": 421,
"key": "RekSai",
"name": "Rek'Sai",
"title": "the Void Burrower"
},
"Renekton": {
"id": 58,
"key": "Renekton",
"name": "Renekton",
"title": "the Butcher of the Sands"
},
"Rengar": {
"id": 107,
"key": "Rengar",
"name": "Rengar",
"title": "the Pridestalker"
},
"Riven": {
"id": 92,
"key": "Riven",
"name": "Riven",
"title": "the Exile"
},
"Rumble": {
"id": 68,
"key": "Rumble",
"name": "Rumble",
"title": "the Mechanized Menace"
},
"Ryze": {
"id": 13,
"key": "Ryze",
"name": "Ryze",
"title": "the Rune Mage"
},
"Sejuani": {
"id": 113,
"key": "Sejuani",
"name": "Sejuani",
"title": "Fury of the North"
},
"Shaco": {
"id": 35,
"key": "Shaco",
"name": "Shaco",
"title": "the Demon Jester"
},
"Shen": {
"id": 98,
"key": "Shen",
"name": "Shen",
"title": "the Eye of Twilight"
},
"Shyvana": {
"id": 102,
"key": "Shyvana",
"name": "Shyvana",
"title": "the Half-Dragon"
},
"Singed": {
"id": 27,
"key": "Singed",
"name": "Singed",
"title": "the Mad Chemist"
},
"Sion": {
"id": 14,
"key": "Sion",
"name": "Sion",
"title": "The Undead Juggernaut"
},
"Sivir": {
"id": 15,
"key": "Sivir",
"name": "Sivir",
"title": "the Battle Mistress"
},
"Skarner": {
"id": 72,
"key": "Skarner",
"name": "Skarner",
"title": "the Crystal Vanguard"
},
"Sona": {
"id": 37,
"key": "Sona",
"name": "Sona",
"title": "Maven of the Strings"
},
"Soraka": {
"id": 16,
"key": "Soraka",
"name": "Soraka",
"title": "the Starchild"
},
"Swain": {
"id": 50,
"key": "Swain",
"name": "Swain",
"title": "the Master Tactician"
},
"Syndra": {
"id": 134,
"key": "Syndra",
"name": "Syndra",
"title": "the Dark Sovereign"
},
"TahmKench": {
"id": 223,
"key": "TahmKench",
"name": "Tahm Kench",
"title": "the River King"
},
"Taliyah": {
"id": 163,
"key": "Taliyah",
"name": "Taliyah",
"title": "the Stoneweaver"
},
"Talon": {
"id": 91,
"key": "Talon",
"name": "Talon",
"title": "the Blade's Shadow"
},
"Taric": {
"id": 44,
"key": "Taric",
"name": "Taric",
"title": "the Shield of Valoran"
},
"Teemo": {
"id": 17,
"key": "Teemo",
"name": "Teemo",
"title": "the Swift Scout"
},
"Thresh": {
"id": 412,
"key": "Thresh",
"name": "Thresh",
"title": "the Chain Warden"
},
"Tristana": {
"id": 18,
"key": "Tristana",
"name": "Tristana",
"title": "the Yordle Gunner"
},
"Trundle": {
"id": 48,
"key": "Trundle",
"name": "Trundle",
"title": "the Troll King"
},
"Tryndamere": {
"id": 23,
"key": "Tryndamere",
"name": "Tryndamere",
"title": "the Barbarian King"
},
"TwistedFate": {
"id": 4,
"key": "TwistedFate",
"name": "Twisted Fate",
"title": "the Card Master"
},
"Twitch": {
"id": 29,
"key": "Twitch",
"name": "Twitch",
"title": "the Plague Rat"
},
"Udyr": {
"id": 77,
"key": "Udyr",
"name": "Udyr",
"title": "the Spirit Walker"
},
"Urgot": {
"id": 6,
"key": "Urgot",
"name": "Urgot",
"title": "the Headsman's Pride"
},
"Varus": {
"id": 110,
"key": "Varus",
"name": "Varus",
"title": "the Arrow of Retribution"
},
"Vayne": {
"id": 67,
"key": "Vayne",
"name": "Vayne",
"title": "the Night Hunter"
},
"Veigar": {
"id": 45,
"key": "Veigar",
"name": "Veigar",
"title": "the Tiny Master of Evil"
},
"Velkoz": {
"id": 161,
"key": "Velkoz",
"name": "Vel'Koz",
"title": "the Eye of the Void"
},
"Vi": {
"id": 254,
"key": "Vi",
"name": "Vi",
"title": "the Piltover Enforcer"
},
"Viktor": {
"id": 112,
"key": "Viktor",
"name": "Viktor",
"title": "the Machine Herald"
},
"Vladimir": {
"id": 8,
"key": "Vladimir",
"name": "Vladimir",
"title": "the Crimson Reaper"
},
"Volibear": {
"id": 106,
"key": "Volibear",
"name": "Volibear",
"title": "the Thunder's Roar"
},
"Warwick": {
"id": 19,
"key": "Warwick",
"name": "Warwick",
"title": "the Uncaged Wrath of Zaun"
},
"Xayah": {
"id": 498,
"key": "Xayah",
"name": "Xayah",
"title": "the Rebel"
},
"Xerath": {
"id": 101,
"key": "Xerath",
"name": "Xerath",
"title": "the Magus Ascendant"
},
"XinZhao": {
"id": 5,
"key": "XinZhao",
"name": "Xin Zhao",
"title": "the Seneschal of Demacia"
},
"Yasuo": {
"id": 157,
"key": "Yasuo",
"name": "Yasuo",
"title": "the Unforgiven"
},
"Yorick": {
"id": 83,
"key": "Yorick",
"name": "Yorick",
"title": "Shepherd of Souls"
},
"Zac": {
"id": 154,
"key": "Zac",
"name": "Zac",
"title": "the Secret Weapon"
},
"Zed": {
"id": 238,
"key": "Zed",
"name": "Zed",
"title": "the Master of Shadows"
},
"Ziggs": {
"id": 115,
"key": "Ziggs",
"name": "Ziggs",
"title": "the Hexplosives Expert"
},
"Zilean": {
"id": 26,
"key": "Zilean",
"name": "Zilean",
"title": "the Chronokeeper"
},
"Zyra": {
"id": 143,
"key": "Zyra",
"name": "Zyra",
"title": "Rise of the Thorns"
}
}