protected override async Task <ActionModelBase> GetActionInternal()
 {
     if (this.ShowUsernameGrid)
     {
         return(TwitchActionModel.CreateUserAction(this.SelectedActionType, this.Username));
     }
     else if (this.ShowAdGrid)
     {
         return(TwitchActionModel.CreateAdAction(this.SelectedAdLength));
     }
     else if (this.ShowClipsGrid)
     {
         return(TwitchActionModel.CreateClipAction(this.ClipIncludeDelay, this.ShowInfoInChat));
     }
     else if (this.ShowStreamMarkerGrid)
     {
         return(TwitchActionModel.CreateStreamMarkerAction(this.StreamMarkerDescription, this.ShowInfoInChat));
     }
     else if (this.ShowUpdateChannelPointRewardGrid)
     {
         return(TwitchActionModel.CreateUpdateChannelPointReward(this.ChannelPointReward.id, this.ChannelPointRewardState, this.ChannelPointRewardCost,
                                                                 this.ChannelPointRewardUpdateCooldownsAndLimits, this.ChannelPointRewardMaxPerStream, this.ChannelPointRewardMaxPerUser, this.ChannelPointRewardGlobalCooldown));
     }
     else if (this.ShowPollGrid)
     {
         List <string> choices = new List <string>();
         if (!string.IsNullOrEmpty(this.PollChoice1))
         {
             choices.Add(this.PollChoice1);
         }
         if (!string.IsNullOrEmpty(this.PollChoice2))
         {
             choices.Add(this.PollChoice2);
         }
         if (!string.IsNullOrEmpty(this.PollChoice3))
         {
             choices.Add(this.PollChoice3);
         }
         if (!string.IsNullOrEmpty(this.PollChoice4))
         {
             choices.Add(this.PollChoice4);
         }
         return(TwitchActionModel.CreatePollAction(this.PollTitle, this.PollDurationSeconds, this.pollChannelPointsCost, this.pollBitsCost, choices, await this.ActionEditorList.GetActions()));
     }
     else if (this.ShowPredictionGrid)
     {
         return(TwitchActionModel.CreatePredictionAction(this.PredictionTitle, this.PredictionDurationSeconds, new List <string>()
         {
             this.PredictionOutcome1, this.PredictionOutcome2
         }, await this.ActionEditorList.GetActions()));
     }
     return(null);
 }
Esempio n. 2
0
        public async Task <IActionResult> AddReport([FromBody] TwitchActionModel model)
        {
            if (model == null)
            {
                _logger.LogInformation("Twitch action request received: no body");
                return(BadRequest("request was empty"));
            }

            if (string.IsNullOrEmpty(model.ModUsername))
            {
                _logger.LogInformation("Twitch action request received: no mod username");
                return(BadRequest("mod username was empty"));
            }

            if (string.IsNullOrEmpty(model.UserUsername))
            {
                _logger.LogInformation("Twitch action request received: no user username");
                return(BadRequest("user username was empty"));
            }

            if (string.IsNullOrEmpty(model.Action))
            {
                _logger.LogInformation("Twitch action request received: no action");
                return(BadRequest("action was empty"));
            }

            // FORMAT:
            // ACTION vaindil KeithyDee timeout 600 no reason
            var sb = new StringBuilder("ACTION ");

            sb.Append(model.ModUsername);
            sb.Append(' ');
            sb.Append(model.UserUsername);
            sb.Append(' ');
            sb.Append(model.Action);
            sb.Append(' ');
            sb.Append(model.Duration);
            sb.Append(' ');
            sb.Append(model.Reason);

            var final = sb.ToString();

            await _wsMgr.SendAllAsync(final);

            _logger.LogInformation($"Twitch action request received: {final}");

            return(NoContent());
        }
Esempio n. 3
0
 protected override Task <ActionModelBase> GetActionInternal()
 {
     if (this.ShowUsernameGrid)
     {
         return(Task.FromResult <ActionModelBase>(TwitchActionModel.CreateUserAction(this.SelectedActionType, this.Username)));
     }
     else if (this.ShowAdGrid)
     {
         return(Task.FromResult <ActionModelBase>(TwitchActionModel.CreateAdAction(this.SelectedAdLength)));
     }
     else if (this.ShowClipsGrid)
     {
         return(Task.FromResult <ActionModelBase>(TwitchActionModel.CreateClipAction(this.ClipIncludeDelay, this.ShowInfoInChat)));
     }
     else if (this.ShowStreamMarkerGrid)
     {
         return(Task.FromResult <ActionModelBase>(TwitchActionModel.CreateStreamMarkerAction(this.StreamMarkerDescription, this.ShowInfoInChat)));
     }
     return(Task.FromResult <ActionModelBase>(null));
 }
