Exemplo n.º 1
0
        private async Task Tweet(TimeSpan timeInLitterBox)
        {
            if (IsTweetingTooFrequently())
            {
                return;
            }

            if (DurationIsTooShort(timeInLitterBox))
            {
                return;
            }

            UpdateCounter();

            var message = GenerateMessage();

            _log.Verbose("Trying to tweet '" + message + "'.");

            try
            {
                await _twitterClientService.Tweet(message);

                _lastTweetTimestamp = DateTime.Now;
                _log.Info("Successfully tweeted: " + message);
            }
            catch (Exception exception)
            {
                _log.Warning("Failed to tweet. " + exception.Message);
            }
        }
Exemplo n.º 2
0
 public void Execute()
 {
     Task.Run(async() => await _twitterService.Tweet(_messageProvider()));
 }