mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
More twitter rate fixes, Redo input pin logic
This commit is contained in:
parent
8a03773567
commit
3ff0b6a761
@ -145,9 +145,10 @@
|
|||||||
tags: {value:""},
|
tags: {value:""},
|
||||||
user: {value:"false",required:true},
|
user: {value:"false",required:true},
|
||||||
name: {value:""},
|
name: {value:""},
|
||||||
topic: {value:"tweets"}
|
topic: {value:"tweets"},
|
||||||
|
inputs: {value:0}
|
||||||
},
|
},
|
||||||
inputs: 1,
|
inputs: 0,
|
||||||
outputs: 1,
|
outputs: 1,
|
||||||
icon: "twitter.png",
|
icon: "twitter.png",
|
||||||
label: function() {
|
label: function() {
|
||||||
@ -188,16 +189,16 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
$("#node-input-user").change();
|
$("#node-input-user").change();
|
||||||
}//,
|
},
|
||||||
// oneditsave: function() {
|
oneditsave: function() {
|
||||||
// if ($('#node-input-tags').val() === '' && $("#node-input-user option:selected").val() === 'false') {
|
if ($('#node-input-tags').val() === '' && $("#node-input-user option:selected").val() === 'false') {
|
||||||
// this.inputs=1;
|
this.inputs = 1;
|
||||||
// }
|
}
|
||||||
// else {
|
else {
|
||||||
// //set back the default state of 0 inputs
|
//set back the default state of 0 inputs
|
||||||
// this.inputs=0;
|
//this.inputs = 0;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ module.exports = function(RED) {
|
|||||||
twit.stream(thing, st, function(stream) {
|
twit.stream(thing, st, function(stream) {
|
||||||
//console.log("ST",st);
|
//console.log("ST",st);
|
||||||
node.stream = stream;
|
node.stream = stream;
|
||||||
var retry = 15000; // 15 secs for general errors
|
var retry = 60000; // 60 secs backoff for now
|
||||||
stream.on('data', function(tweet) {
|
stream.on('data', function(tweet) {
|
||||||
if (tweet.user !== undefined) {
|
if (tweet.user !== undefined) {
|
||||||
var where = tweet.user.location;
|
var where = tweet.user.location;
|
||||||
@ -213,20 +213,19 @@ module.exports = function(RED) {
|
|||||||
addLocationToTweet(msg);
|
addLocationToTweet(msg);
|
||||||
}
|
}
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
node.status({fill:"green", shape:"dot", text:(tags||" ")});
|
//node.status({fill:"green", shape:"dot", text:(tags||" ")});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
stream.on('limit', function(tweet) {
|
stream.on('limit', function(tweet) {
|
||||||
node.status({fill:"grey", shape:"dot", text:RED._("twitter.errors.limitrate")});
|
//node.status({fill:"grey", shape:"dot", text:RED._("twitter.errors.limitrate")});
|
||||||
//node.warn(RED._("twitter.errors.ratelimit"));
|
node.status({fill:"grey", shape:"dot", text:(tags||" ")});
|
||||||
});
|
});
|
||||||
stream.on('error', function(tweet,rc) {
|
stream.on('error', function(tweet,rc) {
|
||||||
|
//console.log("ERRO",rc,tweet);
|
||||||
if (rc == 420) {
|
if (rc == 420) {
|
||||||
node.status({fill:"red", shape:"ring", text:RED._("twitter.errors.ratelimit")});
|
node.status({fill:"red", shape:"ring", text:RED._("twitter.errors.ratelimit")});
|
||||||
retry = 60000; // 60 secs for rate limit
|
|
||||||
//node.warn(RED._("twitter.errors.ratelimit"));
|
|
||||||
} else {
|
} else {
|
||||||
node.status({fill:"red", shape:"ring", text:"rc:"+rc});
|
node.status({fill:"red", shape:"ring", text:tweet.toString()});
|
||||||
node.warn(RED._("twitter.errors.streamerror",{error:tweet.toString(),rc:rc}));
|
node.warn(RED._("twitter.errors.streamerror",{error:tweet.toString(),rc:rc}));
|
||||||
}
|
}
|
||||||
twitterRateTimeout = Date.now() + retry;
|
twitterRateTimeout = Date.now() + retry;
|
||||||
@ -235,7 +234,8 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
stream.on('destroy', function (response) {
|
stream.on('destroy', function (response) {
|
||||||
twitterRateTimeout = Date.now() + retry;
|
//console.log("DEST",response)
|
||||||
|
twitterRateTimeout = Date.now() + 15000;
|
||||||
if (node.restart) {
|
if (node.restart) {
|
||||||
node.status({fill:"red", shape:"dot", text:" "});
|
node.status({fill:"red", shape:"dot", text:" "});
|
||||||
node.warn(RED._("twitter.errors.unexpectedend"));
|
node.warn(RED._("twitter.errors.unexpectedend"));
|
||||||
@ -303,7 +303,7 @@ module.exports = function(RED) {
|
|||||||
node.status({fill:"yellow", shape:"ring", text:RED._("twitter.warn.waiting")});
|
node.status({fill:"yellow", shape:"ring", text:RED._("twitter.warn.waiting")});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
node.status({fill:"green", shape:"dot", text:(tags||" ")});
|
this.restart = true;
|
||||||
setupStream();
|
setupStream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-twitter",
|
"name" : "node-red-node-twitter",
|
||||||
"version" : "0.1.6",
|
"version" : "0.1.7",
|
||||||
"description" : "A Node-RED node to talk to Twitter",
|
"description" : "A Node-RED node to talk to Twitter",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"twitter-ng": "0.6.2",
|
"twitter-ng": "0.6.2",
|
||||||
"oauth" : "0.9.14",
|
"oauth" : "0.9.14",
|
||||||
"request" : "2.67.0"
|
"request" : "^2.75.0"
|
||||||
},
|
},
|
||||||
"repository" : {
|
"repository" : {
|
||||||
"type":"git",
|
"type":"git",
|
||||||
|
Loading…
Reference in New Issue
Block a user