/// <summary> /// Generates default command name->method pairs. /// </summary> void DefaultCommands(DiscordBot bot) { AdminCommands adminCmds = new AdminCommands(); MetaCommands metaCmds = new MetaCommands(); UtilityCommands utilCmds = new UtilityCommands(); CoreCommands coreCmds = new CoreCommands(IsBotCommander); // Informational bot.RegisterCommand(InfoCmds.CMD_Help, "help", "halp", "helps", "halps", "hel", "hal", "h"); bot.RegisterCommand(InfoCmds.CMD_Hello, "hello", "hi", "hey", "source", "src"); bot.RegisterCommand(InfoCmds.CMD_Info, "info", "notice", "alert"); bot.RegisterCommand(InfoCmds.CMD_Update, "update", "latest", "current", "build", "builds", "download", "version"); bot.RegisterCommand(InfoCmds.CMD_GitHub, "github", "git", "gh", "readme", "read", "link"); bot.RegisterCommand(InfoCmds.CMD_Issues, "issues", "issue", "error", "ghissues", "githubissues"); bot.RegisterCommand(InfoCmds.CMD_Rule, "rule", "rules"); bot.RegisterCommand(InfoCmds.CMD_Quote, "quote", "quotes", "q"); // Meta Docs bot.RegisterCommand(metaCmds.CMD_Command, "command", "commands", "cmd", "cmds", "c"); bot.RegisterCommand(metaCmds.CMD_Mechanism, "mechanism", "mechanisms", "mech", "mechs", "mec", "mecs", "m"); bot.RegisterCommand(metaCmds.CMD_Tag, "tag", "tags", "t"); bot.RegisterCommand(metaCmds.CMD_Event, "event", "events", "evt", "evts", "e"); bot.RegisterCommand(metaCmds.CMD_Action, "action", "actions", "act", "acts", "a"); bot.RegisterCommand(metaCmds.CMD_Language, "language", "languages", "lang", "langs", "l"); bot.RegisterCommand(metaCmds.CMD_Guide, "guide", "guides", "g", "beginner", "beginners", "beginnersguide", "guidepage", "guidespage"); bot.RegisterCommand(metaCmds.CMD_Search, "search", "s", "find", "f", "get", "locate", "what", "where", "how", "w", "meta", "metainfo", "docs", "doc", "documentation", "documentations", "document", "documents"); // Utility bot.RegisterCommand(utilCmds.CMD_LogCheck, "logcheck", "checklog", "logscheck", "checklogs"); bot.RegisterCommand(utilCmds.CMD_VersionCheck, "versioncheck", "checkversion", "iscurrent", "isuptodate", "isupdated", "checkcurrent", "currentcheck"); bot.RegisterCommand(utilCmds.CMD_ScriptCheck, "script", "scriptcheck", "dscript", "ds", "checkscript", "dscriptcheck", "checkdscript"); // Admin bot.RegisterCommand(coreCmds.CMD_Restart, "restart"); bot.RegisterCommand(adminCmds.CMD_Reload, "reload"); }
public void RegisterServices(IServiceCollection services) { DataServiceRegistration.Register(services); services .AddSingleton(InputParserOptions.Default) .AddSingleton <Action <IServiceProvider, IModuleFactory> >((serviceProvider, moduleFactory) => { var serviceCollector = TypeCollector.Create(type => type.IsInterface && type != typeof(IModule)); var services = serviceCollector.Collect <IModule>(definitions => definitions.DescribeAssembly <IModuleFactory>()); foreach (var service in services) { moduleFactory.Add(service.Name, (IModule)serviceProvider.GetRequiredService(service)); } }) .AddSingleton(UtilityCommands.GetCommands() .Union(ManagementCommands.GetCommands()) .Union(LoginCommands.GetCommands())) .AddSingleton <IApplicationSettings, ApplicationSettings>() .AddSingleton(typeof(IConsoleWrapper <>), typeof(ConsoleWrapper <>)) .RegisterCacheState <DateTimeOffset>() .RegisterServices(BuildSecurityProfiles, configureDistrubutedCacheOptions: ConfigureDistrubutedCacheOptions, configureDistributedCacheEntryOptions: ConfigureDistributedCacheEntryOptions, scannerConfiguration: scanner => scanner .FromAssemblyOf <ServiceRegistration>() .AddClasses(filter => filter.WithoutAttribute <IgnoreScanningAttribute>()) .AsMatchingInterface()); }
/// <summary> /// Generates default command name->method pairs. /// </summary> void DefaultCommands() { InfoCmds.Bot = this; AdminCommands adminCmds = new AdminCommands() { Bot = this }; MetaCommands metaCmds = new MetaCommands() { Bot = this }; UtilityCommands utilCmds = new UtilityCommands() { Bot = this }; // Informational RegisterCommand(InfoCmds.CMD_Help, "help", "halp", "helps", "halps", "hel", "hal", "h"); RegisterCommand(InfoCmds.CMD_Hello, "hello", "hi", "hey", "source", "src"); RegisterCommand(InfoCmds.CMD_Info, "info", "notice", "alert"); RegisterCommand(InfoCmds.CMD_Update, "update", "latest", "current", "build", "builds", "download", "version"); RegisterCommand(InfoCmds.CMD_GitHub, "github", "git", "gh", "readme", "read", "link"); RegisterCommand(InfoCmds.CMD_Issues, "issues", "issue", "error", "ghissues", "githubissues"); RegisterCommand(InfoCmds.CMD_Rule, "rule", "rules"); // Meta Docs RegisterCommand(metaCmds.CMD_Command, "command", "commands", "cmd", "cmds", "c"); RegisterCommand(metaCmds.CMD_Mechanism, "mechanism", "mechanisms", "mech", "mechs", "mec", "mecs", "m"); RegisterCommand(metaCmds.CMD_Tag, "tag", "tags", "t"); RegisterCommand(metaCmds.CMD_Event, "event", "events", "evt", "evts", "e"); RegisterCommand(metaCmds.CMD_Action, "action", "actions", "act", "acts", "a"); RegisterCommand(metaCmds.CMD_Language, "language", "languages", "lang", "langs", "l"); RegisterCommand(metaCmds.CMD_Search, "search", "s", "find", "f", "get", "g", "locate", "what", "where", "how", "w", "meta", "metainfo", "docs", "doc", "documentation", "documentations", "document", "documents"); // Utility // TODO: CMD_DScriptCheck RegisterCommand(utilCmds.CMD_LogCheck, "logcheck", "checklog", "logscheck", "checklogs"); RegisterCommand(utilCmds.CMD_VersionCheck, "versioncheck", "checkversion", "iscurrent", "isuptodate", "isupdated", "checkcurrent", "currentcheck"); // Admin RegisterCommand(adminCmds.CMD_Restart, "restart"); RegisterCommand(adminCmds.CMD_Reload, "reload"); }