diff --git a/social/twitter/27-twitter.html b/social/twitter/27-twitter.html old mode 100644 new mode 100755 index 456b4c20..6bb93ef2 --- a/social/twitter/27-twitter.html +++ b/social/twitter/27-twitter.html @@ -105,6 +105,7 @@ +
Use space for and and comma , for or when searching for multiple terms.
+Use space for and ,a comma for or ,when searching for multiple terms.
+When returning tweets or DM's:
Sets the msg.topic to tweets/ and then appends the senders screen name.
Sets msg.location to the tweeters location if known.
-Sets msg.tweet to the full tweet object as documented by Twitter. +
Sets msg.tweet to the full tweet object as documented by Twitter.
+When returning events:
+Sets the msg.event to the twitter event, a full list is documented by Twitter.
+Sets msg.payload to the full tweet object as documented by Twitter.
+Note: when set to a specific user's tweets, or your direct messages, the node is subject to
       Twitter's API rate limiting. If you deploy the flows multiple times within a 15 minute window, you may
       exceed the limit and will see errors from the node. These errors will clear when the current 15 minute window
@@ -155,6 +162,9 @@
             if (this.user == "dm") {
                 var user = RED.nodes.node(this.twitter);
                 return (user?user.label()+" ":"")+this._("twitter.label.dmslabel");
+            } else if (this.user == "event") {
+                var user = RED.nodes.node(this.twitter);
+                return (user?user.label()+" ":"")+this._("twitter.label.eventslabel");
             } else if (this.user == "user") {
                 return this.tags+" "+this._("twitter.label.tweetslabel");
             }
@@ -174,7 +184,7 @@
                     $("#node-input-tags-row").show();
                     $("#node-input-tags-label").html(userlabel);
                     $("#node-input-tags").attr("placeholder",userph);
-                } else if (type == "dm") {
+                } else if (type == "dm" || type == "event") {
                     $("#node-input-tags-row").hide();
                 } else {
                     $("#node-input-tags-row").show();
diff --git a/social/twitter/27-twitter.js b/social/twitter/27-twitter.js
old mode 100644
new mode 100755
index f0e24e04..928d0059
--- a/social/twitter/27-twitter.js
+++ b/social/twitter/27-twitter.js
@@ -182,6 +182,48 @@ module.exports = function(RED) {
                     },120000));
                 });
 
+            } else if (this.user === "event") {
+                try {
+                    var thing = 'user';
+                    var setupStream = function() {
+                        if (node.active) {
+                            twit.stream(thing, st, function(stream) {
+                                //twit.stream('user', { track: [node.tags] }, function(stream) {
+                                node.stream = stream;
+                                stream.on('data', function(tweet) {
+                                    if (tweet.event !== undefined) {
+                                        console.log("stream event"+tweet.event);
+                                        console.log(tweet);
+                                        var la = tweet.target.lang || tweet.source.lang;
+                                        var msg = { event:tweet.event, payload:tweet  };
+                                        node.send(msg);
+                                    }
+                                });
+                                stream.on('limit', function(tweet) {
+                                    node.warn("tweet rate limit hit");
+                                });
+                                stream.on('error', function(tweet,rc) {
+                                    if (rc == 420) {
+                                        node.warn("Twitter rate limit hit");
+                                    } else {
+                                        node.warn("Stream error:"+tweet.toString()+" ("+rc+")");
+                                    }
+                                    setTimeout(setupStream,10000);
+                                });
+                                stream.on('destroy', function (response) {
+                                    if (this.active) {
+                                        node.warn("twitter ended unexpectedly");
+                                        setTimeout(setupStream,10000);
+                                    }
+                                });
+                            });
+                        }
+                    }
+                    setupStream();
+                }
+                catch (err) {
+                    node.error(err);
+                } 
             } else if (this.tags !== "") {
                 try {
                     var thing = 'statuses/filter';
diff --git a/social/twitter/locales/en-US/27-twitter.json b/social/twitter/locales/en-US/27-twitter.json
index 81213943..309ef13d 100644
--- a/social/twitter/locales/en-US/27-twitter.json
+++ b/social/twitter/locales/en-US/27-twitter.json
@@ -7,6 +7,7 @@
             "user": "User",
             "dmslabel": "DMs",
             "tweetslabel": "tweets",
+            "eventslabel": "events",
             "clickhere": "Click here to authenticate with Twitter."
         },
         "placeholder": {
@@ -17,7 +18,8 @@
             "public": "all public tweets",
             "follow": "the tweets of who you follow",
             "user": "the tweets of specific users",
-            "direct": "your direct messages"
+            "direct": "your direct messages",
+            "events": "your twitter events"
         },
         "tip": "Tip: Use commas without spaces between multiple search terms. Comma = OR, Space = AND.
The Twitter API WILL NOT deliver 100% of all tweets.
Tweets of who you follow will include their retweets and favourites.",
         "status": {