From 5b95cdaca8441ff6b44ed689fcb47a9f6c17159b Mon Sep 17 00:00:00 2001 From: RaidMax Date: Mon, 1 Nov 2021 17:06:17 -0500 Subject: [PATCH] update welcome plugin to bypass api lookup limitation --- Plugins/Welcome/Plugin.cs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Plugins/Welcome/Plugin.cs b/Plugins/Welcome/Plugin.cs index d95f7f798..ab1e7e34b 100644 --- a/Plugins/Welcome/Plugin.cs +++ b/Plugins/Welcome/Plugin.cs @@ -104,24 +104,22 @@ namespace IW4MAdmin.Plugins.Welcome /// private async Task GetCountryName(string ip) { - using (var wc = new WebClient()) + using var wc = new WebClient(); + try { - try - { - string response = - await wc.DownloadStringTaskAsync(new Uri($"http://extreme-ip-lookup.com/json/{ip}")); - var responseObj = JObject.Parse(response); - response = responseObj["country"].ToString(); + var response = + await wc.DownloadStringTaskAsync(new Uri($"http://extreme-ip-lookup.com/json/{ip}?key=demo")); + var responseObj = JObject.Parse(response); + response = responseObj["country"]?.ToString(); - return string.IsNullOrEmpty(response) - ? Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_WELCOME_UNKNOWN_COUNTRY"] - : response; - } + return string.IsNullOrEmpty(response) + ? Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_WELCOME_UNKNOWN_COUNTRY"] + : response; + } - catch - { - return Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_WELCOME_UNKNOWN_IP"]; - } + catch + { + return Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_WELCOME_UNKNOWN_IP"]; } } }