public MatchedTweetReceivedEventArgs GetMatchingTweetEventArgsAndRaiseMatchingElements(ITweet tweet, string json, MatchOn matchOn) { var result = new MatchedTweetReceivedEventArgs(tweet, json); var trackMatcherConfig = new FilteredStreamMatcherConfig <string>(matchOn); var locationMatcherConfig = new FilteredStreamMatcherConfig <ILocation>(matchOn); var followersMatcherConfig = new FilteredStreamMatcherConfig <long>(matchOn); UpdateMatchesBasedOnTweetText(tweet, trackMatcherConfig, result); UpdateMatchesBasedOnUrlEntities(tweet, trackMatcherConfig, result); UpdateMatchesBasedOnHashTagEntities(tweet, trackMatcherConfig, result); UpdateMatchesBasedOnUserMentions(tweet, trackMatcherConfig, result); UpdateMatchesBasedOnSymbols(tweet, trackMatcherConfig, result); UpdateMatchesBasedOnTweetLocation(tweet, locationMatcherConfig, result); UpdateMatchesBasedOnTweetCreator(tweet, followersMatcherConfig, result); UpdateMatchesBasedOnTweetInReplyToUser(tweet, followersMatcherConfig, result); result.MatchingTracks = trackMatcherConfig.TweetMatchingTrackAndActions.Select(x => x.Key).ToArray(); result.MatchingLocations = locationMatcherConfig.TweetMatchingTrackAndActions.Select(x => x.Key).ToArray(); result.MatchingFollowers = followersMatcherConfig.TweetMatchingTrackAndActions.Select(x => x.Key).ToArray(); result.RetweetMatchingTracks = trackMatcherConfig.RetweetMatchingTrackAndActions.Select(x => x.Key).ToArray(); result.RetweetMatchingLocations = locationMatcherConfig.RetweetMatchingTrackAndActions.Select(x => x.Key).ToArray(); result.RetweetMatchingFollowers = followersMatcherConfig.RetweetMatchingTrackAndActions.Select(x => x.Key).ToArray(); result.QuotedTweetMatchingTracks = trackMatcherConfig.QuotedTweetMatchingTrackAndActions.Select(x => x.Key).ToArray(); result.QuotedTweetMatchingLocations = locationMatcherConfig.QuotedTweetMatchingTrackAndActions.Select(x => x.Key).ToArray(); result.QuotedTweetMatchingFollowers = followersMatcherConfig.QuotedTweetMatchingTrackAndActions.Select(x => x.Key).ToArray(); CallMultipleActions(tweet, trackMatcherConfig.GetAllMatchingTracks().Select(x => x.Value)); CallMultipleActions(tweet, locationMatcherConfig.GetAllMatchingTracks().Select(x => x.Value)); CallMultipleActions(tweet, followersMatcherConfig.GetAllMatchingTracks().Select(x => x.Value)); return(result); }
// Update Event Args private void UpdateMatchesBasedOnTweetText(ITweet tweet, FilteredStreamMatcherConfig <string> config, MatchedTweetReceivedEventArgs result) { if (config.MatchOn.HasFlag(MatchOn.Everything) || config.MatchOn.HasFlag(MatchOn.TweetText)) { GetMatchingTracksInTweetText(tweet, config.TweetMatchingTrackAndActions, () => result.MatchOn |= MatchOn.TweetText); if (tweet.RetweetedTweet != null) { GetMatchingTracksInTweetText(tweet.RetweetedTweet, config.RetweetMatchingTrackAndActions, () => result.RetweetMatchOn |= MatchOn.TweetText); } if (tweet.QuotedTweet != null) { GetMatchingTracksInTweetText(tweet.QuotedTweet, config.QuotedTweetMatchingTrackAndActions, () => result.QuotedTweetMatchOn |= MatchOn.TweetText); } } }
private void UpdateMatchesBasedOnTweetInReplyToUser(ITweet tweet, FilteredStreamMatcherConfig <long> config, MatchedTweetReceivedEventArgs result) { if (config.MatchOn.HasFlag(MatchOn.Everything) || config.MatchOn.HasFlag(MatchOn.FollowerInReplyTo)) { GetMatchingFollowersBasedOnTweetReply(tweet, config.TweetMatchingTrackAndActions, () => result.MatchOn |= MatchOn.FollowerInReplyTo); if (tweet.RetweetedTweet != null) { GetMatchingFollowersBasedOnTweetReply(tweet.RetweetedTweet, config.RetweetMatchingTrackAndActions, () => result.RetweetMatchOn |= MatchOn.FollowerInReplyTo); } if (tweet.QuotedTweet != null) { GetMatchingFollowersBasedOnTweetReply(tweet.QuotedTweet, config.QuotedTweetMatchingTrackAndActions, () => result.QuotedTweetMatchOn |= MatchOn.FollowerInReplyTo); } } }