Esempio n. 4
0
 public TwitchActionEditorControlViewModel(TwitchActionModel action)
     : base(action)
 {
     this.SelectedActionType = action.ActionType;
     if (this.ShowUsernameGrid)
     {
         this.Username = action.Username;
     }
     else if (this.ShowAdGrid)
     {
         this.SelectedAdLength = action.AdLength;
     }
     else if (this.ShowClipsGrid)
     {
         this.ClipIncludeDelay = action.ClipIncludeDelay;
         this.ShowInfoInChat   = action.ShowInfoInChat;
     }
     else if (this.ShowStreamMarkerGrid)
     {
         this.StreamMarkerDescription = action.StreamMarkerDescription;
         this.ShowInfoInChat          = action.ShowInfoInChat;
     }
 }
        public TwitchActionEditorControlViewModel(TwitchActionModel action)
            : base(action, action.Actions)
        {
            this.SelectedActionType = action.ActionType;
            if (this.ShowUsernameGrid)
            {
                this.Username = action.Username;
            }
            else if (this.ShowAdGrid)
            {
                this.SelectedAdLength = action.AdLength;
            }
            else if (this.ShowClipsGrid)
            {
                this.ClipIncludeDelay = action.ClipIncludeDelay;
                this.ShowInfoInChat   = action.ShowInfoInChat;
            }
            else if (this.ShowStreamMarkerGrid)
            {
                this.StreamMarkerDescription = action.StreamMarkerDescription;
                this.ShowInfoInChat          = action.ShowInfoInChat;
            }
            else if (this.ShowUpdateChannelPointRewardGrid)
            {
#pragma warning disable CS0612 // Type or member is obsolete
                if (action.ChannelPointRewardCost >= 0)
                {
                    action.ChannelPointRewardCostString           = action.ChannelPointRewardCost.ToString();
                    action.ChannelPointRewardMaxPerStreamString   = action.ChannelPointRewardMaxPerStream.ToString();
                    action.ChannelPointRewardMaxPerUserString     = action.ChannelPointRewardMaxPerUser.ToString();
                    action.ChannelPointRewardGlobalCooldownString = action.ChannelPointRewardGlobalCooldown.ToString();

                    action.ChannelPointRewardCost           = -1;
                    action.ChannelPointRewardMaxPerStream   = -1;
                    action.ChannelPointRewardMaxPerUser     = -1;
                    action.ChannelPointRewardGlobalCooldown = -1;
                }
#pragma warning restore CS0612 // Type or member is obsolete

                this.existingChannelPointRewardID = action.ChannelPointRewardID;
                this.ChannelPointRewardState      = action.ChannelPointRewardState;
                this.ChannelPointRewardCost       = action.ChannelPointRewardCostString;
                this.ChannelPointRewardUpdateCooldownsAndLimits = action.ChannelPointRewardUpdateCooldownsAndLimits;
                this.ChannelPointRewardMaxPerStream             = action.ChannelPointRewardMaxPerStreamString;
                this.ChannelPointRewardMaxPerUser     = action.ChannelPointRewardMaxPerUserString;
                this.ChannelPointRewardGlobalCooldown = action.ChannelPointRewardGlobalCooldownString;
            }
            else if (this.ShowPollGrid)
            {
                this.PollTitle             = action.PollTitle;
                this.PollDurationSeconds   = action.PollDurationSeconds;
                this.pollChannelPointsCost = action.PollChannelPointsCost;
                this.pollBitsCost          = action.PollBitsCost;
                if (action.PollChoices.Count > 0)
                {
                    this.PollChoice1 = action.PollChoices[0];
                }
                if (action.PollChoices.Count > 1)
                {
                    this.PollChoice2 = action.PollChoices[1];
                }
                if (action.PollChoices.Count > 2)
                {
                    this.PollChoice3 = action.PollChoices[2];
                }
                if (action.PollChoices.Count > 3)
                {
                    this.PollChoice4 = action.PollChoices[3];
                }
            }
            else if (this.ShowPredictionGrid)
            {
                this.PredictionTitle           = action.PredictionTitle;
                this.PredictionDurationSeconds = action.PredictionDurationSeconds;
                this.PredictionOutcome1        = action.PredictionOutcomes[0];
                this.PredictionOutcome2        = action.PredictionOutcomes[1];
            }
        }