コード例 #1
0
        public override async Task HandleAsync <T>(ContentRequestNotification notification, ILogger <T> logger)
        {
            RawTweet videoTweet = await twitterRepository.FindByIdAsync(notification.IdOfTweetBeingRepliedTo.Value);

            TweetNotification tweetNotification = new TweetNotification(videoTweet, notification.IdOfRequestingTweet, notification.RequestedBy);

            if (tweetNotification.HasVideo())
            {
                var video   = tweetNotification.GetVideo();
                var request = tweetNotification.GetVideoRequest(video.Id);

                await scraperRepository.CaptureTwitterVideoAndRequestAsync(request, video);

                string response = video.GetResponseContent(settings.BaseUrl, request.RequestedBy);
                //send back response
                await twitterRepository.ReplyToTweetAsync(request.RequestingTweetId, response);

                logger.LogInformation($"Sent back this response -> {response}");
            }
            else
            {
                logger.LogWarning($"The tweet being responded to didn't have a video -> {tweetNotification.TweetWithVideo.id}");
                await base.HandleAsync(notification, logger);
            }
        }
コード例 #2
0
        public override async Task HandleAsync <T>(ContentRequestNotification notification, ILogger <T> logger)
        {
            TwitterVideo twitterVideo;
            bool         exists = scraperRepository.GetIfVideoExists(notification.IdOfTweetBeingRepliedTo.Value, out twitterVideo);

            if (exists)
            {
                logger.LogInformation($"This tweet existed {notification.IdOfTweetBeingRepliedTo.Value}.");

                var request = new TwitterVideoRequest(notification.IdOfRequestingTweet, twitterVideo.Id, notification.RequestedBy);

                await scraperRepository.CaptureTwitterRequestAsync(request);

                string response = twitterVideo.GetResponseContent(settings.BaseUrl, request.RequestedBy);
                //send back response
                await twitterRepository.ReplyToTweetAsync(notification.IdOfRequestingTweet, response);

                return;
            }
            else
            {
                await base.HandleAsync(notification, logger);
            }
        }