From b92c59ecd9c0b79d104b94b3e46783940b4877d4 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 13 Oct 2016 02:00:58 +0200 Subject: [PATCH] Fixed greet stuff, fixed memelist --- .../Commands/ServerGreetCommands.cs | 4 ++-- .../Searches/Commands/MemegenCommands.cs | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/ServerGreetCommands.cs b/src/NadekoBot/Modules/Administration/Commands/ServerGreetCommands.cs index 757ac1e6..fba659ff 100644 --- a/src/NadekoBot/Modules/Administration/Commands/ServerGreetCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/ServerGreetCommands.cs @@ -43,7 +43,7 @@ namespace NadekoBot.Modules.Administration if (channel == null) //maybe warn the server owner that the channel is missing return; - var msg = conf.ChannelByeMessageText.Replace("%user%", user.Mention).Replace("%server%", user.Guild.Name); + var msg = conf.ChannelByeMessageText.Replace("%user%", user.Username + $" ({user.Id})").Replace("%server%", user.Guild.Name); if (string.IsNullOrWhiteSpace(msg)) return; try @@ -78,7 +78,7 @@ namespace NadekoBot.Modules.Administration var channel = (await user.Guild.GetTextChannelsAsync()).SingleOrDefault(c => c.Id == conf.GreetMessageChannelId); if (channel != null) //maybe warn the server owner that the channel is missing { - var msg = conf.ChannelGreetMessageText.Replace("%user%", user.Username).Replace("%server%", user.Guild.Name); + var msg = conf.ChannelGreetMessageText.Replace("%user%", user.Mention).Replace("%server%", user.Guild.Name); if (!string.IsNullOrWhiteSpace(msg)) { try diff --git a/src/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs b/src/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs index d35c37d2..1015f679 100644 --- a/src/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs +++ b/src/NadekoBot/Modules/Searches/Commands/MemegenCommands.cs @@ -20,9 +20,23 @@ namespace NadekoBot.Modules.Searches public async Task Memelist(IUserMessage umsg) { var channel = (ITextChannel)umsg.Channel; - using (var http = new HttpClient()) + HttpClientHandler handler = new HttpClientHandler(); + + handler.AllowAutoRedirect = false; + + using (var http = new HttpClient(handler)) { - var data = JsonConvert.DeserializeObject>(await http.GetStringAsync("http://memegen.link/templates/")) + http.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); + string rawJson = ""; + try + { + rawJson = await http.GetStringAsync("https://memegen.link/api/templates/").ConfigureAwait(false); + } + catch (Exception ex) + { + Console.WriteLine(ex); + } + var data = JsonConvert.DeserializeObject>(rawJson) .Select(kvp => Path.GetFileName(kvp.Value)); await channel.SendTableAsync(data, x => $"{x,-17}", 3);