Command Categories (more or less)

This commit is contained in:
Runebaas 2017-10-12 16:34:10 +02:00
parent f30c136785
commit 58ba2980f9
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
29 changed files with 97 additions and 17 deletions

View file

@ -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");

View file

@ -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)
{

View file

@ -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()
{

View file

@ -25,6 +25,7 @@ namespace Geekbot.net.Commands
}
[Command("checkem", RunMode = RunMode.Async)]
[Remarks(CommandCategories.Randomness)]
[Summary("Check for dubs")]
public async Task MuhDubs()
{

View file

@ -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(';');

View file

@ -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)
{

View file

@ -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")
{

View file

@ -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()
{

View file

@ -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)
{

View file

@ -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()
{

View file

@ -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)
{

View file

@ -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()
{

View file

@ -19,6 +19,7 @@ namespace Geekbot.net.Commands
}
[Command("help", RunMode = RunMode.Async)]
[Remarks(CommandCategories.Helpers)]
[Summary("List all Commands")]
public async Task GetHelp()
{

View file

@ -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()
{

View file

@ -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!");

View file

@ -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)
{

View file

@ -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)
{

View file

@ -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()
{

View file

@ -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()
{

View file

@ -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;

View file

@ -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)
{

View file

@ -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)
{

View file

@ -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)
{

View file

@ -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)
{

View file

@ -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)
{

View file

@ -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";
}
}

View file

@ -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<IErrorHandler>(errorHandler);
services.AddSingleton(redis);
services.AddSingleton<ILogger>(logger);
services.AddSingleton<IUserRepository>(userRepository);
services.AddSingleton(RandomClient);
services.AddSingleton(randomClient);
services.AddSingleton<IFortunesProvider>(fortunes);
services.AddSingleton<IMediaProvider>(mediaProvider);
services.AddSingleton<IMalClient>(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<Task> FinishSetup()
{
var appInfo = await client.GetApplicationInfoAsync();

View file

@ -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; }

View file

@ -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());
});
}