Exemplo n.º 1
0
        public Task Handle(RestoreCommand notification, CancellationToken cancellationToken)
        {
            var i = _obs.OBSClient
                    .GetSourceFilters("Main")
                    .Where(sf => sf.IsEnabled && sf.Type.Equals("move_source_filter", StringComparison.InvariantCultureIgnoreCase))
                    .ToList();

            if (!i.Any())
            {
                return(Task.CompletedTask);
            }
            var active = i.FirstOrDefault(sf => sf.Name.Equals("Main075"))
                         ?? i.First();

            if (active == null)
            {
                return(Task.CompletedTask);
            }
            _obs.TriggerHotKeyByName(active.Name);
            foreach (var current in i)
            {
                current.Settings["activated"] = current.Name.Equals(active.Name);
                _obs.OBSClient.SetSourceFilterSettings("Main", current.Name, current.Settings);
            }
            return(Task.CompletedTask);
        }
Exemplo n.º 2
0
        public async Task Handle(GrowCommand notification, CancellationToken cancellationToken)
        {
            var e = notification.RewardRedeemedArgs;
            var i = _obs.OBSClient
                    .GetSourceFilters("Main")
                    .Where(sf => sf.IsEnabled && sf.Type.Equals("move_source_filter", StringComparison.InvariantCultureIgnoreCase))
                    .ToList();

            if (!i.Any())
            {
                await Cancel(e);

                return;
            }
            var active =
                i.FirstOrDefault(sf => sf.Settings["activated"] != null && (bool)sf.Settings["activated"])
                ?? i.FirstOrDefault(sf => sf.Name.Equals("Main075"))
                ?? i.First();

            if (active == null)
            {
                await Cancel(e);

                return;
            }
            var nextIndex = i.IndexOf(active) + 1;

            if (nextIndex > i.Count - 1)
            {
                await Cancel(e);

                return;
            }
            var next = i[nextIndex];

            _obs.TriggerHotKeyByName(next.Name);
            await _api.UpdateChannelRedemptionStatus($"{e.RedemptionId:D}", $"{e.RewardId:D}", RedemptionStatus.FULFILLED);

            for (var p = 0; p < i.Count; p++)
            {
                var current = i[p];
                current.Settings["activated"] = p == nextIndex;
                _obs.OBSClient.SetSourceFilterSettings("Main", current.Name, current.Settings);
            }
        }