diff --git a/NadekoBot/Classes/Permissions/PermissionChecker.cs b/NadekoBot/Classes/Permissions/PermissionChecker.cs index 628b0c7b..19b32ee8 100644 --- a/NadekoBot/Classes/Permissions/PermissionChecker.cs +++ b/NadekoBot/Classes/Permissions/PermissionChecker.cs @@ -32,10 +32,10 @@ namespace NadekoBot.Classes.Permissions { if (timeBlackList.ContainsKey(user)) return false; - timeBlackList.TryAdd(user, DateTime.Now); - if (channel.IsPrivate) - return true; + return false; + + timeBlackList.TryAdd(user, DateTime.Now); try { //is it a permission command? diff --git a/NadekoBot/Commands/LoLCommands.cs b/NadekoBot/Commands/LoLCommands.cs index c521ca05..f91ac5f2 100644 --- a/NadekoBot/Commands/LoLCommands.cs +++ b/NadekoBot/Commands/LoLCommands.cs @@ -5,6 +5,8 @@ using System.Text; using System.Threading.Tasks; using Discord.Commands; using NadekoBot; +using System.Drawing; +using NadekoBot.Extensions; namespace NadekoBot.Commands { class LoLCommands : DiscordCommand { @@ -23,14 +25,71 @@ namespace NadekoBot.Commands { var arg = e.GetArg("region"); var data = Newtonsoft.Json.Linq.JArray.Parse(await Classes.SearchHelper.GetResponseAsync($"http://api.champion.gg/stats/champs/{e.GetArg("region")}?api_key={NadekoBot.creds.LOLAPIKey}"))[0]; var general = data["general"]; + //todo save this for at least 1 hour + Image img = Image.FromFile("data/lol/bg.png"); + using (Graphics g = Graphics.FromImage(img)) { + int statsFontSize = 15; + int margin = 5; + int imageSize = 75; + var normalFont = new Font("Times New Roman", 9, FontStyle.Regular); + //draw champ image + g.DrawImage(Image.FromFile($"data/lol/champions/{data["title"].ToString()}.png"), new Rectangle(margin, margin, imageSize, imageSize)); + //draw champ name + g.DrawString($"{data["title"]}", new Font("Times New Roman", 25, FontStyle.Regular), Brushes.WhiteSmoke, margin + imageSize + margin, margin); + //draw champ surname + //todo + //draw roles + g.DrawString( +@" Average Stats + +Kills: 5.12 CS: 250.5 +Deaths: 0.01 Win: 99% +Assists: 6.55 Ban: 10% +", normalFont, Brushes.WhiteSmoke, img.Width - 150, margin); + //draw masteries + g.DrawString($"MASTERIES: 18 / 0 / 12", normalFont, Brushes.WhiteSmoke, margin, margin + imageSize + margin + 20); + //draw runes + g.DrawString(@"RUNES +9 x Greater Mark of Attack Damage +9 x Greater Glyph of Scaling Magic Resist +9 x Greater Seal of Armor +3 x Greater Quintessence of Attack Speed", normalFont, Brushes.WhiteSmoke, margin, margin + imageSize + margin + 40); + //draw counters + int smallImgSize = 50; + var counters = new string[] { "Yasuo", "Yasuo", "Yasuo" }; + for (int i = 0; i < counters.Length; i++) { + g.DrawImage(Image.FromFile("data/lol/champions/" + counters[i] + ".png"), new Rectangle(i * (smallImgSize + margin) + margin, img.Height - smallImgSize - margin, smallImgSize, smallImgSize)); + } + //draw countered by + var countered = new string[] { "Yasuo", "Yasuo", "Yasuo" }; + for (int i = 0; i < countered.Length; i++) { + g.DrawImage(Image.FromFile("data/lol/champions/" + counters[i] + ".png"), new Rectangle(i * (smallImgSize + margin) + margin, img.Height - smallImgSize - margin, smallImgSize, smallImgSize)); + } + //draw item build + var build = new string[] { "Bloodthirster", "Bloodthirster", "Bloodthirster", "Bloodthirster", "Bloodthirster", "Bloodthirster" }; + /* + int kdkdPosTop = 75; + Font kdkdFont = new Font("Bodoni MT", statsFontSize, FontStyle.Regular); + string killsString = "Kills:"; + SizeF killsSize = g.MeasureString(killsString, kdkdFont); + string deathsString = "Deaths:"; + SizeF deathsSize = g.MeasureString(deathsString, kdkdFont); + string k_dString = "K/D:"; + SizeF k_dSize = g.MeasureString(k_dString, kdkdFont); + // g.DrawString(k_dString, Brushes.WhiteSmoke,200, kdkdPosTop); + g.DrawString($" {general["kills"]} { general["deaths"]} { float.Parse(general["kills"].ToString()) / float.Parse(general["deaths"].ToString()):f2}" + ,new Font("Bodoni MT", statsFontSize, FontStyle.Regular), Brushes.OrangeRed, 200, kdkdPosTop); + */ + } + await e.Channel.SendFile(data["title"] + "_stats.png", img.ToStream()); await e.Channel.SendMessage( $@"**`Champion Name:` {data["title"]} -`Kills:` {general["kills"]} `Deaths:` {general["deaths"]}** `K/D:`**{float.Parse(general["kills"].ToString()) / float.Parse(general["deaths"].ToString()):f2}** + `Minions:` **{general["minionsKilled"]}** `Win percentage:` **{general["winPercent"]}%** "); } - catch (Exception) { + catch (Exception ex) { await e.Channel.SendMessage("💢 Failed retreiving data for that champion."); return; } diff --git a/NadekoBot/Modules/Searches.cs b/NadekoBot/Modules/Searches.cs index b7e57963..27bebe5d 100644 --- a/NadekoBot/Modules/Searches.cs +++ b/NadekoBot/Modules/Searches.cs @@ -13,7 +13,7 @@ namespace NadekoBot.Modules { class Searches : DiscordModule { private Random _r; public Searches() : base() { - commands.Add(new LoLCommands()); + //commands.Add(new LoLCommands()); _r = new Random(); } diff --git a/NadekoBot/bin/Debug/Discord.Net.Audio.dll b/NadekoBot/bin/Debug/Discord.Net.Audio.dll index 893cd5ce..5d8dd66d 100644 Binary files a/NadekoBot/bin/Debug/Discord.Net.Audio.dll and b/NadekoBot/bin/Debug/Discord.Net.Audio.dll differ diff --git a/NadekoBot/bin/Debug/Discord.Net.Commands.dll b/NadekoBot/bin/Debug/Discord.Net.Commands.dll index 9455f48d..ca82db65 100644 Binary files a/NadekoBot/bin/Debug/Discord.Net.Commands.dll and b/NadekoBot/bin/Debug/Discord.Net.Commands.dll differ diff --git a/NadekoBot/bin/Debug/Discord.Net.Modules.dll b/NadekoBot/bin/Debug/Discord.Net.Modules.dll index 7bdb31f7..4db24388 100644 Binary files a/NadekoBot/bin/Debug/Discord.Net.Modules.dll and b/NadekoBot/bin/Debug/Discord.Net.Modules.dll differ diff --git a/NadekoBot/bin/Debug/Discord.Net.dll b/NadekoBot/bin/Debug/Discord.Net.dll index f53f8cc1..c70def20 100644 Binary files a/NadekoBot/bin/Debug/Discord.Net.dll and b/NadekoBot/bin/Debug/Discord.Net.dll differ