示例#1
0
        public static async Task IsKickedDetail(string APIKey, string userID)
        {
            using (HttpClient client = new HttpClient())
            {
                var webRequest = await client.GetAsync("https://bans.kingsplayground.fun/recentkickdetail.php?KEY=" + APIKey + "&STEAMID=" + userID);

                if (!webRequest.IsSuccessStatusCode)
                {
                    Exiled.API.Features.Log.Error("Web API connection error in IsKickeddetail(): " + webRequest.StatusCode + " - " + webRequest.Content.ReadAsStringAsync());
                }

                string apiResponse = await webRequest.Content.ReadAsStringAsync();

                Exiled.API.Features.Log.Info($"BAN API RESPONSE FOR {userID}: {apiResponse}");

                JObject json = JObject.Parse(apiResponse);

                bool banned = json.Value <bool>("recentkick");
                if (banned)
                {
                    string reason = json.Value <string>("reason");
                    PlayerEvents.DisplayKickInfo(userID, reason);
                }
                else
                {
                    PlayerEvents.DisplayKickInfo(userID, "nokickfound");
                }
            }
        }