FilterStream replies

Sep 24, 2014 at 8:54 AM
I am using your filterstream object to collect tweets matching a given pattern and it works nicely. However, what I really need to do now is be able to also collect all the reply tweets to those tweets which match that given pattern.

What is the best way of doing this ?

Sep 24, 2014 at 9:14 AM
Edited Sep 24, 2014 at 9:14 AM
Hi MartR,

You should be able to use the ITweet.InReplyToStatusId property for this.

Since the reply and the original tweet have to match the same pattern, I think that both types of tweets are available from the same stream?

On the TweetReceived event, you can simply check if args.Tweet.InReplyToStatusId
var tweets = new List<ITweet>();
var replies = new List<ITweet>();

stream.TweetReceived += (sender, args) =>
    if (tweets.Any(t => t.Id == args.Tweet.InReplyToStatusId))
Let me know if this answers your question.

Marked as answer by linvi on 9/24/2014 at 7:33 AM
Sep 24, 2014 at 9:52 AM
Edited Sep 24, 2014 at 9:52 AM

Thanks for your reply.

I am using the filterstream.MatchingTweetReceived event so my problem is that events do not fire for replies (unless the have the same pattern that the root message has which causes its tweet to be passed via the event). Therefore I do not have the reply in order to test the InReplyToStatusID property.

Is there an alternative ?
Sep 24, 2014 at 10:49 AM
One alternative can be using Search.SearchTweets() to search for each @ScreenName that has a matching tweet. This will give the mentions of the user and you can then parse this data.

However, depending on the amount of data you wish to collect - you can quickly hit the rate limit.

Another way is adding a new follow to the stream. But this might lead to lost data as you have to stop and start the stream every time you add a new follow parameter.

Sorry I can't think of any foolproof way to achieve this. You may want to use a combination of above to ways.

Marked as answer by linvi on 9/24/2014 at 7:33 AM
Sep 24, 2014 at 12:12 PM
Thank you for your reply.