Пример #1
0
        public async Task <DateTime> AddTimeout(string recipient, int broadcasterId, double seconds, string twitchBotApiLink)
        {
            DateTime timeoutExpiration = DateTime.UtcNow.AddSeconds(seconds);

            UserBotTimeout timedoutUser = new UserBotTimeout();

            if (TimedoutUsers.Any(m => m.Username == recipient))
            {
                timedoutUser = await ApiBotRequest.PatchExecuteTaskAsync <UserBotTimeout>(
                    twitchBotApiLink + $"userbottimeouts/patch/{broadcasterId}?username={recipient}",
                    "timeout",
                    timeoutExpiration);

                TimedoutUsers.RemoveAll(t => t.Username == recipient);
            }
            else
            {
                timedoutUser = await ApiBotRequest.PostExecuteTaskAsync(
                    twitchBotApiLink + $"userbottimeouts/create",
                    new UserBotTimeout { Username = recipient, Timeout = timeoutExpiration, Broadcaster = broadcasterId }
                    );
            }

            TimedoutUsers.Add(new TimeoutUser
            {
                Username             = recipient,
                TimeoutExpirationUtc = timeoutExpiration,
                HasBeenWarned        = false
            });

            return(timeoutExpiration);
        }