Пример #1
0
        public void Execute(SupportedReward reward, OnRewardRedeemedArgs args)
        {
            if (!string.IsNullOrWhiteSpace(args.Message) && int.TryParse(args.Message.Trim(), out int replayId))
            {
                Task.Factory.StartNew(async() =>
                {
                    RewardResponse response = await queue.EnqueueItemAsync(requestFactory.Create(reward, args));

                    if (settings.Twitch.EnableChatBot)
                    {
                        string message = $"{args.DisplayName}, {response.Message}";
                        twitchClient.SendMessage(settings.Twitch.Channel, message, dryRun: settings.Twitch.DryRunMode);
                    }
                }, TaskCreationOptions.LongRunning);
            }
            else
            {
                twitchClient.SendMessage(settings.Twitch.Channel, $"{args.DisplayName}, your request is invalid.", dryRun: settings.Twitch.DryRunMode);
                logger.LogDebug($"{args.TimeStamp}: {args.RewardId} - {args.RewardCost}");
            }
        }
Пример #2
0
        public void Execute(SupportedReward reward, OnRewardRedeemedArgs args)
        {
            Task.Factory.StartNew(async() =>
            {
                try
                {
                    logger.LogInformation($"{args.Login} has redeemed {args.RewardTitle}");

                    RewardResponse response = await queue.EnqueueItemAsync(rewardRequestFactory.Create(reward, args));

                    if (settings.Twitch.EnableChatBot)
                    {
                        twitchClient.SendMessage(settings.Twitch.Channel, $"{args.DisplayName}, {response.Message}", dryRun: settings.Twitch.DryRunMode);
                    }
                }
                catch (Exception e)
                {
                    logger.LogError(e, $"Could not queue reward: {reward.Title}");
                }
            }, TaskCreationOptions.LongRunning);
        }