From 58ba2980f97cf2c0125e277d31f8bf37e204428f Mon Sep 17 00:00:00 2001 From: Runebaas Date: Thu, 12 Oct 2017 16:34:10 +0200 Subject: [PATCH] Command Categories (more or less) --- Geekbot.net/Commands/AdminCmd.cs | 13 ++++++++++--- Geekbot.net/Commands/BattleTag.cs | 2 ++ Geekbot.net/Commands/Cat.cs | 2 ++ Geekbot.net/Commands/CheckEm.cs | 1 + Geekbot.net/Commands/Choose.cs | 4 +++- Geekbot.net/Commands/Counters.cs | 2 ++ Geekbot.net/Commands/Dice.cs | 2 ++ Geekbot.net/Commands/Dog.cs | 2 ++ Geekbot.net/Commands/EightBall.cs | 2 ++ Geekbot.net/Commands/Fortune.cs | 2 ++ Geekbot.net/Commands/Google.cs | 2 ++ Geekbot.net/Commands/GuildInfo.cs | 1 + Geekbot.net/Commands/Help.cs | 1 + Geekbot.net/Commands/Info.cs | 2 ++ Geekbot.net/Commands/Ping.cs | 2 ++ Geekbot.net/Commands/Pokedex.cs | 1 + Geekbot.net/Commands/Quote.cs | 5 +++++ Geekbot.net/Commands/RandomAnimals.cs | 6 ++++++ Geekbot.net/Commands/Rank.cs | 1 + Geekbot.net/Commands/Roll.cs | 6 ++++-- Geekbot.net/Commands/Say.cs | 2 ++ Geekbot.net/Commands/Ship.cs | 2 ++ Geekbot.net/Commands/Stats.cs | 1 + Geekbot.net/Commands/Youtube.cs | 2 ++ Geekbot.net/Commands/mal.cs | 2 ++ Geekbot.net/Lib/CommandCategories.cs | 15 +++++++++++++++ Geekbot.net/Program.cs | 21 +++++++++++++-------- Geekbot.net/WebApi/HelpController.cs | 2 ++ Geekbot.net/WebApi/WebConfig.cs | 8 +++++--- 29 files changed, 97 insertions(+), 17 deletions(-) create mode 100644 Geekbot.net/Lib/CommandCategories.cs diff --git a/Geekbot.net/Commands/AdminCmd.cs b/Geekbot.net/Commands/AdminCmd.cs index 0d9292e..060fc78 100644 --- a/Geekbot.net/Commands/AdminCmd.cs +++ b/Geekbot.net/Commands/AdminCmd.cs @@ -30,6 +30,7 @@ namespace Geekbot.net.Commands [RequireUserPermission(GuildPermission.Administrator)] [Command("welcome", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Admin)] [Summary("Set a Welcome Message (use '$user' to mention the new joined user).")] public async Task SetWelcomeMessage([Remainder] [Summary("message")] string welcomeMessage) { @@ -40,6 +41,7 @@ namespace Geekbot.net.Commands } [Command("youtubekey", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Admin)] [Summary("Set the youtube api key")] public async Task SetYoutubeKey([Summary("API Key")] string key) { @@ -55,6 +57,7 @@ namespace Geekbot.net.Commands } [Command("game", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Admin)] [Summary("Set the game that the bot is playing")] public async Task SetGame([Remainder] [Summary("Game")] string key) { @@ -72,7 +75,8 @@ namespace Geekbot.net.Commands } [Command("popuserrepo", RunMode = RunMode.Async)] - [Summary("Set the game that the bot is playing")] + [Remarks(CommandCategories.Admin)] + [Summary("Populate user cache")] public async Task popUserRepoCommand() { try @@ -117,7 +121,8 @@ namespace Geekbot.net.Commands [RequireUserPermission(GuildPermission.Administrator)] [Command("modchannel", RunMode = RunMode.Async)] - [Summary("Set the game that the bot is playing")] + [Remarks(CommandCategories.Admin)] + [Summary("Set a channel for moderation purposes")] public async Task selectModChannel([Summary("ChannelId")] ulong channelId) { try @@ -143,6 +148,7 @@ namespace Geekbot.net.Commands [RequireUserPermission(GuildPermission.Administrator)] [Command("showleave", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Admin)] [Summary("Notify modchannel when someone leaves")] public async Task showLeave([Summary("true/false")] bool enabled) { @@ -169,7 +175,8 @@ namespace Geekbot.net.Commands [RequireUserPermission(GuildPermission.Administrator)] [Command("showdel", RunMode = RunMode.Async)] - [Summary("Notify modchannel when someone leaves")] + [Remarks(CommandCategories.Admin)] + [Summary("Notify modchannel when someone deletes a message")] public async Task showDelete([Summary("true/false")] bool enabled) { var modChannelId = (ulong)_redis.HashGet($"{Context.Guild.Id}:Settings", "ModChannel"); diff --git a/Geekbot.net/Commands/BattleTag.cs b/Geekbot.net/Commands/BattleTag.cs index 0003f58..65a9444 100644 --- a/Geekbot.net/Commands/BattleTag.cs +++ b/Geekbot.net/Commands/BattleTag.cs @@ -21,6 +21,7 @@ namespace Geekbot.net.Commands } [Command(RunMode = RunMode.Async)] + [Remarks(CommandCategories.Games)] [Summary("Get your battletag")] public async Task BattleTagCmd() { @@ -44,6 +45,7 @@ namespace Geekbot.net.Commands } [Command(RunMode = RunMode.Async)] + [Remarks(CommandCategories.Games)] [Summary("Save your battletag")] public async Task BattleTagCmd([Summary("Battletag")] string tag) { diff --git a/Geekbot.net/Commands/Cat.cs b/Geekbot.net/Commands/Cat.cs index 3e7973b..4d5f001 100644 --- a/Geekbot.net/Commands/Cat.cs +++ b/Geekbot.net/Commands/Cat.cs @@ -2,6 +2,7 @@ using System.Net.Http; using System.Threading.Tasks; using Discord.Commands; +using Geekbot.net.Lib; using Newtonsoft.Json; namespace Geekbot.net.Commands @@ -9,6 +10,7 @@ namespace Geekbot.net.Commands public class Cat : ModuleBase { [Command("cat", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Randomness)] [Summary("Return a random image of a cat.")] public async Task Say() { diff --git a/Geekbot.net/Commands/CheckEm.cs b/Geekbot.net/Commands/CheckEm.cs index 15b2cfd..be49cd1 100644 --- a/Geekbot.net/Commands/CheckEm.cs +++ b/Geekbot.net/Commands/CheckEm.cs @@ -25,6 +25,7 @@ namespace Geekbot.net.Commands } [Command("checkem", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Randomness)] [Summary("Check for dubs")] public async Task MuhDubs() { diff --git a/Geekbot.net/Commands/Choose.cs b/Geekbot.net/Commands/Choose.cs index 338851d..9d19c84 100644 --- a/Geekbot.net/Commands/Choose.cs +++ b/Geekbot.net/Commands/Choose.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Discord.Commands; +using Geekbot.net.Lib; namespace Geekbot.net.Commands { @@ -14,7 +15,8 @@ namespace Geekbot.net.Commands } [Command("choose", RunMode = RunMode.Async)] - [Summary("Seperate options with a semicolon.")] + [Remarks(CommandCategories.Helpers)] + [Summary("Let the bot choose for you, seperate options with a semicolon.")] public async Task Command([Remainder] [Summary("option1;option2")] string choices) { var choicesArray = choices.Split(';'); diff --git a/Geekbot.net/Commands/Counters.cs b/Geekbot.net/Commands/Counters.cs index 45ffa3d..f999f1e 100644 --- a/Geekbot.net/Commands/Counters.cs +++ b/Geekbot.net/Commands/Counters.cs @@ -22,6 +22,7 @@ namespace Geekbot.net.Commands } [Command("good", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Karma)] [Summary("Increase Someones Karma")] public async Task Good([Summary("@someone")] IUser user) { @@ -64,6 +65,7 @@ namespace Geekbot.net.Commands } [Command("bad", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Karma)] [Summary("Decrease Someones Karma")] public async Task Bad([Summary("@someone")] IUser user) { diff --git a/Geekbot.net/Commands/Dice.cs b/Geekbot.net/Commands/Dice.cs index c40757c..a0aa03c 100644 --- a/Geekbot.net/Commands/Dice.cs +++ b/Geekbot.net/Commands/Dice.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Discord.Commands; +using Geekbot.net.Lib; namespace Geekbot.net.Commands { @@ -17,6 +18,7 @@ namespace Geekbot.net.Commands } [Command("dice", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Randomness)] [Summary("Roll a dice.")] public async Task RollCommand([Remainder] [Summary("diceType")] string diceType = "1d20") { diff --git a/Geekbot.net/Commands/Dog.cs b/Geekbot.net/Commands/Dog.cs index 481500e..7ce9470 100644 --- a/Geekbot.net/Commands/Dog.cs +++ b/Geekbot.net/Commands/Dog.cs @@ -2,6 +2,7 @@ using System.Net.Http; using System.Threading.Tasks; using Discord.Commands; +using Geekbot.net.Lib; using Newtonsoft.Json; namespace Geekbot.net.Commands @@ -9,6 +10,7 @@ namespace Geekbot.net.Commands public class Dog : ModuleBase { [Command("dog", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Randomness)] [Summary("Return a random image of a dog.")] public async Task Say() { diff --git a/Geekbot.net/Commands/EightBall.cs b/Geekbot.net/Commands/EightBall.cs index 5ca4ae6..3138c69 100644 --- a/Geekbot.net/Commands/EightBall.cs +++ b/Geekbot.net/Commands/EightBall.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Discord.Commands; +using Geekbot.net.Lib; namespace Geekbot.net.Commands { @@ -15,6 +16,7 @@ namespace Geekbot.net.Commands } [Command("8ball", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Randomness)] [Summary("Ask 8Ball a Question.")] public async Task Ball([Remainder] [Summary("Question")] string echo) { diff --git a/Geekbot.net/Commands/Fortune.cs b/Geekbot.net/Commands/Fortune.cs index d97b437..ba4bc07 100644 --- a/Geekbot.net/Commands/Fortune.cs +++ b/Geekbot.net/Commands/Fortune.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Discord.Commands; +using Geekbot.net.Lib; using Geekbot.net.Lib.Media; namespace Geekbot.net.Commands @@ -14,6 +15,7 @@ namespace Geekbot.net.Commands } [Command("fortune", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Randomness)] [Summary("Get a random fortune")] public async Task GetAFortune() { diff --git a/Geekbot.net/Commands/Google.cs b/Geekbot.net/Commands/Google.cs index 05c8c55..16151c5 100644 --- a/Geekbot.net/Commands/Google.cs +++ b/Geekbot.net/Commands/Google.cs @@ -1,11 +1,13 @@ using System.Threading.Tasks; using Discord.Commands; +using Geekbot.net.Lib; namespace Geekbot.net.Commands { public class Google : ModuleBase { [Command("google", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Fun)] [Summary("Google Something.")] public async Task Eyes([Remainder, Summary("SearchText")] string searchText) { diff --git a/Geekbot.net/Commands/GuildInfo.cs b/Geekbot.net/Commands/GuildInfo.cs index ff9c4a0..7ee3d43 100644 --- a/Geekbot.net/Commands/GuildInfo.cs +++ b/Geekbot.net/Commands/GuildInfo.cs @@ -18,6 +18,7 @@ namespace Geekbot.net.Commands } [Command("serverstats", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Statistics)] [Summary("Show some info about the bot.")] public async Task getInfo() { diff --git a/Geekbot.net/Commands/Help.cs b/Geekbot.net/Commands/Help.cs index 5ab8270..9ba8792 100644 --- a/Geekbot.net/Commands/Help.cs +++ b/Geekbot.net/Commands/Help.cs @@ -19,6 +19,7 @@ namespace Geekbot.net.Commands } [Command("help", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Helpers)] [Summary("List all Commands")] public async Task GetHelp() { diff --git a/Geekbot.net/Commands/Info.cs b/Geekbot.net/Commands/Info.cs index a620518..29ee180 100644 --- a/Geekbot.net/Commands/Info.cs +++ b/Geekbot.net/Commands/Info.cs @@ -23,6 +23,7 @@ namespace Geekbot.net.Commands } [Command("info", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Helpers)] [Summary("Get Information about the bot")] public async Task BotInfo() { @@ -51,6 +52,7 @@ namespace Geekbot.net.Commands } [Command("uptime", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Helpers)] [Summary("Get the Bot Uptime")] public async Task BotUptime() { diff --git a/Geekbot.net/Commands/Ping.cs b/Geekbot.net/Commands/Ping.cs index 698c383..c41700e 100644 --- a/Geekbot.net/Commands/Ping.cs +++ b/Geekbot.net/Commands/Ping.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Discord.Commands; +using Geekbot.net.Lib; namespace Geekbot.net.Commands { @@ -7,6 +8,7 @@ namespace Geekbot.net.Commands { [Command("👀", RunMode = RunMode.Async)] [Summary("Look at the bot.")] + [Remarks(CommandCategories.Fun)] public async Task Eyes() { await ReplyAsync("S... Stop looking at me... baka!"); diff --git a/Geekbot.net/Commands/Pokedex.cs b/Geekbot.net/Commands/Pokedex.cs index 0a36e37..b187841 100644 --- a/Geekbot.net/Commands/Pokedex.cs +++ b/Geekbot.net/Commands/Pokedex.cs @@ -19,6 +19,7 @@ namespace Geekbot.net.Commands } [Command("pokedex", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Helpers)] [Summary("A Pokedex Tool")] public async Task GetPokemon([Summary("pokemonName")] string pokemonName) { diff --git a/Geekbot.net/Commands/Quote.cs b/Geekbot.net/Commands/Quote.cs index 699a731..ca2d134 100644 --- a/Geekbot.net/Commands/Quote.cs +++ b/Geekbot.net/Commands/Quote.cs @@ -26,6 +26,7 @@ namespace Geekbot.net.Commands } [Command()] + [Remarks(CommandCategories.Quotes)] [Summary("Return a random quoute from the database")] public async Task getRandomQuote() { @@ -43,6 +44,7 @@ namespace Geekbot.net.Commands } [Command("save")] + [Remarks(CommandCategories.Quotes)] [Summary("Save a quote from the last sent message by @user")] public async Task saveQuote([Summary("@user")] IUser user) { @@ -67,6 +69,7 @@ namespace Geekbot.net.Commands } [Command("save")] + [Remarks(CommandCategories.Quotes)] [Summary("Save a quote from a message id")] public async Task saveQuote([Summary("messageId")] ulong messageId) { @@ -92,6 +95,7 @@ namespace Geekbot.net.Commands } [Command("make")] + [Remarks(CommandCategories.Quotes)] [Summary("Create a quote from the last sent message by @user")] public async Task returnSpecifiedQuote([Summary("@user")] IUser user) { @@ -109,6 +113,7 @@ namespace Geekbot.net.Commands } [Command("make")] + [Remarks(CommandCategories.Quotes)] [Summary("Create a quote from a message id")] public async Task returnSpecifiedQuote([Summary("messageId")] ulong messageId) { diff --git a/Geekbot.net/Commands/RandomAnimals.cs b/Geekbot.net/Commands/RandomAnimals.cs index e879428..7d1f723 100644 --- a/Geekbot.net/Commands/RandomAnimals.cs +++ b/Geekbot.net/Commands/RandomAnimals.cs @@ -1,5 +1,6 @@ using System.Threading.Tasks; using Discord.Commands; +using Geekbot.net.Lib; using Geekbot.net.Lib.Media; namespace Geekbot.net.Commands @@ -14,6 +15,7 @@ namespace Geekbot.net.Commands } [Command("panda", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Randomness)] [Summary("Get a random panda image")] public async Task panda() { @@ -22,6 +24,7 @@ namespace Geekbot.net.Commands [Command("croissant", RunMode = RunMode.Async)] [Alias("gipfeli")] + [Remarks(CommandCategories.Randomness)] [Summary("Get a random croissant image")] public async Task croissant() { @@ -29,6 +32,7 @@ namespace Geekbot.net.Commands } [Command("pumpkin", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Randomness)] [Summary("Get a random pumpkin image")] public async Task pumpkin() { @@ -36,6 +40,7 @@ namespace Geekbot.net.Commands } [Command("squirrel", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Randomness)] [Summary("Get a random squirrel image")] public async Task squirrel() { @@ -43,6 +48,7 @@ namespace Geekbot.net.Commands } [Command("turtle", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Randomness)] [Summary("Get a random turtle image")] public async Task turtle() { diff --git a/Geekbot.net/Commands/Rank.cs b/Geekbot.net/Commands/Rank.cs index 3ec6203..274b7ef 100644 --- a/Geekbot.net/Commands/Rank.cs +++ b/Geekbot.net/Commands/Rank.cs @@ -27,6 +27,7 @@ namespace Geekbot.net.Commands } [Command("rank", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Statistics)] [Summary("get user top 10")] public async Task RankCmd() { diff --git a/Geekbot.net/Commands/Roll.cs b/Geekbot.net/Commands/Roll.cs index 66caa40..5103c9f 100644 --- a/Geekbot.net/Commands/Roll.cs +++ b/Geekbot.net/Commands/Roll.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Discord.Commands; +using Geekbot.net.Lib; using StackExchange.Redis; namespace Geekbot.net.Commands @@ -17,8 +18,9 @@ namespace Geekbot.net.Commands } [Command("roll", RunMode = RunMode.Async)] - [Summary("Roll a number between 1 and 100.")] - public async Task RollCommand([Remainder] [Summary("stuff...")] string stuff = "nothing") + [Remarks(CommandCategories.Fun)] + [Summary("Guess which number the bot will roll (1-100")] + public async Task RollCommand([Remainder] [Summary("guess")] string stuff = "noGuess") { var number = rnd.Next(1, 100); var guess = 1000; diff --git a/Geekbot.net/Commands/Say.cs b/Geekbot.net/Commands/Say.cs index 52b4477..4f057db 100644 --- a/Geekbot.net/Commands/Say.cs +++ b/Geekbot.net/Commands/Say.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; +using Geekbot.net.Lib; namespace Geekbot.net.Commands { @@ -8,6 +9,7 @@ namespace Geekbot.net.Commands { [RequireUserPermission(GuildPermission.Administrator)] [Command("say", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Admin)] [Summary("Say Something.")] public async Task Echo([Remainder] [Summary("What?")] string echo) { diff --git a/Geekbot.net/Commands/Ship.cs b/Geekbot.net/Commands/Ship.cs index da2bd2e..ea1e942 100644 --- a/Geekbot.net/Commands/Ship.cs +++ b/Geekbot.net/Commands/Ship.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using Discord; using Discord.Commands; +using Geekbot.net.Lib; using StackExchange.Redis; namespace Geekbot.net.Commands @@ -18,6 +19,7 @@ namespace Geekbot.net.Commands } [Command("Ship", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Fun)] [Summary("Ask the Shipping meter")] public async Task Command([Summary("@User1")] IUser user1, [Summary("@User2")] IUser user2) { diff --git a/Geekbot.net/Commands/Stats.cs b/Geekbot.net/Commands/Stats.cs index 61b57d9..b35cc45 100644 --- a/Geekbot.net/Commands/Stats.cs +++ b/Geekbot.net/Commands/Stats.cs @@ -19,6 +19,7 @@ namespace Geekbot.net.Commands } [Command("stats", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Statistics)] [Summary("Get information about this user")] public async Task User([Summary("@someone")] IUser user = null) { diff --git a/Geekbot.net/Commands/Youtube.cs b/Geekbot.net/Commands/Youtube.cs index c496cde..ee743b3 100644 --- a/Geekbot.net/Commands/Youtube.cs +++ b/Geekbot.net/Commands/Youtube.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Discord.Commands; +using Geekbot.net.Lib; using Google.Apis.Services; using Google.Apis.YouTube.v3; using StackExchange.Redis; @@ -17,6 +18,7 @@ namespace Geekbot.net.Commands } [Command("yt", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Helpers)] [Summary("Search for something on youtube.")] public async Task Yt([Remainder] [Summary("Title")] string searchQuery) { diff --git a/Geekbot.net/Commands/mal.cs b/Geekbot.net/Commands/mal.cs index 840c7c7..4e364ee 100644 --- a/Geekbot.net/Commands/mal.cs +++ b/Geekbot.net/Commands/mal.cs @@ -18,6 +18,7 @@ namespace Geekbot.net.Commands } [Command("anime", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Helpers)] [Summary("Show Info about an Anime.")] public async Task searchAnime([Remainder, Summary("AnimeName")] string animeName) { @@ -66,6 +67,7 @@ namespace Geekbot.net.Commands } [Command("manga", RunMode = RunMode.Async)] + [Remarks(CommandCategories.Helpers)] [Summary("Show Info about a Manga.")] public async Task searchManga([Remainder, Summary("MangaName")] string mangaName) { diff --git a/Geekbot.net/Lib/CommandCategories.cs b/Geekbot.net/Lib/CommandCategories.cs new file mode 100644 index 0000000..ca7ea58 --- /dev/null +++ b/Geekbot.net/Lib/CommandCategories.cs @@ -0,0 +1,15 @@ +namespace Geekbot.net.Lib +{ + public class CommandCategories + { + public const string Randomness = "Randomness"; + public const string Karma = "Karma"; + public const string Quotes = "Quotes"; + public const string Fun = "Fun"; + public const string Statistics = "Statistics"; + public const string Helpers = "Helpers"; + public const string Games = "Games"; + public const string Admin = "Admin"; + public const string Uncategorized = "Uncategorized"; + } +} \ No newline at end of file diff --git a/Geekbot.net/Program.cs b/Geekbot.net/Program.cs index 4693a51..637a8be 100755 --- a/Geekbot.net/Program.cs +++ b/Geekbot.net/Program.cs @@ -105,16 +105,16 @@ namespace Geekbot.net userRepository = new UserRepository(redis, logger); var errorHandler = new ErrorHandler(logger); - var RandomClient = new Random(); - var fortunes = new FortunesProvider(RandomClient, logger); - var mediaProvider = new MediaProvider(RandomClient, logger); + var randomClient = new Random(); + var fortunes = new FortunesProvider(randomClient, logger); + var mediaProvider = new MediaProvider(randomClient, logger); var malClient = new MalClient(redis, logger); services.AddSingleton(errorHandler); services.AddSingleton(redis); services.AddSingleton(logger); services.AddSingleton(userRepository); - services.AddSingleton(RandomClient); + services.AddSingleton(randomClient); services.AddSingleton(fortunes); services.AddSingleton(mediaProvider); services.AddSingleton(malClient); @@ -162,10 +162,7 @@ namespace Geekbot.net } if (!args.Contains("--disable-api")) { - logger.Information("[API] Starting Webserver"); - var webApiUrl = new Uri("http://localhost:12995"); - new NancyHost(webApiUrl).Start(); - logger.Information($"[API] Webserver now running on {webApiUrl}"); + startWebApi(); } logger.Information("[Geekbot] Done and ready for use\n"); @@ -185,6 +182,14 @@ namespace Geekbot.net return true; } + private async Task startWebApi() + { + logger.Information("[API] Starting Webserver"); + var webApiUrl = new Uri("http://localhost:12995"); + new NancyHost(webApiUrl).Start(); + logger.Information($"[API] Webserver now running on {webApiUrl}"); + } + private async Task FinishSetup() { var appInfo = await client.GetApplicationInfoAsync(); diff --git a/Geekbot.net/WebApi/HelpController.cs b/Geekbot.net/WebApi/HelpController.cs index b318b63..6146352 100644 --- a/Geekbot.net/WebApi/HelpController.cs +++ b/Geekbot.net/WebApi/HelpController.cs @@ -38,6 +38,7 @@ namespace Geekbot.net.WebApi { Name = cmd.Name, Summary = cmd.Summary, + Category = cmd.Remarks ?? CommandCategories.Uncategorized, IsAdminCommand = (param.Contains("admin")), Aliases = cmd.Aliases.ToArray(), Params = cmdParamsObj @@ -60,6 +61,7 @@ namespace Geekbot.net.WebApi 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; } diff --git a/Geekbot.net/WebApi/WebConfig.cs b/Geekbot.net/WebApi/WebConfig.cs index dfcfe01..7875ccb 100644 --- a/Geekbot.net/WebApi/WebConfig.cs +++ b/Geekbot.net/WebApi/WebConfig.cs @@ -1,4 +1,5 @@ -using Nancy; +using System; +using Nancy; using Nancy.Bootstrapper; using Nancy.TinyIoc; @@ -13,8 +14,9 @@ namespace Geekbot.net.WebApi pipelines.AfterRequest.AddItemToEndOfPipeline((ctx) => { ctx.Response.WithHeader("Access-Control-Allow-Origin", "*") - .WithHeader("Access-Control-Allow-Methods", "POST,GET") - .WithHeader("Access-Control-Allow-Headers", "Accept, Origin, Content-type"); + .WithHeader("Access-Control-Allow-Methods", "GET") + .WithHeader("Access-Control-Allow-Headers", "Accept, Origin, Content-type") + .WithHeader("Last-Modified", DateTime.Now.ToString()); }); }