Example #1
0
        public Command CreateCommand(SlateBotController controller, CommandFile file)
        {
            bool moduleParsed = Enum.TryParse(file.Module, out ModuleType module);

            if (!moduleParsed)
            {
                module = ModuleType.General;
            }

            var dictionary = file.ExtraData;
            YouTubeCommandType youTubeCommandType = YouTubeCommandType.YouTube;

            bool valid = dictionary.Any();

            if (valid)
            {
                bool hasMirrorType = file.ExtraData.TryGetValue("YouTubeType", out IEnumerable <string> youTubeCommandTypeStr) > 0;
                if (hasMirrorType)
                {
                    valid = Enum.TryParse(youTubeCommandTypeStr.First(), out youTubeCommandType);
                }
                else
                {
                    valid = false;
                }
            }
            else
            {
                valid = false;
            }

            return(valid ? (new YouTubeCommand(controller.ErrorLogger, controller.waitHandler, controller, controller.languageHandler, file.Aliases, file.Examples, file.Help, module, youTubeCommandType)) : null);
        }
Example #2
0
 internal YouTubeCommand(IErrorLogger errorLogger, PleaseWaitHandler waitHandler, IAsyncResponder asyncResponder, LanguageHandler languageHandler, string[] aliases, string examples, string help, ModuleType module, YouTubeCommandType youTubeCommandType)
     : base(CommandHandlerType.YouTube, aliases, examples, help, module)
 {
     this.errorLogger        = errorLogger;
     this.waitHandler        = waitHandler;
     this.asyncResponder     = asyncResponder;
     this.languageHandler    = languageHandler;
     this.youTubeCommandType = youTubeCommandType;
 }