예제 #1
0
        protected override async Task OnLoaded()
        {
            await base.OnLoaded();

            try
            {
                if (this.command != null)
                {
                    this.uploadCommand = new CommunityCommandUploadModel()
                    {
                        ID   = this.command.ID,
                        Name = this.command.Name,
                    };

                    this.uploadCommand.SetCommands(new List <CommandModelBase>()
                    {
                        this.command
                    });

                    CommunityCommandDetailsModel existingCommand = await ChannelSession.Services.CommunityCommandsService.GetCommandDetails(command.ID);

                    if (existingCommand != null)
                    {
                        this.uploadCommand.ID          = existingCommand.ID;
                        this.uploadCommand.Description = existingCommand.Description;
                    }

                    this.uploadCommand.Tags.Clear();
                    foreach (ActionModelBase action in this.command.Actions)
                    {
                        if (action is ConditionalActionModel)
                        {
                            foreach (ActionModelBase subAction in ((ConditionalActionModel)action).Actions)
                            {
                                this.uploadCommand.Tags.Add((CommunityCommandTagEnum)subAction.Type);
                            }
                        }
                        this.uploadCommand.Tags.Add((CommunityCommandTagEnum)action.Type);
                    }

                    switch (this.command.Type)
                    {
                    case CommandTypeEnum.Chat: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.ChatCommand); break;

                    case CommandTypeEnum.Event: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.EventCommand); break;

                    case CommandTypeEnum.ActionGroup: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.ActionGroupCommand); break;

                    case CommandTypeEnum.Timer: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.TimerCommand); break;

                    case CommandTypeEnum.Game: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.GameCommand); break;

                    case CommandTypeEnum.StreamlootsCard: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.StreamlootsCardCommand); break;

                    case CommandTypeEnum.TwitchChannelPoints: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.TwitchChannelPointsCommand); break;

                    case CommandTypeEnum.Webhook: this.uploadCommand.Tags.Add(CommunityCommandTagEnum.Webhook); break;
                    }
                }
                else
                {
                    this.uploadCommand = new CommunityCommandUploadModel()
                    {
                        ID          = this.ccCommand.ID,
                        Name        = this.ccCommand.Name,
                        Description = this.ccCommand.Description,
                    };
                }

                this.NameTextBox.Text        = this.uploadCommand.Name;
                this.DescriptionTextBox.Text = this.uploadCommand.Description;

                if (this.uploadCommand.Tags.Contains(CommunityCommandTagEnum.Sound) || this.uploadCommand.Tags.Contains(CommunityCommandTagEnum.Overlay) ||
                    this.uploadCommand.Tags.Contains(CommunityCommandTagEnum.File) || this.uploadCommand.Tags.Contains(CommunityCommandTagEnum.ExternalProgram))
                {
                    this.commandContainsMedia = true;
                }

                if (this.uploadCommand.Tags.Contains(CommunityCommandTagEnum.Command))
                {
                    this.commandReferencesOtherCommand = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
예제 #2
0
        public async Task <CommunityCommandDetailsModel> AddOrUpdateCommand(CommunityCommandUploadModel command)
        {
            await EnsureLogin();

            return(await PostAsync <CommunityCommandDetailsModel>("community/commands/command", AdvancedHttpClient.CreateContentFromObject(command)));
        }