From e3adf557429effbe2cac6a6dd8af72e4878dabde Mon Sep 17 00:00:00 2001 From: runebaas Date: Thu, 3 May 2018 00:56:06 +0200 Subject: [PATCH] Refaction all files into component based folders --- Geekbot.net/Commands/{ => Admin}/Admin.cs | 4 +- Geekbot.net/Commands/{ => Admin}/Mod.cs | 4 +- Geekbot.net/Commands/{ => Admin}/Owner.cs | 5 +- Geekbot.net/Commands/{ => Admin}/Role.cs | 4 +- Geekbot.net/Commands/{ => Admin}/Say.cs | 3 +- Geekbot.net/Commands/{ => Games}/BattleTag.cs | 4 +- Geekbot.net/Commands/{ => Games}/Overwatch.cs | 5 +- Geekbot.net/Commands/{ => Games}/Pokedex.cs | 3 +- Geekbot.net/Commands/{ => Games}/Roll.cs | 4 +- .../{ => Integrations/Google}/Google.cs | 46 +----- .../Google/GoogleKgApiDetailedDto.cs | 9 ++ .../Google/GoogleKgApiElementDto.cs | 8 + .../Google/GoogleKgApiImageDto.cs | 8 + .../Google/GoogleKgApiResponseDto.cs | 9 ++ .../Google/GoogleKgApiResultDto.cs | 10 ++ .../{ => Integrations}/MagicTheGathering.cs | 4 +- .../Commands/{mal.cs => Integrations/Mal.cs} | 4 +- .../UbranDictionary/UrbanDictListItemDto.cs | 12 ++ .../UbranDictionary/UrbanDictResponseDto.cs | 10 ++ .../UbranDictionary}/UrbanDictionary.cs | 22 +-- .../Commands/{ => Integrations}/Wikipedia.cs | 3 +- .../Commands/{ => Integrations}/Youtube.cs | 3 +- .../Commands/{ => Randomness/Cat}/Cat.cs | 110 +++++++------- .../Commands/Randomness/Cat/CatResponseDto.cs | 7 + .../Commands/{ => Randomness}/CheckEm.cs | 143 +++++++++--------- .../Chuck/ChuckNorrisJokeResponseDto.cs | 7 + .../Chuck}/ChuckNorrisJokes.cs | 10 +- .../Randomness/Dad/DadJokeResponseDto.cs | 7 + .../Commands/{ => Randomness/Dad}/DadJokes.cs | 10 +- .../Commands/{ => Randomness/Dog}/Dog.cs | 10 +- .../Commands/Randomness/Dog/DogResponseDto.cs | 7 + .../Commands/{ => Randomness}/EightBall.cs | 3 +- .../Commands/{ => Randomness}/Fortune.cs | 2 +- Geekbot.net/Commands/{ => Randomness}/Gdq.cs | 3 +- .../{ => Randomness}/RandomAnimals.cs | 2 +- Geekbot.net/Commands/{ => Randomness}/Ship.cs | 3 +- Geekbot.net/Commands/{ => Randomness}/Slap.cs | 3 +- Geekbot.net/Commands/{ => User}/GuildInfo.cs | 11 +- Geekbot.net/Commands/{ => User}/Karma.cs | 4 +- Geekbot.net/Commands/{ => User/Rank}/Rank.cs | 19 +-- .../Commands/User/Rank/RankUserPolyfillDto.cs | 9 ++ Geekbot.net/Commands/{ => User}/Stats.cs | 4 +- .../Commands/{ => Utils}/AvatarGetter.cs | 3 +- .../{ => Utils/Changelog}/Changelog.cs | 21 +-- .../Utils/Changelog/CommitAuthorDto.cs | 9 ++ .../Commands/Utils/Changelog/CommitDto.cs | 7 + .../Commands/Utils/Changelog/CommitInfoDto.cs | 8 + Geekbot.net/Commands/{ => Utils}/Choose.cs | 4 +- Geekbot.net/Commands/{ => Utils/Dice}/Dice.cs | 10 +- .../Commands/Utils/Dice/DiceTypeDto.cs | 10 ++ Geekbot.net/Commands/{ => Utils}/Emojify.cs | 4 +- Geekbot.net/Commands/{ => Utils}/Help.cs | 3 +- Geekbot.net/Commands/{ => Utils}/Info.cs | 3 +- Geekbot.net/Commands/{ => Utils}/Ping.cs | 2 +- Geekbot.net/Commands/{ => Utils/Poll}/Poll.cs | 34 ++--- .../Commands/Utils/Poll/PollDataDto.cs | 13 ++ .../Commands/Utils/Poll/PollResultDto.cs | 8 + .../Commands/{ => Utils/Quote}/Quote.cs | 21 +-- .../Commands/Utils/Quote/QuoteObjectDto.cs | 12 ++ Geekbot.net/Commands/Voice.cs | 102 ------------- Geekbot.net/Geekbot.net.csproj | 9 +- Geekbot.net/Handlers.cs | 5 +- Geekbot.net/Lib/Clients/IMalClient.cs | 12 ++ Geekbot.net/Lib/{ => Clients}/MalClient.cs | 10 +- .../Lib/{ => Converters}/EmojiConverter.cs | 8 +- Geekbot.net/Lib/Converters/IEmojiConverter.cs | 8 + .../Lib/Converters/IMtgManaConverter.cs | 7 + .../Lib/Converters/MtgManaConverter.cs | 33 ++++ Geekbot.net/Lib/Converters/MtgManaEmojis.json | 50 ++++++ .../Lib/{ => ErrorHandling}/ErrorHandler.cs | 10 +- .../Lib/ErrorHandling/IErrorHandler.cs | 12 ++ Geekbot.net/Lib/Levels/ILevelCalc.cs | 7 + Geekbot.net/Lib/{ => Levels}/LevelCalc.cs | 7 +- .../Lib/Localization/ITranslationHandler.cs | 14 ++ .../{ => Localization}/TranslationHandler.cs | 14 +- .../Localization}/Translations.json | 0 Geekbot.net/Lib/Logger/DiscordLogger.cs | 42 +++++ Geekbot.net/Lib/{ => Logger}/GeekbotLogger.cs | 25 +-- Geekbot.net/Lib/Logger/IDiscordLogger.cs | 10 ++ Geekbot.net/Lib/Logger/IGeekbotLogger.cs | 13 ++ Geekbot.net/Lib/Logger/LogDto.cs | 14 ++ Geekbot.net/Lib/{ => Logger}/LoggerFactory.cs | 4 +- Geekbot.net/Lib/Logger/MessageDto.cs | 26 ++++ .../Lib/{ => Logger}/SimpleConextConverter.cs | 27 +--- Geekbot.net/Lib/Media/FortunesProvider.cs | 8 +- Geekbot.net/Lib/Media/IFortunesProvider.cs | 7 + Geekbot.net/Lib/Media/IMediaProvider.cs | 14 ++ Geekbot.net/Lib/Media/MediaProvider.cs | 29 ++-- Geekbot.net/Lib/MtgManaConverter.cs | 86 ----------- .../Lib/ReactionListener/IReactionListener.cs | 14 ++ .../ReactionListener.cs | 10 +- .../Lib/UserRepository/IUserRepository.cs | 13 ++ .../{ => UserRepository}/UserRepository.cs | 22 +-- .../UserRepository/UserRepositoryUserDto.cs | 16 ++ Geekbot.net/Program.cs | 40 ++--- Geekbot.net/WebApi/Help/CommandDto.cs | 15 ++ Geekbot.net/WebApi/Help/CommandParamDto.cs | 9 ++ .../WebApi/{ => Help}/HelpController.cs | 23 +-- Geekbot.net/WebApi/Status/ApiStatusDto.cs | 9 ++ .../WebApi/{ => Status}/StatusController.cs | 9 +- Tests/Lib/EmojiConverter.test.cs | 1 + Tests/Lib/LevelCalc.test.cs | 1 + 102 files changed, 816 insertions(+), 709 deletions(-) rename Geekbot.net/Commands/{ => Admin}/Admin.cs (96%) rename Geekbot.net/Commands/{ => Admin}/Mod.cs (94%) rename Geekbot.net/Commands/{ => Admin}/Owner.cs (94%) rename Geekbot.net/Commands/{ => Admin}/Role.cs (98%) rename Geekbot.net/Commands/{ => Admin}/Say.cs (92%) rename Geekbot.net/Commands/{ => Games}/BattleTag.cs (92%) rename Geekbot.net/Commands/{ => Games}/Overwatch.cs (94%) rename Geekbot.net/Commands/{ => Games}/Pokedex.cs (94%) rename Geekbot.net/Commands/{ => Games}/Roll.cs (95%) rename Geekbot.net/Commands/{ => Integrations/Google}/Google.cs (56%) create mode 100644 Geekbot.net/Commands/Integrations/Google/GoogleKgApiDetailedDto.cs create mode 100644 Geekbot.net/Commands/Integrations/Google/GoogleKgApiElementDto.cs create mode 100644 Geekbot.net/Commands/Integrations/Google/GoogleKgApiImageDto.cs create mode 100644 Geekbot.net/Commands/Integrations/Google/GoogleKgApiResponseDto.cs create mode 100644 Geekbot.net/Commands/Integrations/Google/GoogleKgApiResultDto.cs rename Geekbot.net/Commands/{ => Integrations}/MagicTheGathering.cs (94%) rename Geekbot.net/Commands/{mal.cs => Integrations/Mal.cs} (95%) create mode 100644 Geekbot.net/Commands/Integrations/UbranDictionary/UrbanDictListItemDto.cs create mode 100644 Geekbot.net/Commands/Integrations/UbranDictionary/UrbanDictResponseDto.cs rename Geekbot.net/Commands/{ => Integrations/UbranDictionary}/UrbanDictionary.cs (78%) rename Geekbot.net/Commands/{ => Integrations}/Wikipedia.cs (95%) rename Geekbot.net/Commands/{ => Integrations}/Youtube.cs (92%) rename Geekbot.net/Commands/{ => Randomness/Cat}/Cat.cs (90%) create mode 100644 Geekbot.net/Commands/Randomness/Cat/CatResponseDto.cs rename Geekbot.net/Commands/{ => Randomness}/CheckEm.cs (93%) create mode 100644 Geekbot.net/Commands/Randomness/Chuck/ChuckNorrisJokeResponseDto.cs rename Geekbot.net/Commands/{ => Randomness/Chuck}/ChuckNorrisJokes.cs (87%) create mode 100644 Geekbot.net/Commands/Randomness/Dad/DadJokeResponseDto.cs rename Geekbot.net/Commands/{ => Randomness/Dad}/DadJokes.cs (87%) rename Geekbot.net/Commands/{ => Randomness/Dog}/Dog.cs (88%) create mode 100644 Geekbot.net/Commands/Randomness/Dog/DogResponseDto.cs rename Geekbot.net/Commands/{ => Randomness}/EightBall.cs (95%) rename Geekbot.net/Commands/{ => Randomness}/Fortune.cs (89%) rename Geekbot.net/Commands/{ => Randomness}/Gdq.cs (89%) rename Geekbot.net/Commands/{ => Randomness}/RandomAnimals.cs (98%) rename Geekbot.net/Commands/{ => Randomness}/Ship.cs (94%) rename Geekbot.net/Commands/{ => Randomness}/Slap.cs (94%) rename Geekbot.net/Commands/{ => User}/GuildInfo.cs (83%) rename Geekbot.net/Commands/{ => User}/Karma.cs (97%) rename Geekbot.net/Commands/{ => User/Rank}/Rank.cs (93%) create mode 100644 Geekbot.net/Commands/User/Rank/RankUserPolyfillDto.cs rename Geekbot.net/Commands/{ => User}/Stats.cs (96%) rename Geekbot.net/Commands/{ => Utils}/AvatarGetter.cs (89%) rename Geekbot.net/Commands/{ => Utils/Changelog}/Changelog.cs (82%) create mode 100644 Geekbot.net/Commands/Utils/Changelog/CommitAuthorDto.cs create mode 100644 Geekbot.net/Commands/Utils/Changelog/CommitDto.cs create mode 100644 Geekbot.net/Commands/Utils/Changelog/CommitInfoDto.cs rename Geekbot.net/Commands/{ => Utils}/Choose.cs (88%) rename Geekbot.net/Commands/{ => Utils/Dice}/Dice.cs (93%) create mode 100644 Geekbot.net/Commands/Utils/Dice/DiceTypeDto.cs rename Geekbot.net/Commands/{ => Utils}/Emojify.cs (89%) rename Geekbot.net/Commands/{ => Utils}/Help.cs (93%) rename Geekbot.net/Commands/{ => Utils}/Info.cs (94%) rename Geekbot.net/Commands/{ => Utils}/Ping.cs (91%) rename Geekbot.net/Commands/{ => Utils/Poll}/Poll.cs (85%) create mode 100644 Geekbot.net/Commands/Utils/Poll/PollDataDto.cs create mode 100644 Geekbot.net/Commands/Utils/Poll/PollResultDto.cs rename Geekbot.net/Commands/{ => Utils/Quote}/Quote.cs (94%) create mode 100644 Geekbot.net/Commands/Utils/Quote/QuoteObjectDto.cs delete mode 100644 Geekbot.net/Commands/Voice.cs create mode 100644 Geekbot.net/Lib/Clients/IMalClient.cs rename Geekbot.net/Lib/{ => Clients}/MalClient.cs (89%) rename Geekbot.net/Lib/{ => Converters}/EmojiConverter.cs (92%) create mode 100644 Geekbot.net/Lib/Converters/IEmojiConverter.cs create mode 100644 Geekbot.net/Lib/Converters/IMtgManaConverter.cs create mode 100644 Geekbot.net/Lib/Converters/MtgManaConverter.cs create mode 100644 Geekbot.net/Lib/Converters/MtgManaEmojis.json rename Geekbot.net/Lib/{ => ErrorHandling}/ErrorHandler.cs (93%) create mode 100644 Geekbot.net/Lib/ErrorHandling/IErrorHandler.cs create mode 100644 Geekbot.net/Lib/Levels/ILevelCalc.cs rename Geekbot.net/Lib/{ => Levels}/LevelCalc.cs (87%) create mode 100644 Geekbot.net/Lib/Localization/ITranslationHandler.cs rename Geekbot.net/Lib/{ => Localization}/TranslationHandler.cs (90%) rename Geekbot.net/{Storage => Lib/Localization}/Translations.json (100%) create mode 100644 Geekbot.net/Lib/Logger/DiscordLogger.cs rename Geekbot.net/Lib/{ => Logger}/GeekbotLogger.cs (75%) create mode 100644 Geekbot.net/Lib/Logger/IDiscordLogger.cs create mode 100644 Geekbot.net/Lib/Logger/IGeekbotLogger.cs create mode 100644 Geekbot.net/Lib/Logger/LogDto.cs rename Geekbot.net/Lib/{ => Logger}/LoggerFactory.cs (95%) create mode 100644 Geekbot.net/Lib/Logger/MessageDto.cs rename Geekbot.net/Lib/{ => Logger}/SimpleConextConverter.cs (75%) create mode 100644 Geekbot.net/Lib/Media/IFortunesProvider.cs create mode 100644 Geekbot.net/Lib/Media/IMediaProvider.cs delete mode 100644 Geekbot.net/Lib/MtgManaConverter.cs create mode 100644 Geekbot.net/Lib/ReactionListener/IReactionListener.cs rename Geekbot.net/Lib/{ => ReactionListener}/ReactionListener.cs (87%) create mode 100644 Geekbot.net/Lib/UserRepository/IUserRepository.cs rename Geekbot.net/Lib/{ => UserRepository}/UserRepository.cs (84%) create mode 100644 Geekbot.net/Lib/UserRepository/UserRepositoryUserDto.cs create mode 100644 Geekbot.net/WebApi/Help/CommandDto.cs create mode 100644 Geekbot.net/WebApi/Help/CommandParamDto.cs rename Geekbot.net/WebApi/{ => Help}/HelpController.cs (70%) create mode 100644 Geekbot.net/WebApi/Status/ApiStatusDto.cs rename Geekbot.net/WebApi/{ => Status}/StatusController.cs (71%) diff --git a/Geekbot.net/Commands/Admin.cs b/Geekbot.net/Commands/Admin/Admin.cs similarity index 96% rename from Geekbot.net/Commands/Admin.cs rename to Geekbot.net/Commands/Admin/Admin.cs index 481eab1..7d30689 100644 --- a/Geekbot.net/Commands/Admin.cs +++ b/Geekbot.net/Commands/Admin/Admin.cs @@ -5,9 +5,11 @@ using Discord; using Discord.Commands; using Discord.WebSocket; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.Localization; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Admin { [Group("admin")] [RequireUserPermission(GuildPermission.Administrator)] diff --git a/Geekbot.net/Commands/Mod.cs b/Geekbot.net/Commands/Admin/Mod.cs similarity index 94% rename from Geekbot.net/Commands/Mod.cs rename to Geekbot.net/Commands/Admin/Mod.cs index e8751f6..2dacee3 100644 --- a/Geekbot.net/Commands/Mod.cs +++ b/Geekbot.net/Commands/Admin/Mod.cs @@ -5,9 +5,11 @@ using Discord; using Discord.Commands; using Discord.WebSocket; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.UserRepository; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Admin { [Group("mod")] [RequireUserPermission(GuildPermission.KickMembers)] diff --git a/Geekbot.net/Commands/Owner.cs b/Geekbot.net/Commands/Admin/Owner.cs similarity index 94% rename from Geekbot.net/Commands/Owner.cs rename to Geekbot.net/Commands/Admin/Owner.cs index b73797f..39ccd8c 100644 --- a/Geekbot.net/Commands/Owner.cs +++ b/Geekbot.net/Commands/Admin/Owner.cs @@ -4,9 +4,12 @@ using Discord; using Discord.Commands; using Discord.WebSocket; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.Logger; +using Geekbot.net.Lib.UserRepository; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Admin { [Group("owner")] [RequireUserPermission(GuildPermission.Administrator)] diff --git a/Geekbot.net/Commands/Role.cs b/Geekbot.net/Commands/Admin/Role.cs similarity index 98% rename from Geekbot.net/Commands/Role.cs rename to Geekbot.net/Commands/Admin/Role.cs index eb67bbf..24d19dd 100644 --- a/Geekbot.net/Commands/Role.cs +++ b/Geekbot.net/Commands/Admin/Role.cs @@ -6,9 +6,11 @@ using Discord; using Discord.Commands; using Discord.Net; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.ReactionListener; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Admin { [Group("role")] public class Role : ModuleBase diff --git a/Geekbot.net/Commands/Say.cs b/Geekbot.net/Commands/Admin/Say.cs similarity index 92% rename from Geekbot.net/Commands/Say.cs rename to Geekbot.net/Commands/Admin/Say.cs index 4c878c4..97c7a0f 100644 --- a/Geekbot.net/Commands/Say.cs +++ b/Geekbot.net/Commands/Admin/Say.cs @@ -3,8 +3,9 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Admin { public class Say : ModuleBase { diff --git a/Geekbot.net/Commands/BattleTag.cs b/Geekbot.net/Commands/Games/BattleTag.cs similarity index 92% rename from Geekbot.net/Commands/BattleTag.cs rename to Geekbot.net/Commands/Games/BattleTag.cs index eb6fca1..88cc0d8 100644 --- a/Geekbot.net/Commands/BattleTag.cs +++ b/Geekbot.net/Commands/Games/BattleTag.cs @@ -2,8 +2,10 @@ using System.Threading.Tasks; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.UserRepository; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Games { [Group("battletag")] public class BattleTag : ModuleBase diff --git a/Geekbot.net/Commands/Overwatch.cs b/Geekbot.net/Commands/Games/Overwatch.cs similarity index 94% rename from Geekbot.net/Commands/Overwatch.cs rename to Geekbot.net/Commands/Games/Overwatch.cs index 0a39662..73e5858 100644 --- a/Geekbot.net/Commands/Overwatch.cs +++ b/Geekbot.net/Commands/Games/Overwatch.cs @@ -3,11 +3,12 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.UserRepository; using OverwatchAPI; using OverwatchAPI.Config; -using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Games { [Group("ow")] public class Overwatch : ModuleBase diff --git a/Geekbot.net/Commands/Pokedex.cs b/Geekbot.net/Commands/Games/Pokedex.cs similarity index 94% rename from Geekbot.net/Commands/Pokedex.cs rename to Geekbot.net/Commands/Games/Pokedex.cs index fa8746f..57f842a 100644 --- a/Geekbot.net/Commands/Pokedex.cs +++ b/Geekbot.net/Commands/Games/Pokedex.cs @@ -4,9 +4,10 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; using PokeAPI; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Games { public class Pokedex : ModuleBase { diff --git a/Geekbot.net/Commands/Roll.cs b/Geekbot.net/Commands/Games/Roll.cs similarity index 95% rename from Geekbot.net/Commands/Roll.cs rename to Geekbot.net/Commands/Games/Roll.cs index 8d4854c..30697df 100644 --- a/Geekbot.net/Commands/Roll.cs +++ b/Geekbot.net/Commands/Games/Roll.cs @@ -2,9 +2,11 @@ using System.Threading.Tasks; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.Localization; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Games { public class Roll : ModuleBase { diff --git a/Geekbot.net/Commands/Google.cs b/Geekbot.net/Commands/Integrations/Google/Google.cs similarity index 56% rename from Geekbot.net/Commands/Google.cs rename to Geekbot.net/Commands/Integrations/Google/Google.cs index 19d3efb..8e880c4 100644 --- a/Geekbot.net/Commands/Google.cs +++ b/Geekbot.net/Commands/Integrations/Google/Google.cs @@ -1,15 +1,15 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Net; using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; using StackExchange.Redis; using Utf8Json; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Integrations.Google { public class Google : ModuleBase { @@ -40,7 +40,7 @@ namespace Geekbot.net.Commands 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 = JsonSerializer.Deserialize(responseString); + var response = JsonSerializer.Deserialize(responseString); if (!response.ItemListElement.Any()) { @@ -48,13 +48,13 @@ namespace Geekbot.net.Commands return; } - var data = response.ItemListElement.First().Result; + var data = response.ItemListElement.First().ResultDto; var eb = new EmbedBuilder(); eb.Title = data.Name; if(!string.IsNullOrEmpty(data.Description)) eb.WithDescription(data.Description); - if(!string.IsNullOrEmpty(data.DetailedDescription?.Url)) eb.WithUrl(data.DetailedDescription.Url); - if(!string.IsNullOrEmpty(data.DetailedDescription?.ArticleBody)) eb.AddField("Details", data.DetailedDescription.ArticleBody); - if(!string.IsNullOrEmpty(data.Image?.ContentUrl)) eb.WithThumbnailUrl(data.Image.ContentUrl); + 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.ImageDto?.ContentUrl)) eb.WithThumbnailUrl(data.ImageDto.ContentUrl); await ReplyAsync("", false, eb.Build()); } @@ -64,37 +64,5 @@ namespace Geekbot.net.Commands _errorHandler.HandleCommandException(e, Context); } } - - public class GoogleKgApiResponse - { - public List ItemListElement { get; set; } - - public class GoogleKgApiElement - { - public GoogleKgApiResult Result { get; set; } - public double ResultScore { get; set; } - } - - public class GoogleKgApiResult - { - public string Name { get; set; } - public string Description { get; set; } - public GoogleKgApiImage Image { get; set; } - public GoogleKgApiDetailed DetailedDescription { get; set; } - } - - public class GoogleKgApiImage - { - public string ContentUrl { get; set; } - public string Url { get; set; } - } - - public class GoogleKgApiDetailed - { - 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/GoogleKgApiDetailedDto.cs b/Geekbot.net/Commands/Integrations/Google/GoogleKgApiDetailedDto.cs new file mode 100644 index 0000000..031d1e7 --- /dev/null +++ b/Geekbot.net/Commands/Integrations/Google/GoogleKgApiDetailedDto.cs @@ -0,0 +1,9 @@ +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 new file mode 100644 index 0000000..3c4a130 --- /dev/null +++ b/Geekbot.net/Commands/Integrations/Google/GoogleKgApiElementDto.cs @@ -0,0 +1,8 @@ +namespace Geekbot.net.Commands.Integrations.Google +{ + public class GoogleKgApiElementDto + { + public GoogleKgApiResultDto ResultDto { 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 new file mode 100644 index 0000000..fe7cdaa --- /dev/null +++ b/Geekbot.net/Commands/Integrations/Google/GoogleKgApiImageDto.cs @@ -0,0 +1,8 @@ +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 new file mode 100644 index 0000000..af337db --- /dev/null +++ b/Geekbot.net/Commands/Integrations/Google/GoogleKgApiResponseDto.cs @@ -0,0 +1,9 @@ +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 new file mode 100644 index 0000000..2c348c9 --- /dev/null +++ b/Geekbot.net/Commands/Integrations/Google/GoogleKgApiResultDto.cs @@ -0,0 +1,10 @@ +namespace Geekbot.net.Commands.Integrations.Google +{ + public class GoogleKgApiResultDto + { + public string Name { get; set; } + public string Description { get; set; } + public GoogleKgApiImageDto ImageDto { get; set; } + public GoogleKgApiDetailedDto DetailedDtoDescription { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/MagicTheGathering.cs b/Geekbot.net/Commands/Integrations/MagicTheGathering.cs similarity index 94% rename from Geekbot.net/Commands/MagicTheGathering.cs rename to Geekbot.net/Commands/Integrations/MagicTheGathering.cs index 9c7379f..3074803 100644 --- a/Geekbot.net/Commands/MagicTheGathering.cs +++ b/Geekbot.net/Commands/Integrations/MagicTheGathering.cs @@ -5,9 +5,11 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.Converters; +using Geekbot.net.Lib.ErrorHandling; using MtgApiManager.Lib.Service; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Integrations { public class Magicthegathering : ModuleBase { diff --git a/Geekbot.net/Commands/mal.cs b/Geekbot.net/Commands/Integrations/Mal.cs similarity index 95% rename from Geekbot.net/Commands/mal.cs rename to Geekbot.net/Commands/Integrations/Mal.cs index 8c16936..d70949a 100644 --- a/Geekbot.net/Commands/mal.cs +++ b/Geekbot.net/Commands/Integrations/Mal.cs @@ -4,8 +4,10 @@ using System.Web; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.Clients; +using Geekbot.net.Lib.ErrorHandling; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Integrations { public class Mal : ModuleBase { diff --git a/Geekbot.net/Commands/Integrations/UbranDictionary/UrbanDictListItemDto.cs b/Geekbot.net/Commands/Integrations/UbranDictionary/UrbanDictListItemDto.cs new file mode 100644 index 0000000..e98885b --- /dev/null +++ b/Geekbot.net/Commands/Integrations/UbranDictionary/UrbanDictListItemDto.cs @@ -0,0 +1,12 @@ +namespace Geekbot.net.Commands.Integrations.UbranDictionary +{ + internal class UrbanListItemDto + { + public string Definition { get; set; } + public string Permalink { get; set; } + public string ThumbsUp { get; set; } + public string Word { get; set; } + public string Example { get; set; } + public string ThumbsDown { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/Integrations/UbranDictionary/UrbanDictResponseDto.cs b/Geekbot.net/Commands/Integrations/UbranDictionary/UrbanDictResponseDto.cs new file mode 100644 index 0000000..2c3e014 --- /dev/null +++ b/Geekbot.net/Commands/Integrations/UbranDictionary/UrbanDictResponseDto.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace Geekbot.net.Commands.Integrations.UbranDictionary +{ + internal class UrbanResponseDto + { + public string[] Tags { get; set; } + public List List { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/UrbanDictionary.cs b/Geekbot.net/Commands/Integrations/UbranDictionary/UrbanDictionary.cs similarity index 78% rename from Geekbot.net/Commands/UrbanDictionary.cs rename to Geekbot.net/Commands/Integrations/UbranDictionary/UrbanDictionary.cs index 2af43ba..44402d0 100644 --- a/Geekbot.net/Commands/UrbanDictionary.cs +++ b/Geekbot.net/Commands/Integrations/UbranDictionary/UrbanDictionary.cs @@ -1,14 +1,14 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; using Newtonsoft.Json; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Integrations.UbranDictionary { public class UrbanDictionary : ModuleBase { @@ -33,7 +33,7 @@ namespace Geekbot.net.Commands response.EnsureSuccessStatusCode(); var stringResponse = await response.Content.ReadAsStringAsync(); - var definitions = JsonConvert.DeserializeObject(stringResponse); + var definitions = JsonConvert.DeserializeObject(stringResponse); if (definitions.List.Count == 0) { await ReplyAsync("That word hasn't been defined..."); @@ -63,21 +63,5 @@ namespace Geekbot.net.Commands _errorHandler.HandleCommandException(e, Context); } } - - private class UrbanResponse - { - public string[] Tags { get; set; } - public List List { get; set; } - } - - private class UrbanListItem - { - public string Definition { get; set; } - public string Permalink { get; set; } - public string ThumbsUp { get; set; } - public string Word { get; set; } - public string Example { get; set; } - public string ThumbsDown { get; set; } - } } } \ No newline at end of file diff --git a/Geekbot.net/Commands/Wikipedia.cs b/Geekbot.net/Commands/Integrations/Wikipedia.cs similarity index 95% rename from Geekbot.net/Commands/Wikipedia.cs rename to Geekbot.net/Commands/Integrations/Wikipedia.cs index 05b21a6..68589f6 100644 --- a/Geekbot.net/Commands/Wikipedia.cs +++ b/Geekbot.net/Commands/Integrations/Wikipedia.cs @@ -6,12 +6,13 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; using HtmlAgilityPack; using StackExchange.Redis; using WikipediaApi; using WikipediaApi.Page; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Integrations { public class Wikipedia : ModuleBase { diff --git a/Geekbot.net/Commands/Youtube.cs b/Geekbot.net/Commands/Integrations/Youtube.cs similarity index 92% rename from Geekbot.net/Commands/Youtube.cs rename to Geekbot.net/Commands/Integrations/Youtube.cs index 305052b..f534bcd 100644 --- a/Geekbot.net/Commands/Youtube.cs +++ b/Geekbot.net/Commands/Integrations/Youtube.cs @@ -2,11 +2,12 @@ using System.Threading.Tasks; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; using Google.Apis.Services; using Google.Apis.YouTube.v3; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Integrations { public class Youtube : ModuleBase { diff --git a/Geekbot.net/Commands/Cat.cs b/Geekbot.net/Commands/Randomness/Cat/Cat.cs similarity index 90% rename from Geekbot.net/Commands/Cat.cs rename to Geekbot.net/Commands/Randomness/Cat/Cat.cs index 0545894..88a9ce5 100644 --- a/Geekbot.net/Commands/Cat.cs +++ b/Geekbot.net/Commands/Randomness/Cat/Cat.cs @@ -1,58 +1,54 @@ -using System; -using System.Net.Http; -using System.Threading.Tasks; -using Discord; -using Discord.Commands; -using Geekbot.net.Lib; -using Newtonsoft.Json; - -namespace Geekbot.net.Commands -{ - public class Cat : ModuleBase - { - private readonly IErrorHandler _errorHandler; - - public Cat(IErrorHandler errorHandler) - { - _errorHandler = errorHandler; - } - - [Command("cat", RunMode = RunMode.Async)] - [Remarks(CommandCategories.Randomness)] - [Summary("Return a random image of a cat.")] - public async Task Say() - { - try - { - using (var client = new HttpClient()) - { - try - { - client.BaseAddress = new Uri("https://aws.random.cat"); - var response = await client.GetAsync("/meow"); - response.EnsureSuccessStatusCode(); - - var stringResponse = await response.Content.ReadAsStringAsync(); - var catFile = JsonConvert.DeserializeObject(stringResponse); - var eb = new EmbedBuilder(); - eb.ImageUrl = catFile.File; - await ReplyAsync("", false, eb.Build()); - } - catch - { - await ReplyAsync("Seems like the dog cought the cat (error occured)"); - } - } - } - catch (Exception e) - { - _errorHandler.HandleCommandException(e, Context); - } - } - - private class CatResponse - { - public string File { get; set; } - } - } +using System; +using System.Net.Http; +using System.Threading.Tasks; +using Discord; +using Discord.Commands; +using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; +using Newtonsoft.Json; + +namespace Geekbot.net.Commands.Randomness.Cat +{ + public class Cat : ModuleBase + { + private readonly IErrorHandler _errorHandler; + + public Cat(IErrorHandler errorHandler) + { + _errorHandler = errorHandler; + } + + [Command("cat", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Randomness)] + [Summary("Return a random image of a cat.")] + public async Task Say() + { + try + { + using (var client = new HttpClient()) + { + try + { + client.BaseAddress = new Uri("https://aws.random.cat"); + var response = await client.GetAsync("/meow"); + response.EnsureSuccessStatusCode(); + + var stringResponse = await response.Content.ReadAsStringAsync(); + var catFile = JsonConvert.DeserializeObject(stringResponse); + var eb = new EmbedBuilder(); + eb.ImageUrl = catFile.File; + await ReplyAsync("", false, eb.Build()); + } + catch + { + await ReplyAsync("Seems like the dog cought the cat (error occured)"); + } + } + } + catch (Exception e) + { + _errorHandler.HandleCommandException(e, Context); + } + } + } } \ No newline at end of file diff --git a/Geekbot.net/Commands/Randomness/Cat/CatResponseDto.cs b/Geekbot.net/Commands/Randomness/Cat/CatResponseDto.cs new file mode 100644 index 0000000..05ebf2b --- /dev/null +++ b/Geekbot.net/Commands/Randomness/Cat/CatResponseDto.cs @@ -0,0 +1,7 @@ +namespace Geekbot.net.Commands.Randomness.Cat +{ + internal class CatResponseDto + { + public string File { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/CheckEm.cs b/Geekbot.net/Commands/Randomness/CheckEm.cs similarity index 93% rename from Geekbot.net/Commands/CheckEm.cs rename to Geekbot.net/Commands/Randomness/CheckEm.cs index 67df682..fc962cc 100644 --- a/Geekbot.net/Commands/CheckEm.cs +++ b/Geekbot.net/Commands/Randomness/CheckEm.cs @@ -1,72 +1,73 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; -using Discord.Commands; -using Geekbot.net.Lib; -using Geekbot.net.Lib.Media; - -namespace Geekbot.net.Commands -{ - public class CheckEm : ModuleBase - { - private readonly IMediaProvider _checkEmImages; - private readonly IErrorHandler _errorHandler; - - public CheckEm(IMediaProvider mediaProvider, IErrorHandler errorHandler) - { - _checkEmImages = mediaProvider; - _errorHandler = errorHandler; - } - - [Command("checkem", RunMode = RunMode.Async)] - [Remarks(CommandCategories.Randomness)] - [Summary("Check for dubs")] - public async Task MuhDubs() - { - try - { - var number = new Random().Next(10000000, 99999999); - var dubtriqua = ""; - - var ns = GetIntArray(number); - if (ns[7] == ns[6]) - { - dubtriqua = "DUBS"; - if (ns[6] == ns[5]) - { - dubtriqua = "TRIPS"; - if (ns[5] == ns[4]) - dubtriqua = "QUADS"; - } - } - - var sb = new StringBuilder(); - sb.AppendLine($"Check em {Context.User.Mention}"); - sb.AppendLine($"**{number}**"); - if (!string.IsNullOrEmpty(dubtriqua)) - sb.AppendLine($":tada: {dubtriqua} :tada:"); - sb.AppendLine(_checkEmImages.GetCheckem()); - - await ReplyAsync(sb.ToString()); - } - catch (Exception e) - { - _errorHandler.HandleCommandException(e, Context); - } - } - - private int[] GetIntArray(int num) - { - var listOfInts = new List(); - while (num > 0) - { - listOfInts.Add(num % 10); - num = num / 10; - } - - listOfInts.Reverse(); - return listOfInts.ToArray(); - } - } +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Discord.Commands; +using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.Media; + +namespace Geekbot.net.Commands.Randomness +{ + public class CheckEm : ModuleBase + { + private readonly IMediaProvider _checkEmImages; + private readonly IErrorHandler _errorHandler; + + public CheckEm(IMediaProvider mediaProvider, IErrorHandler errorHandler) + { + _checkEmImages = mediaProvider; + _errorHandler = errorHandler; + } + + [Command("checkem", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Randomness)] + [Summary("Check for dubs")] + public async Task MuhDubs() + { + try + { + var number = new Random().Next(10000000, 99999999); + var dubtriqua = ""; + + var ns = GetIntArray(number); + if (ns[7] == ns[6]) + { + dubtriqua = "DUBS"; + if (ns[6] == ns[5]) + { + dubtriqua = "TRIPS"; + if (ns[5] == ns[4]) + dubtriqua = "QUADS"; + } + } + + var sb = new StringBuilder(); + sb.AppendLine($"Check em {Context.User.Mention}"); + sb.AppendLine($"**{number}**"); + if (!string.IsNullOrEmpty(dubtriqua)) + sb.AppendLine($":tada: {dubtriqua} :tada:"); + sb.AppendLine(_checkEmImages.GetCheckem()); + + await ReplyAsync(sb.ToString()); + } + catch (Exception e) + { + _errorHandler.HandleCommandException(e, Context); + } + } + + private int[] GetIntArray(int num) + { + var listOfInts = new List(); + while (num > 0) + { + listOfInts.Add(num % 10); + num = num / 10; + } + + listOfInts.Reverse(); + return listOfInts.ToArray(); + } + } } \ No newline at end of file diff --git a/Geekbot.net/Commands/Randomness/Chuck/ChuckNorrisJokeResponseDto.cs b/Geekbot.net/Commands/Randomness/Chuck/ChuckNorrisJokeResponseDto.cs new file mode 100644 index 0000000..8d513b8 --- /dev/null +++ b/Geekbot.net/Commands/Randomness/Chuck/ChuckNorrisJokeResponseDto.cs @@ -0,0 +1,7 @@ +namespace Geekbot.net.Commands.Randomness.Chuck +{ + internal class ChuckNorrisJokeResponseDto + { + public string Value { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/ChuckNorrisJokes.cs b/Geekbot.net/Commands/Randomness/Chuck/ChuckNorrisJokes.cs similarity index 87% rename from Geekbot.net/Commands/ChuckNorrisJokes.cs rename to Geekbot.net/Commands/Randomness/Chuck/ChuckNorrisJokes.cs index 1c3b009..6ff2255 100644 --- a/Geekbot.net/Commands/ChuckNorrisJokes.cs +++ b/Geekbot.net/Commands/Randomness/Chuck/ChuckNorrisJokes.cs @@ -4,9 +4,10 @@ using System.Net.Http.Headers; using System.Threading.Tasks; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; using Newtonsoft.Json; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Randomness.Chuck { public class ChuckNorrisJokes : ModuleBase { @@ -34,7 +35,7 @@ namespace Geekbot.net.Commands response.EnsureSuccessStatusCode(); var stringResponse = await response.Content.ReadAsStringAsync(); - var data = JsonConvert.DeserializeObject(stringResponse); + var data = JsonConvert.DeserializeObject(stringResponse); await ReplyAsync(data.Value); } catch (HttpRequestException) @@ -48,10 +49,5 @@ namespace Geekbot.net.Commands _errorHandler.HandleCommandException(e, Context); } } - - private class ChuckNorrisJokeResponse - { - public string Value { get; set; } - } } } \ No newline at end of file diff --git a/Geekbot.net/Commands/Randomness/Dad/DadJokeResponseDto.cs b/Geekbot.net/Commands/Randomness/Dad/DadJokeResponseDto.cs new file mode 100644 index 0000000..262eee9 --- /dev/null +++ b/Geekbot.net/Commands/Randomness/Dad/DadJokeResponseDto.cs @@ -0,0 +1,7 @@ +namespace Geekbot.net.Commands.Randomness.Dad +{ + internal class DadJokeResponseDto + { + public string Joke { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/DadJokes.cs b/Geekbot.net/Commands/Randomness/Dad/DadJokes.cs similarity index 87% rename from Geekbot.net/Commands/DadJokes.cs rename to Geekbot.net/Commands/Randomness/Dad/DadJokes.cs index 897c3e0..e35798c 100644 --- a/Geekbot.net/Commands/DadJokes.cs +++ b/Geekbot.net/Commands/Randomness/Dad/DadJokes.cs @@ -4,9 +4,10 @@ using System.Net.Http.Headers; using System.Threading.Tasks; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; using Newtonsoft.Json; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Randomness.Dad { public class DadJokes : ModuleBase { @@ -34,7 +35,7 @@ namespace Geekbot.net.Commands response.EnsureSuccessStatusCode(); var stringResponse = await response.Content.ReadAsStringAsync(); - var data = JsonConvert.DeserializeObject(stringResponse); + var data = JsonConvert.DeserializeObject(stringResponse); await ReplyAsync(data.Joke); } catch (HttpRequestException) @@ -48,10 +49,5 @@ namespace Geekbot.net.Commands _errorHandler.HandleCommandException(e, Context); } } - - private class DadJokeResponse - { - public string Joke { get; set; } - } } } \ No newline at end of file diff --git a/Geekbot.net/Commands/Dog.cs b/Geekbot.net/Commands/Randomness/Dog/Dog.cs similarity index 88% rename from Geekbot.net/Commands/Dog.cs rename to Geekbot.net/Commands/Randomness/Dog/Dog.cs index 30c0301..08c1a9b 100644 --- a/Geekbot.net/Commands/Dog.cs +++ b/Geekbot.net/Commands/Randomness/Dog/Dog.cs @@ -4,9 +4,10 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; using Newtonsoft.Json; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Randomness.Dog { public class Dog : ModuleBase { @@ -33,7 +34,7 @@ namespace Geekbot.net.Commands response.EnsureSuccessStatusCode(); var stringResponse = await response.Content.ReadAsStringAsync(); - var dogFile = JsonConvert.DeserializeObject(stringResponse); + var dogFile = JsonConvert.DeserializeObject(stringResponse); var eb = new EmbedBuilder(); eb.ImageUrl = dogFile.Url; await ReplyAsync("", false, eb.Build()); @@ -49,10 +50,5 @@ namespace Geekbot.net.Commands _errorHandler.HandleCommandException(e, Context); } } - - private class DogResponse - { - public string Url { get; set; } - } } } \ No newline at end of file diff --git a/Geekbot.net/Commands/Randomness/Dog/DogResponseDto.cs b/Geekbot.net/Commands/Randomness/Dog/DogResponseDto.cs new file mode 100644 index 0000000..1fc1a82 --- /dev/null +++ b/Geekbot.net/Commands/Randomness/Dog/DogResponseDto.cs @@ -0,0 +1,7 @@ +namespace Geekbot.net.Commands.Randomness.Dog +{ + internal class DogResponseDto + { + public string Url { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/EightBall.cs b/Geekbot.net/Commands/Randomness/EightBall.cs similarity index 95% rename from Geekbot.net/Commands/EightBall.cs rename to Geekbot.net/Commands/Randomness/EightBall.cs index 94b01a1..79ba6d1 100644 --- a/Geekbot.net/Commands/EightBall.cs +++ b/Geekbot.net/Commands/Randomness/EightBall.cs @@ -3,8 +3,9 @@ using System.Collections.Generic; using System.Threading.Tasks; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Randomness { public class EightBall : ModuleBase { diff --git a/Geekbot.net/Commands/Fortune.cs b/Geekbot.net/Commands/Randomness/Fortune.cs similarity index 89% rename from Geekbot.net/Commands/Fortune.cs rename to Geekbot.net/Commands/Randomness/Fortune.cs index 1335139..abc9ce5 100644 --- a/Geekbot.net/Commands/Fortune.cs +++ b/Geekbot.net/Commands/Randomness/Fortune.cs @@ -3,7 +3,7 @@ using Discord.Commands; using Geekbot.net.Lib; using Geekbot.net.Lib.Media; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Randomness { public class Fortune : ModuleBase { diff --git a/Geekbot.net/Commands/Gdq.cs b/Geekbot.net/Commands/Randomness/Gdq.cs similarity index 89% rename from Geekbot.net/Commands/Gdq.cs rename to Geekbot.net/Commands/Randomness/Gdq.cs index fef1c96..3e17451 100644 --- a/Geekbot.net/Commands/Gdq.cs +++ b/Geekbot.net/Commands/Randomness/Gdq.cs @@ -3,8 +3,9 @@ using System.Net; using System.Threading.Tasks; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Randomness { public class Gdq : ModuleBase { diff --git a/Geekbot.net/Commands/RandomAnimals.cs b/Geekbot.net/Commands/Randomness/RandomAnimals.cs similarity index 98% rename from Geekbot.net/Commands/RandomAnimals.cs rename to Geekbot.net/Commands/Randomness/RandomAnimals.cs index 7829b21..a96aea8 100644 --- a/Geekbot.net/Commands/RandomAnimals.cs +++ b/Geekbot.net/Commands/Randomness/RandomAnimals.cs @@ -4,7 +4,7 @@ using Discord.Commands; using Geekbot.net.Lib; using Geekbot.net.Lib.Media; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Randomness { public class RandomAnimals : ModuleBase { diff --git a/Geekbot.net/Commands/Ship.cs b/Geekbot.net/Commands/Randomness/Ship.cs similarity index 94% rename from Geekbot.net/Commands/Ship.cs rename to Geekbot.net/Commands/Randomness/Ship.cs index d7dfd0e..ffa18b4 100644 --- a/Geekbot.net/Commands/Ship.cs +++ b/Geekbot.net/Commands/Randomness/Ship.cs @@ -3,9 +3,10 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Randomness { public class Ship : ModuleBase { diff --git a/Geekbot.net/Commands/Slap.cs b/Geekbot.net/Commands/Randomness/Slap.cs similarity index 94% rename from Geekbot.net/Commands/Slap.cs rename to Geekbot.net/Commands/Randomness/Slap.cs index 668d33e..129e89d 100644 --- a/Geekbot.net/Commands/Slap.cs +++ b/Geekbot.net/Commands/Randomness/Slap.cs @@ -4,9 +4,10 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Randomness { public class Slap : ModuleBase { diff --git a/Geekbot.net/Commands/GuildInfo.cs b/Geekbot.net/Commands/User/GuildInfo.cs similarity index 83% rename from Geekbot.net/Commands/GuildInfo.cs rename to Geekbot.net/Commands/User/GuildInfo.cs index 62e0fd1..6306a76 100644 --- a/Geekbot.net/Commands/GuildInfo.cs +++ b/Geekbot.net/Commands/User/GuildInfo.cs @@ -4,9 +4,11 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.Levels; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.User { public class GuildInfo : ModuleBase { @@ -51,12 +53,5 @@ namespace Geekbot.net.Commands _errorHandler.HandleCommandException(e, Context); } } - - public static string FirstCharToUpper(string input) - { - if (string.IsNullOrEmpty(input)) - throw new ArgumentException("ARGH!"); - return input.First().ToString().ToUpper() + input.Substring(1); - } } } \ No newline at end of file diff --git a/Geekbot.net/Commands/Karma.cs b/Geekbot.net/Commands/User/Karma.cs similarity index 97% rename from Geekbot.net/Commands/Karma.cs rename to Geekbot.net/Commands/User/Karma.cs index d379b06..d6244a8 100644 --- a/Geekbot.net/Commands/Karma.cs +++ b/Geekbot.net/Commands/User/Karma.cs @@ -3,9 +3,11 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.Localization; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.User { public class Karma : ModuleBase { diff --git a/Geekbot.net/Commands/Rank.cs b/Geekbot.net/Commands/User/Rank/Rank.cs similarity index 93% rename from Geekbot.net/Commands/Rank.cs rename to Geekbot.net/Commands/User/Rank/Rank.cs index 92f78bd..774ac5a 100644 --- a/Geekbot.net/Commands/Rank.cs +++ b/Geekbot.net/Commands/User/Rank/Rank.cs @@ -6,9 +6,13 @@ using System.Threading.Tasks; using Discord.Commands; using Discord.WebSocket; using Geekbot.net.Lib; +using Geekbot.net.Lib.Converters; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.Logger; +using Geekbot.net.Lib.UserRepository; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.User.Rank { public class Rank : ModuleBase { @@ -69,7 +73,7 @@ namespace Geekbot.net.Commands } if (type == "Messages") sortedList.RemoveAt(0); - var highscoreUsers = new Dictionary(); + var highscoreUsers = new Dictionary(); var listLimiter = 1; var failedToRetrieveUser = false; foreach (var user in sortedList) @@ -80,7 +84,7 @@ namespace Geekbot.net.Commands var guildUser = _userRepository.Get((ulong) user.Name); if (guildUser.Username != null) { - highscoreUsers.Add(new RankUserPolyfill + highscoreUsers.Add(new RankUserPolyfillDto { Username = guildUser.Username, Discriminator = guildUser.Discriminator @@ -88,7 +92,7 @@ namespace Geekbot.net.Commands } else { - highscoreUsers.Add(new RankUserPolyfill + highscoreUsers.Add(new RankUserPolyfillDto { Id = user.Name }, (int) user.Value); @@ -143,11 +147,4 @@ namespace Geekbot.net.Commands } } } - - internal class RankUserPolyfill - { - public string Username { get; set; } - public string Discriminator { get; set; } - public string Id { get; set; } - } } \ No newline at end of file diff --git a/Geekbot.net/Commands/User/Rank/RankUserPolyfillDto.cs b/Geekbot.net/Commands/User/Rank/RankUserPolyfillDto.cs new file mode 100644 index 0000000..f666ffc --- /dev/null +++ b/Geekbot.net/Commands/User/Rank/RankUserPolyfillDto.cs @@ -0,0 +1,9 @@ +namespace Geekbot.net.Commands.User.Rank +{ + internal class RankUserPolyfillDto + { + public string Username { get; set; } + public string Discriminator { get; set; } + public string Id { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/Stats.cs b/Geekbot.net/Commands/User/Stats.cs similarity index 96% rename from Geekbot.net/Commands/Stats.cs rename to Geekbot.net/Commands/User/Stats.cs index 67b76b9..19a6aa8 100644 --- a/Geekbot.net/Commands/Stats.cs +++ b/Geekbot.net/Commands/User/Stats.cs @@ -3,9 +3,11 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.Levels; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.User { public class Stats : ModuleBase { diff --git a/Geekbot.net/Commands/AvatarGetter.cs b/Geekbot.net/Commands/Utils/AvatarGetter.cs similarity index 89% rename from Geekbot.net/Commands/AvatarGetter.cs rename to Geekbot.net/Commands/Utils/AvatarGetter.cs index d8a04e9..d42c779 100644 --- a/Geekbot.net/Commands/AvatarGetter.cs +++ b/Geekbot.net/Commands/Utils/AvatarGetter.cs @@ -3,8 +3,9 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Utils { public class AvatarGetter : ModuleBase { diff --git a/Geekbot.net/Commands/Changelog.cs b/Geekbot.net/Commands/Utils/Changelog/Changelog.cs similarity index 82% rename from Geekbot.net/Commands/Changelog.cs rename to Geekbot.net/Commands/Utils/Changelog/Changelog.cs index 70c4c17..f956d7c 100644 --- a/Geekbot.net/Commands/Changelog.cs +++ b/Geekbot.net/Commands/Utils/Changelog/Changelog.cs @@ -8,9 +8,10 @@ using Discord; using Discord.Commands; using Discord.WebSocket; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; using Newtonsoft.Json; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Utils.Changelog { public class Changelog : ModuleBase { @@ -51,7 +52,7 @@ namespace Geekbot.net.Commands }); var sb = new StringBuilder(); foreach (var commit in commits.Take(10)) - sb.AppendLine($"- {commit.Commit.Message} ({commit.Commit.Author.Date:yyyy-MM-dd})"); + sb.AppendLine($"- {commit.Commit.Message} ({commit.Commit.AuthorDto.Date:yyyy-MM-dd})"); eb.Description = sb.ToString(); eb.WithFooter(new EmbedFooterBuilder { @@ -65,21 +66,5 @@ namespace Geekbot.net.Commands _errorHandler.HandleCommandException(e, Context); } } - - private class CommitDto - { - public CommitInfo Commit { get; set; } - } - - private class CommitInfo - { - public CommitAuthor Author { get; set; } - public string Message { get; set; } - } - - private class CommitAuthor - { - public DateTimeOffset Date { get; set; } - } } } \ No newline at end of file diff --git a/Geekbot.net/Commands/Utils/Changelog/CommitAuthorDto.cs b/Geekbot.net/Commands/Utils/Changelog/CommitAuthorDto.cs new file mode 100644 index 0000000..ad37311 --- /dev/null +++ b/Geekbot.net/Commands/Utils/Changelog/CommitAuthorDto.cs @@ -0,0 +1,9 @@ +using System; + +namespace Geekbot.net.Commands.Utils.Changelog +{ + internal class CommitAuthorDto + { + public DateTimeOffset Date { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/Utils/Changelog/CommitDto.cs b/Geekbot.net/Commands/Utils/Changelog/CommitDto.cs new file mode 100644 index 0000000..d5c5bab --- /dev/null +++ b/Geekbot.net/Commands/Utils/Changelog/CommitDto.cs @@ -0,0 +1,7 @@ +namespace Geekbot.net.Commands.Utils.Changelog +{ + internal class CommitDto + { + public CommitInfoDto Commit { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/Utils/Changelog/CommitInfoDto.cs b/Geekbot.net/Commands/Utils/Changelog/CommitInfoDto.cs new file mode 100644 index 0000000..102d2cd --- /dev/null +++ b/Geekbot.net/Commands/Utils/Changelog/CommitInfoDto.cs @@ -0,0 +1,8 @@ +namespace Geekbot.net.Commands.Utils.Changelog +{ + internal class CommitInfoDto + { + public CommitAuthorDto AuthorDto { get; set; } + public string Message { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/Choose.cs b/Geekbot.net/Commands/Utils/Choose.cs similarity index 88% rename from Geekbot.net/Commands/Choose.cs rename to Geekbot.net/Commands/Utils/Choose.cs index a726741..4d54654 100644 --- a/Geekbot.net/Commands/Choose.cs +++ b/Geekbot.net/Commands/Utils/Choose.cs @@ -2,8 +2,10 @@ using System.Threading.Tasks; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.Localization; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Utils { public class Choose : ModuleBase { diff --git a/Geekbot.net/Commands/Dice.cs b/Geekbot.net/Commands/Utils/Dice/Dice.cs similarity index 93% rename from Geekbot.net/Commands/Dice.cs rename to Geekbot.net/Commands/Utils/Dice/Dice.cs index 89b3a11..7fc4f84 100644 --- a/Geekbot.net/Commands/Dice.cs +++ b/Geekbot.net/Commands/Utils/Dice/Dice.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Discord.Commands; using Geekbot.net.Lib; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Utils.Dice { public class Dice : ModuleBase { @@ -112,12 +112,4 @@ namespace Geekbot.net.Commands return new DiceTypeDto(); } } - - internal class DiceTypeDto - { - public string DiceType { get; set; } - public int Times { get; set; } - public int Sides { get; set; } - public int Mod { get; set; } - } } \ No newline at end of file diff --git a/Geekbot.net/Commands/Utils/Dice/DiceTypeDto.cs b/Geekbot.net/Commands/Utils/Dice/DiceTypeDto.cs new file mode 100644 index 0000000..5c54792 --- /dev/null +++ b/Geekbot.net/Commands/Utils/Dice/DiceTypeDto.cs @@ -0,0 +1,10 @@ +namespace Geekbot.net.Commands.Utils.Dice +{ + internal class DiceTypeDto + { + public string DiceType { get; set; } + public int Times { get; set; } + public int Sides { get; set; } + public int Mod { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/Emojify.cs b/Geekbot.net/Commands/Utils/Emojify.cs similarity index 89% rename from Geekbot.net/Commands/Emojify.cs rename to Geekbot.net/Commands/Utils/Emojify.cs index 739a4dc..57363c2 100644 --- a/Geekbot.net/Commands/Emojify.cs +++ b/Geekbot.net/Commands/Utils/Emojify.cs @@ -2,8 +2,10 @@ using System.Threading.Tasks; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.Converters; +using Geekbot.net.Lib.ErrorHandling; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Utils { public class Emojify : ModuleBase { diff --git a/Geekbot.net/Commands/Help.cs b/Geekbot.net/Commands/Utils/Help.cs similarity index 93% rename from Geekbot.net/Commands/Help.cs rename to Geekbot.net/Commands/Utils/Help.cs index 1b3e285..be9a747 100644 --- a/Geekbot.net/Commands/Help.cs +++ b/Geekbot.net/Commands/Utils/Help.cs @@ -4,8 +4,9 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Utils { public class Help : ModuleBase { diff --git a/Geekbot.net/Commands/Info.cs b/Geekbot.net/Commands/Utils/Info.cs similarity index 94% rename from Geekbot.net/Commands/Info.cs rename to Geekbot.net/Commands/Utils/Info.cs index e8c35dc..446abfe 100644 --- a/Geekbot.net/Commands/Info.cs +++ b/Geekbot.net/Commands/Utils/Info.cs @@ -6,9 +6,10 @@ using Discord; using Discord.Commands; using Discord.WebSocket; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Utils { public class Info : ModuleBase { diff --git a/Geekbot.net/Commands/Ping.cs b/Geekbot.net/Commands/Utils/Ping.cs similarity index 91% rename from Geekbot.net/Commands/Ping.cs rename to Geekbot.net/Commands/Utils/Ping.cs index c41700e..226e9a3 100644 --- a/Geekbot.net/Commands/Ping.cs +++ b/Geekbot.net/Commands/Utils/Ping.cs @@ -2,7 +2,7 @@ using Discord.Commands; using Geekbot.net.Lib; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Utils { public class Ping : ModuleBase { diff --git a/Geekbot.net/Commands/Poll.cs b/Geekbot.net/Commands/Utils/Poll/Poll.cs similarity index 85% rename from Geekbot.net/Commands/Poll.cs rename to Geekbot.net/Commands/Utils/Poll/Poll.cs index cf80835..5d18a0f 100644 --- a/Geekbot.net/Commands/Poll.cs +++ b/Geekbot.net/Commands/Utils/Poll/Poll.cs @@ -6,10 +6,13 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.Converters; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.UserRepository; using Newtonsoft.Json; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Utils.Poll { [Group("poll")] public class Poll : ModuleBase @@ -92,7 +95,7 @@ namespace Geekbot.net.Commands pollMessage.AddReactionAsync(new Emoji(_emojiConverter.NumberToEmoji(i))); i++; }); - var poll = new PollData + var poll = new PollDataDto { Creator = Context.User.Id, MessageId = pollMessage.Id, @@ -139,28 +142,28 @@ namespace Geekbot.net.Commands } } - private PollData GetCurrentPoll() + private PollDataDto GetCurrentPoll() { try { var currentPoll = _redis.HashGet($"{Context.Guild.Id}:Polls", Context.Channel.Id); - return JsonConvert.DeserializeObject(currentPoll.ToString()); + return JsonConvert.DeserializeObject(currentPoll.ToString()); } catch { - return new PollData(); + return new PollDataDto(); } } - private async Task> GetPollResults(PollData poll) + private async Task> GetPollResults(PollDataDto poll) { var message = (IUserMessage) await Context.Channel.GetMessageAsync(poll.MessageId); - var results = new List(); + var results = new List(); foreach (var r in message.Reactions) try { var option = int.Parse(r.Key.Name.ToCharArray()[0].ToString()); - var result = new PollResult + var result = new PollResultDto { Option = poll.Options[option - 1], VoteCount = r.Value.ReactionCount @@ -172,20 +175,5 @@ namespace Geekbot.net.Commands results.Sort((x, y) => y.VoteCount.CompareTo(x.VoteCount)); return results; } - - private class PollData - { - public ulong Creator { get; set; } - public ulong MessageId { get; set; } - public bool IsFinshed { get; set; } - public string Question { get; set; } - public List Options { get; set; } - } - - private class PollResult - { - public string Option { get; set; } - public int VoteCount { get; set; } - } } } \ No newline at end of file diff --git a/Geekbot.net/Commands/Utils/Poll/PollDataDto.cs b/Geekbot.net/Commands/Utils/Poll/PollDataDto.cs new file mode 100644 index 0000000..3d21479 --- /dev/null +++ b/Geekbot.net/Commands/Utils/Poll/PollDataDto.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; + +namespace Geekbot.net.Commands.Utils.Poll +{ + internal class PollDataDto + { + public ulong Creator { get; set; } + public ulong MessageId { get; set; } + public bool IsFinshed { get; set; } + public string Question { get; set; } + public List Options { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/Utils/Poll/PollResultDto.cs b/Geekbot.net/Commands/Utils/Poll/PollResultDto.cs new file mode 100644 index 0000000..b4f14a2 --- /dev/null +++ b/Geekbot.net/Commands/Utils/Poll/PollResultDto.cs @@ -0,0 +1,8 @@ +namespace Geekbot.net.Commands.Utils.Poll +{ + internal class PollResultDto + { + public string Option { get; set; } + public int VoteCount { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/Quote.cs b/Geekbot.net/Commands/Utils/Quote/Quote.cs similarity index 94% rename from Geekbot.net/Commands/Quote.cs rename to Geekbot.net/Commands/Utils/Quote/Quote.cs index 4b4cfc3..f1941ba 100644 --- a/Geekbot.net/Commands/Quote.cs +++ b/Geekbot.net/Commands/Utils/Quote/Quote.cs @@ -4,10 +4,11 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Geekbot.net.Lib; +using Geekbot.net.Lib.ErrorHandling; using Newtonsoft.Json; using StackExchange.Redis; -namespace Geekbot.net.Commands +namespace Geekbot.net.Commands.Utils.Quote { [Group("quote")] public class Quote : ModuleBase @@ -31,7 +32,7 @@ namespace Geekbot.net.Commands var randomQuotes = _redis.SetMembers($"{Context.Guild.Id}:Quotes"); var randomNumber = new Random().Next(randomQuotes.Length - 1); var randomQuote = randomQuotes[randomNumber]; - var quote = JsonConvert.DeserializeObject(randomQuote); + var quote = JsonConvert.DeserializeObject(randomQuote); var embed = QuoteBuilder(quote, randomNumber + 1); await ReplyAsync("", false, embed.Build()); } @@ -159,7 +160,7 @@ namespace Geekbot.net.Commands var success = _redis.SetRemove($"{Context.Guild.Id}:Quotes", quotes[id - 1]); if (success) { - var quote = JsonConvert.DeserializeObject(quotes[id - 1]); + var quote = JsonConvert.DeserializeObject(quotes[id - 1]); var embed = QuoteBuilder(quote); await ReplyAsync($"**Removed #{id}**", false, embed.Build()); } @@ -186,7 +187,7 @@ namespace Geekbot.net.Commands && !msg.Content.ToLower().StartsWith("!")); } - private EmbedBuilder QuoteBuilder(QuoteObject quote, int id = 0) + private EmbedBuilder QuoteBuilder(QuoteObjectDto quote, int id = 0) { var user = Context.Client.GetUserAsync(quote.UserId).Result; var eb = new EmbedBuilder(); @@ -199,7 +200,7 @@ namespace Geekbot.net.Commands return eb; } - private QuoteObject CreateQuoteObject(IMessage message) + private QuoteObjectDto CreateQuoteObject(IMessage message) { string image; try @@ -211,7 +212,7 @@ namespace Geekbot.net.Commands image = null; } - return new QuoteObject + return new QuoteObjectDto { UserId = message.Author.Id, Time = message.Timestamp.DateTime, @@ -220,12 +221,4 @@ namespace Geekbot.net.Commands }; } } - - public class QuoteObject - { - public ulong UserId { get; set; } - public string Quote { get; set; } - public DateTime Time { get; set; } - public string Image { get; set; } - } } \ No newline at end of file diff --git a/Geekbot.net/Commands/Utils/Quote/QuoteObjectDto.cs b/Geekbot.net/Commands/Utils/Quote/QuoteObjectDto.cs new file mode 100644 index 0000000..a37ff76 --- /dev/null +++ b/Geekbot.net/Commands/Utils/Quote/QuoteObjectDto.cs @@ -0,0 +1,12 @@ +using System; + +namespace Geekbot.net.Commands.Utils.Quote +{ + internal class QuoteObjectDto + { + public ulong UserId { get; set; } + public string Quote { get; set; } + public DateTime Time { get; set; } + public string Image { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Commands/Voice.cs b/Geekbot.net/Commands/Voice.cs deleted file mode 100644 index ca65913..0000000 --- a/Geekbot.net/Commands/Voice.cs +++ /dev/null @@ -1,102 +0,0 @@ -//using System; -//using System.IO; -//using System.Threading.Tasks; -//using Discord; -//using Discord.Commands; -//using Geekbot.net.Lib; -// -//namespace Geekbot.net.Commands -//{ -// public class Voice : ModuleBase -// { -// private readonly IAudioUtils _audioUtils; -// private readonly IErrorHandler _errorHandler; -// -// public Voice(IErrorHandler errorHandler, IAudioUtils audioUtils) -// { -// _errorHandler = errorHandler; -// _audioUtils = audioUtils; -// } -// -// [Command("join")] -// public async Task JoinChannel() -// { -// try -// { -// // Get the audio channel -// var channel = (Context.User as IGuildUser)?.VoiceChannel; -// if (channel == null) -// { -// await Context.Channel.SendMessageAsync( -// "User must be in a voice channel, or a voice channel must be passed as an argument."); -// return; -// } -// -// // For the next step with transmitting audio, you would want to pass this Audio Client in to a service. -// var audioClient = await channel.ConnectAsync(); -// _audioUtils.StoreAudioClient(Context.Guild.Id, audioClient); -// await ReplyAsync($"Connected to {channel.Name}"); -// } -// catch (Exception e) -// { -// _errorHandler.HandleCommandException(e, Context); -// } -// } -// -// [Command("disconnect")] -// public async Task DisconnectChannel() -// { -// try -// { -// var audioClient = _audioUtils.GetAudioClient(Context.Guild.Id); -// if (audioClient == null) -// { -// await Context.Channel.SendMessageAsync("I'm not in a voice channel at the moment"); -// return; -// } -// -// await audioClient.StopAsync(); -// await ReplyAsync("Disconnected from channel!"); -// _audioUtils.Cleanup(Context.Guild.Id); -// } -// catch (Exception e) -// { -// _errorHandler.HandleCommandException(e, Context); -// _audioUtils.Cleanup(Context.Guild.Id); -// } -// } -// -// [Command("ytplay")] -// public async Task ytplay(string url) -// { -// try -// { -// if (!url.Contains("youtube")) -// { -// await ReplyAsync("I can only play youtube videos"); -// return; -// } -// var audioClient = _audioUtils.GetAudioClient(Context.Guild.Id); -// if (audioClient == null) -// { -// await ReplyAsync("I'm not in a voice channel at the moment"); -// return; -// } -// -// var message = await Context.Channel.SendMessageAsync("Just a second, i'm still a bit slow at this"); -// var ffmpeg = _audioUtils.CreateStreamFromYoutube(url, Context.Guild.Id); -// var output = ffmpeg.StandardOutput.BaseStream; -// await message.ModifyAsync(msg => msg.Content = "**Playing!** Please note that this feature is experimental"); -// var discord = audioClient.CreatePCMStream(Discord.Audio.AudioApplication.Mixed); -// await output.CopyToAsync(discord); -// await discord.FlushAsync(); -// _audioUtils.Cleanup(Context.Guild.Id); -// } -// catch (Exception e) -// { -// _errorHandler.HandleCommandException(e, Context); -// _audioUtils.Cleanup(Context.Guild.Id); -// } -// } -// } -//} \ No newline at end of file diff --git a/Geekbot.net/Geekbot.net.csproj b/Geekbot.net/Geekbot.net.csproj index ba9faed..5cba28a 100755 --- a/Geekbot.net/Geekbot.net.csproj +++ b/Geekbot.net/Geekbot.net.csproj @@ -63,9 +63,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest @@ -75,6 +72,12 @@ PreserveNewest + + Always + + + Always + diff --git a/Geekbot.net/Handlers.cs b/Geekbot.net/Handlers.cs index 31608b2..7d1523b 100644 --- a/Geekbot.net/Handlers.cs +++ b/Geekbot.net/Handlers.cs @@ -4,7 +4,9 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; using Discord.WebSocket; -using Geekbot.net.Lib; +using Geekbot.net.Lib.Logger; +using Geekbot.net.Lib.ReactionListener; +using Geekbot.net.Lib.UserRepository; using StackExchange.Redis; namespace Geekbot.net @@ -89,7 +91,6 @@ namespace Geekbot.net if (message.Author.IsBot) return Task.CompletedTask; _logger.Information("Message", message.Content, SimpleConextConverter.ConvertSocketMessage(message)); -// _logger.Information($"[Message] {channel.Guild.Name} ({channel.Guild.Id}) - {message.Channel} ({message.Channel.Id}) - {message.Author.Username}#{message.Author.Discriminator} ({message.Author.Id}) - {message.Content}"); } catch (Exception e) { diff --git a/Geekbot.net/Lib/Clients/IMalClient.cs b/Geekbot.net/Lib/Clients/IMalClient.cs new file mode 100644 index 0000000..f59c511 --- /dev/null +++ b/Geekbot.net/Lib/Clients/IMalClient.cs @@ -0,0 +1,12 @@ +using System.Threading.Tasks; +using MyAnimeListSharp.Core; + +namespace Geekbot.net.Lib.Clients +{ + public interface IMalClient + { + bool IsLoggedIn(); + Task GetAnime(string query); + Task GetManga(string query); + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/MalClient.cs b/Geekbot.net/Lib/Clients/MalClient.cs similarity index 89% rename from Geekbot.net/Lib/MalClient.cs rename to Geekbot.net/Lib/Clients/MalClient.cs index dcf4fe3..d8bfe41 100644 --- a/Geekbot.net/Lib/MalClient.cs +++ b/Geekbot.net/Lib/Clients/MalClient.cs @@ -1,10 +1,11 @@ using System.Threading.Tasks; +using Geekbot.net.Lib.Logger; using MyAnimeListSharp.Auth; using MyAnimeListSharp.Core; using MyAnimeListSharp.Facade.Async; using StackExchange.Redis; -namespace Geekbot.net.Lib +namespace Geekbot.net.Lib.Clients { public class MalClient : IMalClient { @@ -66,11 +67,4 @@ namespace Geekbot.net.Lib return response.Entries.Count == 0 ? null : response.Entries[0]; } } - - public interface IMalClient - { - bool IsLoggedIn(); - Task GetAnime(string query); - Task GetManga(string query); - } } \ No newline at end of file diff --git a/Geekbot.net/Lib/EmojiConverter.cs b/Geekbot.net/Lib/Converters/EmojiConverter.cs similarity index 92% rename from Geekbot.net/Lib/EmojiConverter.cs rename to Geekbot.net/Lib/Converters/EmojiConverter.cs index b836485..06f1aa8 100644 --- a/Geekbot.net/Lib/EmojiConverter.cs +++ b/Geekbot.net/Lib/Converters/EmojiConverter.cs @@ -1,7 +1,7 @@ using System.Collections; using System.Text; -namespace Geekbot.net.Lib +namespace Geekbot.net.Lib.Converters { public class EmojiConverter : IEmojiConverter { @@ -90,10 +90,4 @@ namespace Geekbot.net.Lib return returnString.ToString(); } } - - public interface IEmojiConverter - { - string NumberToEmoji(int number); - string TextToEmoji(string text); - } } \ No newline at end of file diff --git a/Geekbot.net/Lib/Converters/IEmojiConverter.cs b/Geekbot.net/Lib/Converters/IEmojiConverter.cs new file mode 100644 index 0000000..b0f666f --- /dev/null +++ b/Geekbot.net/Lib/Converters/IEmojiConverter.cs @@ -0,0 +1,8 @@ +namespace Geekbot.net.Lib.Converters +{ + public interface IEmojiConverter + { + string NumberToEmoji(int number); + string TextToEmoji(string text); + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/Converters/IMtgManaConverter.cs b/Geekbot.net/Lib/Converters/IMtgManaConverter.cs new file mode 100644 index 0000000..d558f09 --- /dev/null +++ b/Geekbot.net/Lib/Converters/IMtgManaConverter.cs @@ -0,0 +1,7 @@ +namespace Geekbot.net.Lib.Converters +{ + public interface IMtgManaConverter + { + string ConvertMana(string mana); + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/Converters/MtgManaConverter.cs b/Geekbot.net/Lib/Converters/MtgManaConverter.cs new file mode 100644 index 0000000..c29e1e0 --- /dev/null +++ b/Geekbot.net/Lib/Converters/MtgManaConverter.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; +using System.IO; +using System.Text.RegularExpressions; +using Utf8Json; + +namespace Geekbot.net.Lib.Converters +{ + public class MtgManaConverter : IMtgManaConverter + { + private Dictionary _manaDict; + + public MtgManaConverter() + { + // these emotes can be found at https://discord.gg/bz8HyA7 + var mtgEmojis = File.ReadAllText(Path.GetFullPath("./Lib/Converters/MtgManaEmojis.json")); + _manaDict = JsonSerializer.Deserialize>(mtgEmojis); + } + + public string ConvertMana(string mana) + { + var rgx = Regex.Matches(mana, @"(\{(.*?)\})"); + foreach (Match manaTypes in rgx) + { + var m = _manaDict.GetValueOrDefault(manaTypes.Value); + if (!string.IsNullOrEmpty(m)) + { + mana = mana.Replace(manaTypes.Value, m); + } + } + return mana; + } + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/Converters/MtgManaEmojis.json b/Geekbot.net/Lib/Converters/MtgManaEmojis.json new file mode 100644 index 0000000..8ebe75b --- /dev/null +++ b/Geekbot.net/Lib/Converters/MtgManaEmojis.json @@ -0,0 +1,50 @@ +{ + "{0}": "<:mtg_0:415216130043412482>", + "{1}": "<:mtg_1:415216130253389835>", + "{2}": "<:mtg_2:415216130031091713>", + "{3}": "<:mtg_3:415216130467037194>", + "{4}": "<:mtg_4:415216130026635295>", + "{5}": "<:mtg_5:415216130492203008>", + "{6}": "<:mtg_6:415216130458779658>", + "{7}": "<:mtg_7:415216130190475265>", + "{8}": "<:mtg_8:415216130517630986>", + "{9}": "<:mtg_9:415216130500722689>", + "{10": "<:mtg_10:415216130450391051>", + "{11}": "<:mtg_11:415216130811101185>", + "{12}": "<:mtg_12:415216130525888532>", + "{13}": "<:mtg_13:415216130517631000>", + "{14}": "<:mtg_14:415216130165178370>", + "{15}": "<:mtg_15:415216130576089108>", + "{16}": "<:mtg_16:415216130358247425>", + "{17}": "<:mtg_17:415216130601517056>", + "{18}": "<:mtg_18:415216130462842891>", + "{19}": "<:mtg_19:415216130614099988>", + "{20}": "<:mtg_20:415216130656043038>", + "{W}": "<:mtg_white:415216131515744256>", + "{U}": "<:mtg_blue:415216130521694209>", + "{B}": "<:mtg_black:415216130873884683>", + "{R}": "<:mtg_red:415216131322806272>", + "{G}": "<:mtg_green:415216131180331009>", + "{S}": "<:mtg_s:415216131293446144>", + "{T}": "<:mtg_tap:415258392727257088>", + "{C}": "<:mtg_colorless:415216130706374666>", + "{2/W}": "<:mtg_2w:415216130446065664>", + "{2/U}": "<:mtg_2u:415216130429550592>", + "{2/B}": "<:mtg_2b:415216130160984065>", + "{2/R}": "<:mtg_2r:415216130454716436>", + "{2/G}": "<:mtg_2g:415216130420899840>", + "{W/U}": "<:mtg_wu:415216130970484736>", + "{W/B}": "<:mtg_wb:415216131222011914>", + "{U/R}": "<:mtg_ur:415216130962096128>", + "{U/B}": "<:mtg_ub:415216130865758218>", + "{R/W}": "<:mtg_rw:415216130878210057>", + "{G/W}": "<:mtg_gw:415216130567962646>", + "{G/U}": "<:mtg_gu:415216130739666945>", + "{B/R}": "<:mtg_br:415216130580283394>", + "{B/G}": "<:mtg_bg:415216130781609994>", + "{U/P}": "<:mtg_up:415216130861432842>", + "{R/P}": "<:mtg_rp:415216130597322783>", + "{G/P}": "<:mtg_gp:415216130760769546>", + "{W/P}": "<:mtg_wp:415216131541041172>", + "{B/P}": "<:mtg_bp:415216130664169482>" +} \ No newline at end of file diff --git a/Geekbot.net/Lib/ErrorHandler.cs b/Geekbot.net/Lib/ErrorHandling/ErrorHandler.cs similarity index 93% rename from Geekbot.net/Lib/ErrorHandler.cs rename to Geekbot.net/Lib/ErrorHandling/ErrorHandler.cs index 9bf99f4..3d53242 100644 --- a/Geekbot.net/Lib/ErrorHandler.cs +++ b/Geekbot.net/Lib/ErrorHandling/ErrorHandler.cs @@ -2,10 +2,12 @@ using System.Net; using Discord.Commands; using Discord.Net; +using Geekbot.net.Lib.Localization; +using Geekbot.net.Lib.Logger; using SharpRaven; using SharpRaven.Data; -namespace Geekbot.net.Lib +namespace Geekbot.net.Lib.ErrorHandling { public class ErrorHandler : IErrorHandler { @@ -90,10 +92,4 @@ namespace Geekbot.net.Lib } - - public interface IErrorHandler - { - void HandleCommandException(Exception e, ICommandContext context, string errorMessage = "def"); - void HandleHttpException(HttpException e, ICommandContext context); - } } \ No newline at end of file diff --git a/Geekbot.net/Lib/ErrorHandling/IErrorHandler.cs b/Geekbot.net/Lib/ErrorHandling/IErrorHandler.cs new file mode 100644 index 0000000..f2d8dac --- /dev/null +++ b/Geekbot.net/Lib/ErrorHandling/IErrorHandler.cs @@ -0,0 +1,12 @@ +using System; +using Discord.Commands; +using Discord.Net; + +namespace Geekbot.net.Lib.ErrorHandling +{ + public interface IErrorHandler + { + void HandleCommandException(Exception e, ICommandContext context, string errorMessage = "def"); + void HandleHttpException(HttpException e, ICommandContext context); + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/Levels/ILevelCalc.cs b/Geekbot.net/Lib/Levels/ILevelCalc.cs new file mode 100644 index 0000000..6353132 --- /dev/null +++ b/Geekbot.net/Lib/Levels/ILevelCalc.cs @@ -0,0 +1,7 @@ +namespace Geekbot.net.Lib.Levels +{ + public interface ILevelCalc + { + int GetLevel(int experience); + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/LevelCalc.cs b/Geekbot.net/Lib/Levels/LevelCalc.cs similarity index 87% rename from Geekbot.net/Lib/LevelCalc.cs rename to Geekbot.net/Lib/Levels/LevelCalc.cs index 75df83d..9ecf803 100644 --- a/Geekbot.net/Lib/LevelCalc.cs +++ b/Geekbot.net/Lib/Levels/LevelCalc.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace Geekbot.net.Lib +namespace Geekbot.net.Lib.Levels { public class LevelCalc : ILevelCalc { @@ -30,9 +30,4 @@ namespace Geekbot.net.Lib return returnVal; } } - - public interface ILevelCalc - { - int GetLevel(int experience); - } } \ No newline at end of file diff --git a/Geekbot.net/Lib/Localization/ITranslationHandler.cs b/Geekbot.net/Lib/Localization/ITranslationHandler.cs new file mode 100644 index 0000000..3cd9549 --- /dev/null +++ b/Geekbot.net/Lib/Localization/ITranslationHandler.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using Discord.Commands; + +namespace Geekbot.net.Lib.Localization +{ + public interface ITranslationHandler + { + string GetString(ulong guildId, string command, string stringName); + Dictionary GetDict(ICommandContext context); + Dictionary GetDict(ICommandContext context, string command); + bool SetLanguage(ulong guildId, string language); + List GetSupportedLanguages(); + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/TranslationHandler.cs b/Geekbot.net/Lib/Localization/TranslationHandler.cs similarity index 90% rename from Geekbot.net/Lib/TranslationHandler.cs rename to Geekbot.net/Lib/Localization/TranslationHandler.cs index 5324496..e57ee8d 100644 --- a/Geekbot.net/Lib/TranslationHandler.cs +++ b/Geekbot.net/Lib/Localization/TranslationHandler.cs @@ -4,10 +4,11 @@ using System.IO; using System.Linq; using Discord.Commands; using Discord.WebSocket; +using Geekbot.net.Lib.Logger; using StackExchange.Redis; using Utf8Json; -namespace Geekbot.net.Lib +namespace Geekbot.net.Lib.Localization { public class TranslationHandler : ITranslationHandler { @@ -30,7 +31,7 @@ namespace Geekbot.net.Lib { try { - var translationFile = File.ReadAllText(Path.GetFullPath("./Storage/Translations.json")); + var translationFile = File.ReadAllText(Path.GetFullPath("./Lib/Localization/Translations.json")); var rawTranslations = JsonSerializer.Deserialize>>>(translationFile); var sortedPerLanguage = new Dictionary>>(); foreach (var command in rawTranslations) @@ -152,13 +153,4 @@ namespace Geekbot.net.Lib return _supportedLanguages; } } - - public interface ITranslationHandler - { - string GetString(ulong guildId, string command, string stringName); - Dictionary GetDict(ICommandContext context); - Dictionary GetDict(ICommandContext context, string command); - bool SetLanguage(ulong guildId, string language); - List GetSupportedLanguages(); - } } \ No newline at end of file diff --git a/Geekbot.net/Storage/Translations.json b/Geekbot.net/Lib/Localization/Translations.json similarity index 100% rename from Geekbot.net/Storage/Translations.json rename to Geekbot.net/Lib/Localization/Translations.json diff --git a/Geekbot.net/Lib/Logger/DiscordLogger.cs b/Geekbot.net/Lib/Logger/DiscordLogger.cs new file mode 100644 index 0000000..fc12201 --- /dev/null +++ b/Geekbot.net/Lib/Logger/DiscordLogger.cs @@ -0,0 +1,42 @@ +using System.Threading.Tasks; +using Discord; + +namespace Geekbot.net.Lib.Logger +{ + public class DiscordLogger : IDiscordLogger + { + private readonly GeekbotLogger _logger; + + public DiscordLogger(GeekbotLogger logger) + { + _logger = logger; + } + + public Task Log(LogMessage message) + { + var logMessage = $"[{message.Source}] {message.Message}"; + switch (message.Severity) + { + case LogSeverity.Verbose: + _logger.Trace(message.Source, message.Message); + break; + case LogSeverity.Debug: + _logger.Debug(message.Source, message.Message); + break; + case LogSeverity.Info: + _logger.Information(message.Source, message.Message); + break; + case LogSeverity.Critical: + case LogSeverity.Error: + case LogSeverity.Warning: + if (logMessage.Contains("VOICE_STATE_UPDATE")) break; + _logger.Error(message.Source, message.Message, message.Exception); + break; + default: + _logger.Information(message.Source, $"{logMessage} --- {message.Severity}"); + break; + } + return Task.CompletedTask; + } + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/GeekbotLogger.cs b/Geekbot.net/Lib/Logger/GeekbotLogger.cs similarity index 75% rename from Geekbot.net/Lib/GeekbotLogger.cs rename to Geekbot.net/Lib/Logger/GeekbotLogger.cs index 7093a7c..8cefdb4 100644 --- a/Geekbot.net/Lib/GeekbotLogger.cs +++ b/Geekbot.net/Lib/Logger/GeekbotLogger.cs @@ -1,7 +1,7 @@ using System; using Newtonsoft.Json; -namespace Geekbot.net.Lib +namespace Geekbot.net.Lib.Logger { public class GeekbotLogger : IGeekbotLogger { @@ -21,6 +21,11 @@ namespace Geekbot.net.Lib Information("Geekbot", "Using GeekbotLogger"); } + public void Trace(string source, string message, object extra = null) + { + _logger.Trace(CreateLogString("Debug", source, message, null, extra)); + } + public void Debug(string source, string message, object extra = null) { _logger.Debug(CreateLogString("Debug", source, message, null, extra)); @@ -63,22 +68,4 @@ namespace Geekbot.net.Lib return $"[{source}] - [{m.Guild.Name} - {m.Channel.Name}] {m.User.Name}: {m.Message.Content}"; } } - - public class GeekbotLoggerObject - { - public DateTime Timestamp { get; set; } - public string Type { get; set; } - public string Source { get; set; } - public string Message { get; set; } - public Exception StackTrace { get; set; } - public object Extra { get; set; } - } - - public interface IGeekbotLogger - { - void Debug(string source, string message, object extra = null); - void Information(string source, string message, object extra = null); - void Warning(string source, string message, Exception stackTrace = null, object extra = null); - void Error(string source, string message, Exception stackTrace, object extra = null); - } } \ No newline at end of file diff --git a/Geekbot.net/Lib/Logger/IDiscordLogger.cs b/Geekbot.net/Lib/Logger/IDiscordLogger.cs new file mode 100644 index 0000000..fdc8c7f --- /dev/null +++ b/Geekbot.net/Lib/Logger/IDiscordLogger.cs @@ -0,0 +1,10 @@ +using System.Threading.Tasks; +using Discord; + +namespace Geekbot.net.Lib.Logger +{ + public interface IDiscordLogger + { + Task Log(LogMessage message); + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/Logger/IGeekbotLogger.cs b/Geekbot.net/Lib/Logger/IGeekbotLogger.cs new file mode 100644 index 0000000..36d456d --- /dev/null +++ b/Geekbot.net/Lib/Logger/IGeekbotLogger.cs @@ -0,0 +1,13 @@ +using System; + +namespace Geekbot.net.Lib.Logger +{ + public interface IGeekbotLogger + { + void Trace(string source, string message, object extra = null); + void Debug(string source, string message, object extra = null); + void Information(string source, string message, object extra = null); + void Warning(string source, string message, Exception stackTrace = null, object extra = null); + void Error(string source, string message, Exception stackTrace, object extra = null); + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/Logger/LogDto.cs b/Geekbot.net/Lib/Logger/LogDto.cs new file mode 100644 index 0000000..74695ec --- /dev/null +++ b/Geekbot.net/Lib/Logger/LogDto.cs @@ -0,0 +1,14 @@ +using System; + +namespace Geekbot.net.Lib.Logger +{ + public class GeekbotLoggerObject + { + public DateTime Timestamp { get; set; } + public string Type { get; set; } + public string Source { get; set; } + public string Message { get; set; } + public Exception StackTrace { get; set; } + public object Extra { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/LoggerFactory.cs b/Geekbot.net/Lib/Logger/LoggerFactory.cs similarity index 95% rename from Geekbot.net/Lib/LoggerFactory.cs rename to Geekbot.net/Lib/Logger/LoggerFactory.cs index b0b5060..53325a6 100644 --- a/Geekbot.net/Lib/LoggerFactory.cs +++ b/Geekbot.net/Lib/Logger/LoggerFactory.cs @@ -5,11 +5,11 @@ using NLog.Config; using NLog.Targets; using SumoLogic.Logging.NLog; -namespace Geekbot.net.Lib +namespace Geekbot.net.Lib.Logger { public class LoggerFactory { - public static Logger CreateNLog(RunParameters runParameters, bool sumologicActive) + public static NLog.Logger CreateNLog(RunParameters runParameters, bool sumologicActive) { var config = new LoggingConfiguration(); diff --git a/Geekbot.net/Lib/Logger/MessageDto.cs b/Geekbot.net/Lib/Logger/MessageDto.cs new file mode 100644 index 0000000..011acf3 --- /dev/null +++ b/Geekbot.net/Lib/Logger/MessageDto.cs @@ -0,0 +1,26 @@ +namespace Geekbot.net.Lib.Logger +{ + public class MessageDto + { + public MessageContent Message { get; set; } + public IdAndName User { get; set; } + public IdAndName Guild { get; set; } + public IdAndName Channel { get; set; } + + public class MessageContent + { + public string Content { get; set; } + public string Id { get; set; } + public int Attachments { get; set; } + public int ChannelMentions { get; set; } + public int UserMentions { get; set; } + public int RoleMentions { get; set; } + } + + public class IdAndName + { + public string Id { get; set; } + public string Name { get; set; } + } + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/SimpleConextConverter.cs b/Geekbot.net/Lib/Logger/SimpleConextConverter.cs similarity index 75% rename from Geekbot.net/Lib/SimpleConextConverter.cs rename to Geekbot.net/Lib/Logger/SimpleConextConverter.cs index ad029c7..4df802d 100644 --- a/Geekbot.net/Lib/SimpleConextConverter.cs +++ b/Geekbot.net/Lib/Logger/SimpleConextConverter.cs @@ -1,7 +1,7 @@ using Discord.Commands; using Discord.WebSocket; -namespace Geekbot.net.Lib +namespace Geekbot.net.Lib.Logger { public class SimpleConextConverter { @@ -68,29 +68,4 @@ namespace Geekbot.net.Lib } } - - - public class MessageDto - { - public MessageContent Message { get; set; } - public IdAndName User { get; set; } - public IdAndName Guild { get; set; } - public IdAndName Channel { get; set; } - - public class MessageContent - { - public string Content { get; set; } - public string Id { get; set; } - public int Attachments { get; set; } - public int ChannelMentions { get; set; } - public int UserMentions { get; set; } - public int RoleMentions { get; set; } - } - - public class IdAndName - { - public string Id { get; set; } - public string Name { get; set; } - } - } } \ No newline at end of file diff --git a/Geekbot.net/Lib/Media/FortunesProvider.cs b/Geekbot.net/Lib/Media/FortunesProvider.cs index 5988660..dc97199 100644 --- a/Geekbot.net/Lib/Media/FortunesProvider.cs +++ b/Geekbot.net/Lib/Media/FortunesProvider.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using Geekbot.net.Lib.Logger; namespace Geekbot.net.Lib.Media { @@ -16,7 +17,7 @@ namespace Geekbot.net.Lib.Media var rawFortunes = File.ReadAllText(path); _fortuneArray = rawFortunes.Split("%"); _totalFortunes = _fortuneArray.Length; - logger.Debug("Geekbot", "Loaded {totalFortunes} Fortunes"); + logger.Trace("Geekbot", $"Loaded {_totalFortunes} Fortunes"); } else { @@ -29,9 +30,4 @@ namespace Geekbot.net.Lib.Media return _fortuneArray[new Random().Next(0, _totalFortunes)]; } } - - public interface IFortunesProvider - { - string GetRandomFortune(); - } } \ No newline at end of file diff --git a/Geekbot.net/Lib/Media/IFortunesProvider.cs b/Geekbot.net/Lib/Media/IFortunesProvider.cs new file mode 100644 index 0000000..c82e45c --- /dev/null +++ b/Geekbot.net/Lib/Media/IFortunesProvider.cs @@ -0,0 +1,7 @@ +namespace Geekbot.net.Lib.Media +{ + public interface IFortunesProvider + { + string GetRandomFortune(); + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/Media/IMediaProvider.cs b/Geekbot.net/Lib/Media/IMediaProvider.cs new file mode 100644 index 0000000..79c6c98 --- /dev/null +++ b/Geekbot.net/Lib/Media/IMediaProvider.cs @@ -0,0 +1,14 @@ +namespace Geekbot.net.Lib.Media +{ + public interface IMediaProvider + { + string GetCheckem(); + string GetPanda(); + string GetCrossant(); + string GetSquirrel(); + string GetPumpkin(); + string GetTurtle(); + string GetPinguin(); + string GetFox(); + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/Media/MediaProvider.cs b/Geekbot.net/Lib/Media/MediaProvider.cs index 568f67d..8f28d0d 100644 --- a/Geekbot.net/Lib/Media/MediaProvider.cs +++ b/Geekbot.net/Lib/Media/MediaProvider.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using Geekbot.net.Lib.Logger; namespace Geekbot.net.Lib.Media { @@ -37,56 +38,56 @@ namespace Geekbot.net.Lib.Media { var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/checkEmPics")); _checkemImages = rawLinks.Split("\n"); - _logger.Debug("Geekbot", $"Loaded {_checkemImages.Length} CheckEm Images"); + _logger.Trace("Geekbot", $"Loaded {_checkemImages.Length} CheckEm Images"); } private void LoadPandas() { var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/pandas")); _pandaImages = rawLinks.Split("\n"); - _logger.Debug("Geekbot", $"Loaded {_pandaImages.Length} Panda Images"); + _logger.Trace("Geekbot", $"Loaded {_pandaImages.Length} Panda Images"); } private void BakeCroissants() { var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/croissant")); _croissantImages = rawLinks.Split("\n"); - _logger.Debug("Geekbot", $"Loaded {_croissantImages.Length} Croissant Images"); + _logger.Trace("Geekbot", $"Loaded {_croissantImages.Length} Croissant Images"); } private void LoadSquirrels() { var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/squirrel")); _squirrelImages = rawLinks.Split("\n"); - _logger.Debug("Geekbot", $"Loaded {_squirrelImages.Length} Squirrel Images"); + _logger.Trace("Geekbot", $"Loaded {_squirrelImages.Length} Squirrel Images"); } private void LoadPumpkins() { var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/pumpkin")); _pumpkinImages = rawLinks.Split("\n"); - _logger.Debug("Geekbot", $"Loaded {_pumpkinImages.Length} Pumpkin Images"); + _logger.Trace("Geekbot", $"Loaded {_pumpkinImages.Length} Pumpkin Images"); } private void LoadTurtles() { var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/turtles")); _turtlesImages = rawLinks.Split("\n"); - _logger.Debug("Geekbot", $"Loaded {_turtlesImages.Length} Turtle Images"); + _logger.Trace("Geekbot", $"Loaded {_turtlesImages.Length} Turtle Images"); } private void LoadPinguins() { var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/pinguins")); _pinguinImages = rawLinks.Split("\n"); - _logger.Debug("Geekbot", $"Loaded {_pinguinImages.Length} Pinguin Images"); + _logger.Trace("Geekbot", $"Loaded {_pinguinImages.Length} Pinguin Images"); } private void LoadFoxes() { var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/foxes")); _foxImages = rawLinks.Split("\n"); - _logger.Debug("Geekbot", $"Loaded {_foxImages.Length} Foxes Images"); + _logger.Trace("Geekbot", $"Loaded {_foxImages.Length} Foxes Images"); } public string GetCheckem() @@ -129,16 +130,4 @@ namespace Geekbot.net.Lib.Media return _foxImages[_random.Next(0, _foxImages.Length)]; } } - - public interface IMediaProvider - { - string GetCheckem(); - string GetPanda(); - string GetCrossant(); - string GetSquirrel(); - string GetPumpkin(); - string GetTurtle(); - string GetPinguin(); - string GetFox(); - } } \ No newline at end of file diff --git a/Geekbot.net/Lib/MtgManaConverter.cs b/Geekbot.net/Lib/MtgManaConverter.cs deleted file mode 100644 index 83b6767..0000000 --- a/Geekbot.net/Lib/MtgManaConverter.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace Geekbot.net.Lib -{ - public class MtgManaConverter : IMtgManaConverter - { - private Dictionary _manaDict; - - public MtgManaConverter() - { - // these emotes can be found at https://discord.gg/bz8HyA7 - - var manaDict = new Dictionary(); - manaDict.Add("{0}", "<:mtg_0:415216130043412482>"); - manaDict.Add("{1}", "<:mtg_1:415216130253389835>"); - manaDict.Add("{2}", "<:mtg_2:415216130031091713>"); - manaDict.Add("{3}", "<:mtg_3:415216130467037194>"); - manaDict.Add("{4}", "<:mtg_4:415216130026635295>"); - manaDict.Add("{5}", "<:mtg_5:415216130492203008>"); - manaDict.Add("{6}", "<:mtg_6:415216130458779658>"); - manaDict.Add("{7}", "<:mtg_7:415216130190475265>"); - manaDict.Add("{8}", "<:mtg_8:415216130517630986>"); - manaDict.Add("{9}", "<:mtg_9:415216130500722689>"); - manaDict.Add("{10", "<:mtg_10:415216130450391051>"); - manaDict.Add("{11}", "<:mtg_11:415216130811101185>"); - manaDict.Add("{12}", "<:mtg_12:415216130525888532>"); - manaDict.Add("{13}", "<:mtg_13:415216130517631000>"); - manaDict.Add("{14}", "<:mtg_14:415216130165178370>"); - manaDict.Add("{15}", "<:mtg_15:415216130576089108>"); - manaDict.Add("{16}", "<:mtg_16:415216130358247425>"); - manaDict.Add("{17}", "<:mtg_17:415216130601517056>"); - manaDict.Add("{18}", "<:mtg_18:415216130462842891>"); - manaDict.Add("{19}", "<:mtg_19:415216130614099988>"); - manaDict.Add("{20}", "<:mtg_20:415216130656043038>"); - manaDict.Add("{W}", "<:mtg_white:415216131515744256>"); - manaDict.Add("{U}", "<:mtg_blue:415216130521694209>"); - manaDict.Add("{B}", "<:mtg_black:415216130873884683>"); - manaDict.Add("{R}", "<:mtg_red:415216131322806272>"); - manaDict.Add("{G}", "<:mtg_green:415216131180331009>"); - manaDict.Add("{S}", "<:mtg_s:415216131293446144>"); - manaDict.Add("{T}", "<:mtg_tap:415258392727257088>"); - manaDict.Add("{C}", "<:mtg_colorless:415216130706374666>"); - manaDict.Add("{2/W}", "<:mtg_2w:415216130446065664>"); - manaDict.Add("{2/U}", "<:mtg_2u:415216130429550592>"); - manaDict.Add("{2/B}", "<:mtg_2b:415216130160984065>"); - manaDict.Add("{2/R}", "<:mtg_2r:415216130454716436>"); - manaDict.Add("{2/G}", "<:mtg_2g:415216130420899840>"); - manaDict.Add("{W/U}", "<:mtg_wu:415216130970484736>"); - manaDict.Add("{W/B}", "<:mtg_wb:415216131222011914>"); - manaDict.Add("{U/R}", "<:mtg_ur:415216130962096128>"); - manaDict.Add("{U/B}", "<:mtg_ub:415216130865758218>"); - manaDict.Add("{R/W}", "<:mtg_rw:415216130878210057>"); - manaDict.Add("{G/W}", "<:mtg_gw:415216130567962646>"); - manaDict.Add("{G/U}", "<:mtg_gu:415216130739666945>"); - manaDict.Add("{B/R}", "<:mtg_br:415216130580283394>"); - manaDict.Add("{B/G}", "<:mtg_bg:415216130781609994>"); - manaDict.Add("{U/P}", "<:mtg_up:415216130861432842>"); - manaDict.Add("{R/P}", "<:mtg_rp:415216130597322783>"); - manaDict.Add("{G/P}", "<:mtg_gp:415216130760769546>"); - manaDict.Add("{W/P}", "<:mtg_wp:415216131541041172>"); - manaDict.Add("{B/P}", "<:mtg_bp:415216130664169482>"); - - _manaDict = manaDict; - } - - public string ConvertMana(string mana) - { - var rgx = Regex.Matches(mana, @"(\{(.*?)\})"); - foreach (Match manaTypes in rgx) - { - var m = _manaDict.GetValueOrDefault(manaTypes.Value); - if (!string.IsNullOrEmpty(m)) - { - mana = mana.Replace(manaTypes.Value, m); - } - } - return mana; - } - } - - public interface IMtgManaConverter - { - string ConvertMana(string mana); - } -} \ No newline at end of file diff --git a/Geekbot.net/Lib/ReactionListener/IReactionListener.cs b/Geekbot.net/Lib/ReactionListener/IReactionListener.cs new file mode 100644 index 0000000..792a516 --- /dev/null +++ b/Geekbot.net/Lib/ReactionListener/IReactionListener.cs @@ -0,0 +1,14 @@ +using System.Threading.Tasks; +using Discord; +using Discord.WebSocket; + +namespace Geekbot.net.Lib.ReactionListener +{ + public interface IReactionListener + { + bool IsListener(ulong id); + Task AddRoleToListener(string messageId, IEmote emoji, IRole role); + void RemoveRole(ISocketMessageChannel channel, SocketReaction reaction); + void GiveRole(ISocketMessageChannel message, SocketReaction reaction); + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/ReactionListener.cs b/Geekbot.net/Lib/ReactionListener/ReactionListener.cs similarity index 87% rename from Geekbot.net/Lib/ReactionListener.cs rename to Geekbot.net/Lib/ReactionListener/ReactionListener.cs index f837280..950edd1 100644 --- a/Geekbot.net/Lib/ReactionListener.cs +++ b/Geekbot.net/Lib/ReactionListener/ReactionListener.cs @@ -5,7 +5,7 @@ using Discord; using Discord.WebSocket; using StackExchange.Redis; -namespace Geekbot.net.Lib +namespace Geekbot.net.Lib.ReactionListener { public class ReactionListener : IReactionListener { @@ -87,12 +87,4 @@ namespace Geekbot.net.Lib await ((IGuildUser) reaction.User.Value).AddRoleAsync(role); } } - - public interface IReactionListener - { - bool IsListener(ulong id); - Task AddRoleToListener(string messageId, IEmote emoji, IRole role); - void RemoveRole(ISocketMessageChannel channel, SocketReaction reaction); - void GiveRole(ISocketMessageChannel message, SocketReaction reaction); - } } \ No newline at end of file diff --git a/Geekbot.net/Lib/UserRepository/IUserRepository.cs b/Geekbot.net/Lib/UserRepository/IUserRepository.cs new file mode 100644 index 0000000..9466621 --- /dev/null +++ b/Geekbot.net/Lib/UserRepository/IUserRepository.cs @@ -0,0 +1,13 @@ +using System.Threading.Tasks; +using Discord.WebSocket; + +namespace Geekbot.net.Lib.UserRepository +{ + public interface IUserRepository + { + Task Update(SocketUser user); + UserRepositoryUser Get(ulong userId); + string GetUserSetting(ulong userId, string setting); + bool SaveUserSetting(ulong userId, string setting, string value); + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/UserRepository.cs b/Geekbot.net/Lib/UserRepository/UserRepository.cs similarity index 84% rename from Geekbot.net/Lib/UserRepository.cs rename to Geekbot.net/Lib/UserRepository/UserRepository.cs index 28d0541..558732e 100644 --- a/Geekbot.net/Lib/UserRepository.cs +++ b/Geekbot.net/Lib/UserRepository/UserRepository.cs @@ -2,10 +2,11 @@ using System.Collections.Generic; using System.Threading.Tasks; using Discord.WebSocket; +using Geekbot.net.Lib.Logger; using StackExchange.Redis; using Utf8Json; -namespace Geekbot.net.Lib +namespace Geekbot.net.Lib.UserRepository { public class UserRepository : IUserRepository { @@ -121,23 +122,4 @@ namespace Geekbot.net.Lib return true; } } - - public class UserRepositoryUser - { - public ulong Id { get; set; } - public string Username { get; set; } - public string Discriminator { get; set; } - public string AvatarUrl { get; set; } - public bool IsBot { get; set; } - public DateTimeOffset Joined { get; set; } - public List UsedNames { get; set; } - } - - public interface IUserRepository - { - Task Update(SocketUser user); - UserRepositoryUser Get(ulong userId); - string GetUserSetting(ulong userId, string setting); - bool SaveUserSetting(ulong userId, string setting, string value); - } } \ No newline at end of file diff --git a/Geekbot.net/Lib/UserRepository/UserRepositoryUserDto.cs b/Geekbot.net/Lib/UserRepository/UserRepositoryUserDto.cs new file mode 100644 index 0000000..4af719b --- /dev/null +++ b/Geekbot.net/Lib/UserRepository/UserRepositoryUserDto.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; + +namespace Geekbot.net.Lib.UserRepository +{ + public class UserRepositoryUser + { + public ulong Id { get; set; } + public string Username { get; set; } + public string Discriminator { get; set; } + public string AvatarUrl { get; set; } + public bool IsBot { get; set; } + public DateTimeOffset Joined { get; set; } + public List UsedNames { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/Program.cs b/Geekbot.net/Program.cs index 3c0e5eb..f5f878a 100755 --- a/Geekbot.net/Program.cs +++ b/Geekbot.net/Program.cs @@ -8,7 +8,15 @@ using Discord; using Discord.Commands; using Discord.WebSocket; using Geekbot.net.Lib; +using Geekbot.net.Lib.Clients; +using Geekbot.net.Lib.Converters; +using Geekbot.net.Lib.ErrorHandling; +using Geekbot.net.Lib.Levels; +using Geekbot.net.Lib.Localization; +using Geekbot.net.Lib.Logger; using Geekbot.net.Lib.Media; +using Geekbot.net.Lib.ReactionListener; +using Geekbot.net.Lib.UserRepository; using Microsoft.Extensions.DependencyInjection; using Nancy.Hosting.Self; using StackExchange.Redis; @@ -24,7 +32,7 @@ namespace Geekbot.net private IServiceCollection _services; private IServiceProvider _servicesProvider; private RedisValue _token; - private IGeekbotLogger _logger; + private GeekbotLogger _logger; private IUserRepository _userRepository; private bool _firstStart; private RunParameters _runParameters; @@ -57,18 +65,19 @@ namespace Geekbot.net } } - private async Task MainAsync(RunParameters runParameters, IGeekbotLogger logger) + private async Task MainAsync(RunParameters runParameters, GeekbotLogger logger) { _logger = logger; _runParameters = runParameters; logger.Information("Geekbot", "Initing Stuff"); + var discordLogger = new DiscordLogger(logger); _client = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Verbose, MessageCacheSize = 1000 }); - _client.Log += DiscordLogger; + _client.Log += discordLogger.Log; _commands = new CommandService(); try @@ -218,30 +227,5 @@ namespace Geekbot.net } return Task.CompletedTask; } - - private Task DiscordLogger(LogMessage message) - { - var logMessage = $"[{message.Source}] {message.Message}"; - switch (message.Severity) - { - case LogSeverity.Verbose: - case LogSeverity.Debug: - _logger.Debug(message.Source, message.Message); - break; - case LogSeverity.Info: - _logger.Information(message.Source, message.Message); - break; - case LogSeverity.Critical: - case LogSeverity.Error: - case LogSeverity.Warning: - if (logMessage.Contains("VOICE_STATE_UPDATE")) break; - _logger.Error(message.Source, message.Message, message.Exception); - break; - default: - _logger.Information(message.Source, $"{logMessage} --- {message.Severity}"); - break; - } - return Task.CompletedTask; - } } } \ No newline at end of file diff --git a/Geekbot.net/WebApi/Help/CommandDto.cs b/Geekbot.net/WebApi/Help/CommandDto.cs new file mode 100644 index 0000000..5921fa6 --- /dev/null +++ b/Geekbot.net/WebApi/Help/CommandDto.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace Geekbot.net.WebApi.Help +{ + public class CommandDto + { + public string Name { get; set; } + public string Category { get; set; } + public string Summary { get; set; } + public bool IsAdminCommand { get; set; } + public Array Aliases { get; set; } + public List Params { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/WebApi/Help/CommandParamDto.cs b/Geekbot.net/WebApi/Help/CommandParamDto.cs new file mode 100644 index 0000000..f7ce0ea --- /dev/null +++ b/Geekbot.net/WebApi/Help/CommandParamDto.cs @@ -0,0 +1,9 @@ +namespace Geekbot.net.WebApi.Help +{ + public class CommandParamDto + { + public string Summary { get; set; } + public string Default { get; set; } + public string Type { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/WebApi/HelpController.cs b/Geekbot.net/WebApi/Help/HelpController.cs similarity index 70% rename from Geekbot.net/WebApi/HelpController.cs rename to Geekbot.net/WebApi/Help/HelpController.cs index 060dea0..d71d26f 100644 --- a/Geekbot.net/WebApi/HelpController.cs +++ b/Geekbot.net/WebApi/Help/HelpController.cs @@ -1,13 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Linq; using System.Reflection; using System.Threading.Tasks; using Discord.Commands; using Geekbot.net.Lib; using Nancy; -namespace Geekbot.net.WebApi +namespace Geekbot.net.WebApi.Help { public class HelpController : NancyModule { @@ -47,21 +45,4 @@ namespace Geekbot.net.WebApi return commands; } } - - public class CommandDto - { - public string Name { get; set; } - public string Category { get; set; } - public string Summary { get; set; } - public bool IsAdminCommand { get; set; } - public Array Aliases { get; set; } - public List Params { get; set; } - } - - public class CommandParamDto - { - public string Summary { get; set; } - public string Default { get; set; } - public string Type { get; set; } - } } \ No newline at end of file diff --git a/Geekbot.net/WebApi/Status/ApiStatusDto.cs b/Geekbot.net/WebApi/Status/ApiStatusDto.cs new file mode 100644 index 0000000..242bf58 --- /dev/null +++ b/Geekbot.net/WebApi/Status/ApiStatusDto.cs @@ -0,0 +1,9 @@ +namespace Geekbot.net.WebApi.Status +{ + public class ApiStatusDto + { + public string GeekbotVersion { get; set; } + public string ApiVersion { get; set; } + public string Status { get; set; } + } +} \ No newline at end of file diff --git a/Geekbot.net/WebApi/StatusController.cs b/Geekbot.net/WebApi/Status/StatusController.cs similarity index 71% rename from Geekbot.net/WebApi/StatusController.cs rename to Geekbot.net/WebApi/Status/StatusController.cs index b785e07..5f995c9 100644 --- a/Geekbot.net/WebApi/StatusController.cs +++ b/Geekbot.net/WebApi/Status/StatusController.cs @@ -1,7 +1,7 @@ using Geekbot.net.Lib; using Nancy; -namespace Geekbot.net.WebApi +namespace Geekbot.net.WebApi.Status { public class StatusController : NancyModule { @@ -19,11 +19,4 @@ namespace Geekbot.net.WebApi }); } } - - public class ApiStatusDto - { - public string GeekbotVersion { get; set; } - public string ApiVersion { get; set; } - public string Status { get; set; } - } } \ No newline at end of file diff --git a/Tests/Lib/EmojiConverter.test.cs b/Tests/Lib/EmojiConverter.test.cs index 4bfcf06..aaaaa8f 100644 --- a/Tests/Lib/EmojiConverter.test.cs +++ b/Tests/Lib/EmojiConverter.test.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Geekbot.net.Lib; +using Geekbot.net.Lib.Converters; using Xunit; namespace Tests.Lib diff --git a/Tests/Lib/LevelCalc.test.cs b/Tests/Lib/LevelCalc.test.cs index ecca151..4b6b095 100644 --- a/Tests/Lib/LevelCalc.test.cs +++ b/Tests/Lib/LevelCalc.test.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Geekbot.net.Lib; +using Geekbot.net.Lib.Levels; using Xunit; namespace Tests.Lib