From f1387f824e34e99b8fd017767d620be7563f1736 Mon Sep 17 00:00:00 2001 From: runebaas Date: Thu, 19 Sep 2019 13:40:02 +0200 Subject: [PATCH] Remove the google command --- .../Commands/Integrations/Google/Google.cs | 68 ------------------- .../Google/GoogleKgApiDetailedDto.cs | 9 --- .../Google/GoogleKgApiElementDto.cs | 8 --- .../Google/GoogleKgApiImageDto.cs | 8 --- .../Google/GoogleKgApiResponseDto.cs | 9 --- .../Google/GoogleKgApiResultDto.cs | 10 --- 6 files changed, 112 deletions(-) delete mode 100644 Geekbot.net/Commands/Integrations/Google/Google.cs delete mode 100644 Geekbot.net/Commands/Integrations/Google/GoogleKgApiDetailedDto.cs delete mode 100644 Geekbot.net/Commands/Integrations/Google/GoogleKgApiElementDto.cs delete mode 100644 Geekbot.net/Commands/Integrations/Google/GoogleKgApiImageDto.cs delete mode 100644 Geekbot.net/Commands/Integrations/Google/GoogleKgApiResponseDto.cs delete mode 100644 Geekbot.net/Commands/Integrations/Google/GoogleKgApiResultDto.cs diff --git a/Geekbot.net/Commands/Integrations/Google/Google.cs b/Geekbot.net/Commands/Integrations/Google/Google.cs deleted file mode 100644 index db059b4..0000000 --- a/Geekbot.net/Commands/Integrations/Google/Google.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Linq; -using System.Net; -using System.Threading.Tasks; -using Discord; -using Discord.Commands; -using Geekbot.net.Lib.ErrorHandling; -using Geekbot.net.Lib.GlobalSettings; -using Newtonsoft.Json; - -namespace Geekbot.net.Commands.Integrations.Google -{ - public class Google : ModuleBase - { - private readonly IErrorHandler _errorHandler; - private readonly IGlobalSettings _globalSettings; - - public Google(IErrorHandler errorHandler, IGlobalSettings globalSettings) - { - _errorHandler = errorHandler; - _globalSettings = globalSettings; - } - - [Command("google", RunMode = RunMode.Async)] - [Summary("Google Something.")] - public async Task AskGoogle([Remainder, Summary("search-text")] string searchText) - { - try - { - using (var client = new WebClient()) - { - var apiKey = _globalSettings.GetKey("GoogleGraphKey"); - if (string.IsNullOrEmpty(apiKey)) - { - await ReplyAsync("No Google API key has been set, please contact my owner"); - return; - } - - var url = new Uri($"https://kgsearch.googleapis.com/v1/entities:search?languages=en&limit=1&query={searchText}&key={apiKey}"); - var responseString = client.DownloadString(url); - var response = JsonConvert.DeserializeObject(responseString); - - if (!response.ItemListElement.Any()) - { - await ReplyAsync("No results were found..."); - return; - } - - var data = response.ItemListElement.First().Result; - var eb = new EmbedBuilder - { - Title = data.Name - }; - if(!string.IsNullOrEmpty(data.Description)) eb.WithDescription(data.Description); - if(!string.IsNullOrEmpty(data.DetailedDtoDescription?.Url)) eb.WithUrl(data.DetailedDtoDescription.Url); - if(!string.IsNullOrEmpty(data.DetailedDtoDescription?.ArticleBody)) eb.AddField("Details", data.DetailedDtoDescription.ArticleBody); - if(!string.IsNullOrEmpty(data.Image?.ContentUrl)) eb.WithThumbnailUrl(data.Image.ContentUrl); - - await ReplyAsync("", false, eb.Build()); - } - } - catch (Exception e) - { - await _errorHandler.HandleCommandException(e, Context); - } - } - } -} \ No newline at end of file diff --git a/Geekbot.net/Commands/Integrations/Google/GoogleKgApiDetailedDto.cs b/Geekbot.net/Commands/Integrations/Google/GoogleKgApiDetailedDto.cs deleted file mode 100644 index 031d1e7..0000000 --- a/Geekbot.net/Commands/Integrations/Google/GoogleKgApiDetailedDto.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Geekbot.net.Commands.Integrations.Google -{ - public class GoogleKgApiDetailedDto - { - public string ArticleBody { get; set; } - public string Url { get; set; } - public string License { get; set; } - } -} \ No newline at end of file diff --git a/Geekbot.net/Commands/Integrations/Google/GoogleKgApiElementDto.cs b/Geekbot.net/Commands/Integrations/Google/GoogleKgApiElementDto.cs deleted file mode 100644 index a48b184..0000000 --- a/Geekbot.net/Commands/Integrations/Google/GoogleKgApiElementDto.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Geekbot.net.Commands.Integrations.Google -{ - public class GoogleKgApiElementDto - { - public GoogleKgApiResultDto Result { get; set; } - public double ResultScore { get; set; } - } -} \ No newline at end of file diff --git a/Geekbot.net/Commands/Integrations/Google/GoogleKgApiImageDto.cs b/Geekbot.net/Commands/Integrations/Google/GoogleKgApiImageDto.cs deleted file mode 100644 index fe7cdaa..0000000 --- a/Geekbot.net/Commands/Integrations/Google/GoogleKgApiImageDto.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Geekbot.net.Commands.Integrations.Google -{ - public class GoogleKgApiImageDto - { - public string ContentUrl { get; set; } - public string Url { get; set; } - } -} \ No newline at end of file diff --git a/Geekbot.net/Commands/Integrations/Google/GoogleKgApiResponseDto.cs b/Geekbot.net/Commands/Integrations/Google/GoogleKgApiResponseDto.cs deleted file mode 100644 index af337db..0000000 --- a/Geekbot.net/Commands/Integrations/Google/GoogleKgApiResponseDto.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Collections.Generic; - -namespace Geekbot.net.Commands.Integrations.Google -{ - public class GoogleKgApiResponseDto - { - public List ItemListElement { get; set; } - } -} \ No newline at end of file diff --git a/Geekbot.net/Commands/Integrations/Google/GoogleKgApiResultDto.cs b/Geekbot.net/Commands/Integrations/Google/GoogleKgApiResultDto.cs deleted file mode 100644 index 465f1d7..0000000 --- a/Geekbot.net/Commands/Integrations/Google/GoogleKgApiResultDto.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Geekbot.net.Commands.Integrations.Google -{ - public class GoogleKgApiResultDto - { - public string Name { get; set; } - public string Description { get; set; } - public GoogleKgApiImageDto Image { get; set; } - public GoogleKgApiDetailedDto DetailedDtoDescription { get; set; } - } -} \ No newline at end of file