Skip to content

Commit

Permalink
Now emitting events for retweets
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Heap committed Nov 18, 2011
1 parent 4002fbb commit 539f9a7
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
{
if (typeof data.friends != "undefined")
{
this.emit("connect", data.friends);
this.emit("connect", recipient, data.friends);
}
}

Expand All @@ -131,20 +131,48 @@
{
if (typeof data.text != "undefined")
{
// If it was a retweet

// If it was a RT
if ( typeof data.retweeted_status != "undefined" )
{
this.emit("tweet", data.retweeted_status, data.retweeted_status.user);
this.emit("retweet", data.retweeted_status, data);
this.emit("user", data.retweeted_status.user);
this.emit("tweet", recipient, data.retweeted_status, data.retweeted_status.user);

this.emit("user", recipient, data.retweeted_status.user);

if (data.retweeted_status.in_reply_to_user_id_str == recipient){
self.emit("mention", recipient, data.retweeted_status);
}

// Retweets
if (data.user.id_str == recipient){
self.emit("retweet_by_me", recipient, data.retweeted_status, data);
}

if (data.retweeted_status.user.id_str == recipient){
self.emit("retweet_of_me", recipient, data.retweeted_status, data);
}

this.emit("retweet_by_following", recipient, data.retweeted_status, data);

}

// It's not a RT
else
{
this.emit("tweet", data, data.user);
this.emit("tweet", recipient, data, data.user);
if (data.in_reply_to_user_id_str == recipient){
self.emit("mention", recipient, data);
}
}

// Always save the person that RT'd
this.emit("user", data.user);
// Always, if it's a RT or not
if (data.user.id_str == recipient){
self.emit("own_tweet", recipient, data);
}

this.emit("user", recipient, data.user);



}

Expand Down

0 comments on commit 539f9a7

Please sign in to comment.