mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Tidy up twitter node info
and re-order code to make more logical. (or at least readable)
This commit is contained in:
parent
c456f89441
commit
eeb1189092
@ -120,8 +120,9 @@
|
|||||||
|
|
||||||
<script type="text/x-red" data-help-name="twitter in">
|
<script type="text/x-red" data-help-name="twitter in">
|
||||||
<p>Twitter input node. Can be used to search either:
|
<p>Twitter input node. Can be used to search either:
|
||||||
<ul><li>the public or a user's stream for tweets containing the configured search term</li>
|
<ul><li>the public stream for tweets containing the configured search term</li>
|
||||||
<li>all tweets by specific users</li>
|
<li>all the tweets from accounts that the authenticated user follows</li>
|
||||||
|
<li>all tweets by specified users</li>
|
||||||
<li>direct messages received by the authenticated user</li>
|
<li>direct messages received by the authenticated user</li>
|
||||||
</ul></p>
|
</ul></p>
|
||||||
<p>Use space for <i>and</i> and comma , for <i>or</i> when searching for multiple terms.
|
<p>Use space for <i>and</i> and comma , for <i>or</i> when searching for multiple terms.
|
||||||
@ -129,10 +130,10 @@
|
|||||||
<p>Sets the <code>msg.topic</code> to <i>tweets/</i> and then appends the senders screen name.</p>
|
<p>Sets the <code>msg.topic</code> to <i>tweets/</i> and then appends the senders screen name.</p>
|
||||||
<p>Sets <code>msg.location</code> to the tweeters location if known.</p>
|
<p>Sets <code>msg.location</code> to the tweeters location if known.</p>
|
||||||
<p>Sets <code>msg.tweet</code> to the full tweet object as documented by <a href="https://dev.twitter.com/overview/api/tweets">Twitter</a>.
|
<p>Sets <code>msg.tweet</code> to the full tweet object as documented by <a href="https://dev.twitter.com/overview/api/tweets">Twitter</a>.
|
||||||
<p><b>Note:</b> when set to a specific user's tweets, or your direct messages, the node is subject to
|
<p><b>Note:</b> when set to follow specific users, 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
|
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 when the current 15 minute window
|
exceed the limit and will see errors from the node. These errors will clear automatically when the current 15
|
||||||
passes.</p>
|
minute window passes.</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -153,14 +154,14 @@
|
|||||||
if (this.name) {
|
if (this.name) {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
var uname = RED.nodes.node(this.twitter);
|
||||||
if (this.user == "dm") {
|
if (this.user == "dm") {
|
||||||
var user = RED.nodes.node(this.twitter);
|
return (uname?uname.label()+" ":"")+this._("twitter.label.dmslabel");
|
||||||
return (user?user.label()+" ":"")+this._("twitter.label.dmslabel");
|
|
||||||
} else if (this.user == "user") {
|
} else if (this.user == "user") {
|
||||||
return this.tags+" "+this._("twitter.label.tweetslabel");
|
return this.tags+" "+this._("twitter.label.tweetslabel");
|
||||||
}
|
}
|
||||||
else if (this.user == "true") {
|
else if (this.user == "true") {
|
||||||
return this._("twitter.label.followers");
|
return this._("twitter.label.followers") + (uname?(" "+uname.label()):"");
|
||||||
}
|
}
|
||||||
return "twitter";
|
return "twitter";
|
||||||
},
|
},
|
||||||
|
@ -194,24 +194,6 @@ module.exports = function(RED) {
|
|||||||
var thing = 'statuses/filter';
|
var thing = 'statuses/filter';
|
||||||
var tags = node.tags;
|
var tags = node.tags;
|
||||||
var st = { track: [tags] };
|
var st = { track: [tags] };
|
||||||
if (this.user === "true") {
|
|
||||||
thing = 'user';
|
|
||||||
//st.with = "user";
|
|
||||||
// twit.getFriendsIds(node.twitterConfig.screen_name.substr(1), function(err,list) {
|
|
||||||
// friends = list;
|
|
||||||
// });
|
|
||||||
st = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var bits = node.tags.split(",");
|
|
||||||
if (bits.length == 4) {
|
|
||||||
if ((Number(bits[0]) < Number(bits[2])) && (Number(bits[1]) < Number(bits[3]))) {
|
|
||||||
st = { locations: node.tags };
|
|
||||||
node.log(RED._("twitter.status.using-geo",{location:node.tags.toString()}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var setupStream = function() {
|
var setupStream = function() {
|
||||||
if (node.active) {
|
if (node.active) {
|
||||||
@ -228,10 +210,7 @@ module.exports = function(RED) {
|
|||||||
addLocationToTweet(msg);
|
addLocationToTweet(msg);
|
||||||
}
|
}
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
if (tags !== "zyxxyzyxxyzyxxyzyxxyzyxxyzyxxy") {
|
node.status({fill:"green", shape:"dot", text:(tags||" ")});
|
||||||
node.status({fill:"green", shape:"dot", text:tags});
|
|
||||||
}
|
|
||||||
else { node.status({fill:"green", shape:"dot", text:node.twitterConfig.screen_name}); }
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
stream.on('limit', function(tweet) {
|
stream.on('limit', function(tweet) {
|
||||||
@ -256,12 +235,26 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tags === '') {
|
|
||||||
node.status({fill:"yellow", shape:"ring", text:RED._("twitter.warn.waiting")});
|
// ask for users stream instead of public
|
||||||
|
if (this.user === "true") {
|
||||||
|
thing = 'user';
|
||||||
|
// twit.getFriendsIds(node.twitterConfig.screen_name.substr(1), function(err,list) {
|
||||||
|
// friends = list;
|
||||||
|
// });
|
||||||
|
st = null;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
setupStream();
|
// if 4 numeric tags that look like a geo area then set geo area
|
||||||
|
var bits = node.tags.split(",");
|
||||||
|
if (bits.length == 4) {
|
||||||
|
if ((Number(bits[0]) < Number(bits[2])) && (Number(bits[1]) < Number(bits[3]))) {
|
||||||
|
st = { locations: node.tags };
|
||||||
|
node.log(RED._("twitter.status.using-geo",{location:node.tags.toString()}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// all public tweets
|
||||||
if (this.user === "false") {
|
if (this.user === "false") {
|
||||||
node.on("input", function(msg) {
|
node.on("input", function(msg) {
|
||||||
if (this.tags === '') {
|
if (this.tags === '') {
|
||||||
@ -276,14 +269,17 @@ 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")});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//We shouldn't get into this state, but just incase, check for it
|
|
||||||
else {
|
|
||||||
//console.log("oops");
|
|
||||||
//node.status({fill:"green", shape:"dot", text:node.tags});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else { node.status({fill:"green", shape:"ring", text:node.twitterConfig.screen_name}); }
|
|
||||||
|
// wait for input or start the stream
|
||||||
|
if ((this.user === "false") && (tags === '')) {
|
||||||
|
node.status({fill:"yellow", shape:"ring", text:RED._("twitter.warn.waiting")});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
node.status({fill:"green", shape:"ring", text:(tags||" ")});
|
||||||
|
setupStream();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
node.error(err);
|
node.error(err);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"for": "for",
|
"for": "for",
|
||||||
"user": "User",
|
"user": "User",
|
||||||
"dmslabel": "DMs",
|
"dmslabel": "DMs",
|
||||||
"followers": "followed users",
|
"followers": "followed by",
|
||||||
"tweetslabel": "tweets",
|
"tweetslabel": "tweets",
|
||||||
"clickhere": "Click here to authenticate with Twitter."
|
"clickhere": "Click here to authenticate with Twitter."
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user