diff --git a/social/twitter/27-twitter.html b/social/twitter/27-twitter.html index 2ab8ad96..1f304a0e 100644 --- a/social/twitter/27-twitter.html +++ b/social/twitter/27-twitter.html @@ -90,6 +90,7 @@ +
Use space for and and comma , for or when searching for multiple terms.
If you want to pass in the search term(s) via the msg.payload
, leave the for field blank.
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.
+
When returning events it sets the msg.payload
to the twitter event, a full list is documented by
+ Twitter.
Sets msg.tweet
to the full tweet object as documented by Twitter.
+
+
Note: This node is not connected to the FireHose, so will not return 100% of all tweets to a busy @id or #hashtag.
Note: when set to follow specific users, or your direct messages, the node is subject to
the rate limiting of the Twitter API. 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 automatically when the current 15
@@ -143,6 +149,9 @@
var uname = RED.nodes.node(this.twitter);
if (this.user == "dm") {
return (uname?uname.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");
}
@@ -165,7 +174,7 @@
$("#node-input-tags-row").show();
$("#node-input-tags-label").html(userlabel);
$("#node-input-tags").attr("placeholder",userph);
- } else if ((type == "dm")||(type == "true")) {
+ } else if ((type == "dm")||(type == "true")||(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
index 62f6e5e6..a5db37de 100644
--- a/social/twitter/27-twitter.js
+++ b/social/twitter/27-twitter.js
@@ -175,6 +175,61 @@ module.exports = function(RED) {
},120000));
});
}
+ else if (this.user === "event") {
+ try {
+ var thingu = 'user';
+ var setupEvStream = function() {
+ if (node.active) {
+ twit.stream(thingu, st, function(stream) {
+ node.status({fill:"green", shape:"dot", text:" "});
+ node.stream = stream;
+ stream.on('data', function(tweet) {
+ if (tweet.event !== undefined) {
+ var where = tweet.source.location;
+ var la = tweet.source.lang;
+ var msg = { topic:node.topic+"/"+tweet.source.screen_name, payload:tweet.event, lang:la, tweet:tweet };
+ if (where) {
+ msg.location = {place:where};
+ addLocationToTweet(msg);
+ }
+ node.send(msg);
+ }
+ });
+ stream.on('limit', function(tweet) {
+ node.status({fill:"grey", shape:"dot", text:" "});
+ node.tout2 = setTimeout(function() { node.status({fill:"green", shape:"dot", text:" "}); },10000);
+ });
+ stream.on('error', function(tweet,rc) {
+ //console.log("ERRO",rc,tweet);
+ if (rc == 420) {
+ node.status({fill:"red", shape:"ring", text:RED._("twitter.errors.ratelimit")});
+ } else {
+ node.status({fill:"red", shape:"ring", text:" "});
+ node.warn(RED._("twitter.errors.streamerror",{error:tweet.toString(),rc:rc}));
+ }
+ twitterRateTimeout = Date.now() + retry;
+ if (node.restart) {
+ node.tout = setTimeout(function() { setupEvStream() },retry);
+ }
+ });
+ stream.on('destroy', function (response) {
+ //console.log("DEST",response)
+ twitterRateTimeout = Date.now() + 15000;
+ if (node.restart) {
+ node.status({fill:"red", shape:"dot", text:" "});
+ node.warn(RED._("twitter.errors.unexpectedend"));
+ node.tout = setTimeout(function() { setupEvStream() },15000);
+ }
+ });
+ });
+ }
+ }
+ setupEvStream();
+ }
+ catch (err) {
+ node.error(err);
+ }
+ }
else {
try {
var thing = 'statuses/filter';
diff --git a/social/twitter/README.md b/social/twitter/README.md
index ed6e01b3..033b5aac 100644
--- a/social/twitter/README.md
+++ b/social/twitter/README.md
@@ -33,9 +33,16 @@ Sets the `msg.topic` to *tweets/* and then appends the senders screen name.
Sets `msg.location` to the tweeters location if known.
+When returning events it sets the `msg.payload` to the twitter event, a full list is documented by
+Twitter.
+
+Sets `msg.tweet` to the full tweet object as documented by Twitter.
+
+**Note**: This node is not connected to the FireHose, so will not return 100% of all tweets to a busy @id or #hashtag.
+
Sets `msg.tweet` 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
+**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
passes.
diff --git a/social/twitter/locales/en-US/27-twitter.json b/social/twitter/locales/en-US/27-twitter.json
index 496eef09..d4684392 100644
--- a/social/twitter/locales/en-US/27-twitter.json
+++ b/social/twitter/locales/en-US/27-twitter.json
@@ -8,6 +8,7 @@
"dmslabel": "DMs",
"followers": "followed by",
"tweetslabel": "tweets",
+ "eventslabel": "events",
"clickhere": "Click here to authenticate with Twitter."
},
"placeholder": {
@@ -18,7 +19,8 @@
"public": "all public tweets",
"follow": "all tweets from people I 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.
Leave for blank to set using msg.payload.",
"status": {
diff --git a/social/twitter/package.json b/social/twitter/package.json
index a46cb91d..5fb4ac7c 100644
--- a/social/twitter/package.json
+++ b/social/twitter/package.json
@@ -1,6 +1,6 @@
{
"name" : "node-red-node-twitter",
- "version" : "0.1.8",
+ "version" : "0.1.9",
"description" : "A Node-RED node to talk to Twitter",
"dependencies" : {
"twitter-ng": "0.6.2",