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:""},
|
||||
user: {value:"false",required:true},
|
||||
name: {value:""},
|
||||
topic: {value:"tweets"}
|
||||
topic: {value:"tweets"},
|
||||
inputs: {value:0}
|
||||
},
|
||||
inputs: 1,
|
||||
inputs: 0,
|
||||
outputs: 1,
|
||||
icon: "twitter.png",
|
||||
label: function() {
|
||||
@ -188,16 +189,16 @@
|
||||
}
|
||||
});
|
||||
$("#node-input-user").change();
|
||||
}//,
|
||||
// oneditsave: function() {
|
||||
// if ($('#node-input-tags').val() === '' && $("#node-input-user option:selected").val() === 'false') {
|
||||
// this.inputs=1;
|
||||
// }
|
||||
// else {
|
||||
// //set back the default state of 0 inputs
|
||||
// this.inputs=0;
|
||||
// }
|
||||
// }
|
||||
},
|
||||
oneditsave: function() {
|
||||
if ($('#node-input-tags').val() === '' && $("#node-input-user option:selected").val() === 'false') {
|
||||
this.inputs = 1;
|
||||
}
|
||||
else {
|
||||
//set back the default state of 0 inputs
|
||||
//this.inputs = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -202,7 +202,7 @@ module.exports = function(RED) {
|
||||
twit.stream(thing, st, function(stream) {
|
||||
//console.log("ST",st);
|
||||
node.stream = stream;
|
||||
var retry = 15000; // 15 secs for general errors
|
||||
var retry = 60000; // 60 secs backoff for now
|
||||
stream.on('data', function(tweet) {
|
||||
if (tweet.user !== undefined) {
|
||||
var where = tweet.user.location;
|
||||
@ -213,20 +213,19 @@ module.exports = function(RED) {
|
||||
addLocationToTweet(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) {
|
||||
node.status({fill:"grey", shape:"dot", text:RED._("twitter.errors.limitrate")});
|
||||
//node.warn(RED._("twitter.errors.ratelimit"));
|
||||
//node.status({fill:"grey", shape:"dot", text:RED._("twitter.errors.limitrate")});
|
||||
node.status({fill:"grey", shape:"dot", text:(tags||" ")});
|
||||
});
|
||||
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")});
|
||||
retry = 60000; // 60 secs for rate limit
|
||||
//node.warn(RED._("twitter.errors.ratelimit"));
|
||||
} 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}));
|
||||
}
|
||||
twitterRateTimeout = Date.now() + retry;
|
||||
@ -235,7 +234,8 @@ module.exports = function(RED) {
|
||||
}
|
||||
});
|
||||
stream.on('destroy', function (response) {
|
||||
twitterRateTimeout = Date.now() + retry;
|
||||
//console.log("DEST",response)
|
||||
twitterRateTimeout = Date.now() + 15000;
|
||||
if (node.restart) {
|
||||
node.status({fill:"red", shape:"dot", text:" "});
|
||||
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")});
|
||||
}
|
||||
else {
|
||||
node.status({fill:"green", shape:"dot", text:(tags||" ")});
|
||||
this.restart = true;
|
||||
setupStream();
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
{
|
||||
"name" : "node-red-node-twitter",
|
||||
"version" : "0.1.6",
|
||||
"version" : "0.1.7",
|
||||
"description" : "A Node-RED node to talk to Twitter",
|
||||
"dependencies" : {
|
||||
"twitter-ng": "0.6.2",
|
||||
"oauth" : "0.9.14",
|
||||
"request" : "2.67.0"
|
||||
"request" : "^2.75.0"
|
||||
},
|
||||
"repository" : {
|
||||
"type":"git",
|
||||
|
Loading…
Reference in New Issue
Block a user