distinguishing Track from Follow

Sep 24, 2014 at 1:01 PM
I have a number of tracks and follows set up on a filterstream.
When a tracked tweet arrives and the MatchingTweetReceived() event fires, I have context about which track it is from the e.MatchingTracks array

When a followed tweet arrives the same event fires but how can I tell which Follow caused it. e.MatchingTracks is empty - is this all I have to be able to determine that it is not caused by a Track and is caused by a Follow. ?

Thanks
Editor
Sep 24, 2014 at 1:20 PM
I think the twitter stream doesn't provide this information. Even the e.MatchingTracks is populated behind the scenes by tweetinvi.

So a tweet could be matching both a track and a follow parameter.

Twitter provides this information about the follow parameter.
For each user specified in the follow parameter, the stream will contain:
  • Tweets created by the user.
  • Tweets which are retweeted by the user.
  • Replies to any Tweet created by the user.
  • Retweets of any Tweet created by the user.
  • Manual replies, created without pressing a reply button (e.g. “@twitterapi I agree”).
ref: https://dev.twitter.com/streaming/overview/request-parameters#follow

I think you can use this information to get MatchingFollows.

imlokesh
Marked as answer by linvi on 9/24/2014 at 7:29 AM
Coordinator
Sep 24, 2014 at 1:39 PM
Imlokesh is right, a Tweet can be matching both a Track and a Follow.

Therefore you can get this information easily by checking the Creator Id of a Tweet.
var ids = new HashSet<long>( /* Put your follower ids here */ );

var fs = Stream.CreateFilteredStream();
ids.ForEach(id => fs.AddFollow(id));

fs.MatchingTweetReceived += (sender, args) =>
{
    var tweet = args.Tweet;
    var followerId = tweet.Creator.Id;

    if (ids.Contains(followerId))
    {
        // Follower posted this tweet
    }
};

fs.StartStreamMatchingAnyCondition();
Please note that I am using a HashSet and its .Contains method for obvious performance issues.

Linvi
Marked as answer by linvi on 9/24/2014 at 7:29 AM
Sep 24, 2014 at 2:13 PM
Thanks guys. As I am not interested in Retweets, I think it is probably easier to set up a filter and just check the Creator.Id and InReplyTo.id.
Coordinator
Sep 24, 2014 at 2:29 PM
Just check the Tweet.IsRetweet property.
if (tweet.IsRetweet)
{
    return;
}
Linvi