mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Tidy up twitter node, add status, i18n etc
This commit is contained in:
parent
b0c93e44b8
commit
4c5b75f30a
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
Copyright 2013, 2015 IBM Corp.
|
Copyright 2013, 2016 IBM Corp.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -186,14 +186,13 @@
|
|||||||
$("#node-input-user").change();
|
$("#node-input-user").change();
|
||||||
},
|
},
|
||||||
oneditsave: function() {
|
oneditsave: function() {
|
||||||
if ($('#node-input-tags').val() == '' && $("#node-input-user option:selected").val() != 'dm'
|
if ($('#node-input-tags').val() === '' && $("#node-input-user option:selected").val() != 'dm' && $("#node-input-user option:selected").val() != 'user') {
|
||||||
&& $("#node-input-user option:selected").val() != 'user') {
|
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>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2013, 2015 IBM Corp.
|
* Copyright 2013, 2016 IBM Corp.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -89,8 +89,9 @@ module.exports = function(RED) {
|
|||||||
node.poll_ids = [];
|
node.poll_ids = [];
|
||||||
node.since_ids = {};
|
node.since_ids = {};
|
||||||
var users = node.tags.split(",");
|
var users = node.tags.split(",");
|
||||||
if (users == '') node.warn("User option selected but no users specified");
|
//if (users == '') node.warn("User option selected but no users specified");
|
||||||
for (var i=0;i<users.length;i++) {
|
if (users.length === 0) { node.warn(RED._("twitter.warn.nousers")); }
|
||||||
|
for (var i=0; i<users.length; i++) {
|
||||||
var user = users[i].replace(" ","");
|
var user = users[i].replace(" ","");
|
||||||
twit.getUserTimeline({
|
twit.getUserTimeline({
|
||||||
screen_name:user,
|
screen_name:user,
|
||||||
@ -236,29 +237,30 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.tags == '')
|
if (this.tags === '') {
|
||||||
{
|
node.status({fill:"yellow", shape:"ring", text:RED._("twitter.warn.waiting")});
|
||||||
this.warn("No search term(s) specified - add to node config or pass in through msg.payload");
|
}
|
||||||
}
|
else {
|
||||||
else setupStream();
|
setupStream();
|
||||||
|
}
|
||||||
node.on("input", function(msg) {
|
node.on("input", function(msg) {
|
||||||
if (this.tags == '') {
|
if (this.tags === '') {
|
||||||
this.warn("Now searching for: " + msg.payload);
|
if (this.stream) { this.stream.destroy(); }
|
||||||
if (this.stream) this.stream.destroy();
|
st = { track: [msg.payload] };
|
||||||
st = { track: [msg.payload] };
|
setupStream();
|
||||||
setupStream();
|
node.status({fill:"green", shape:"dot", text:msg.payload});
|
||||||
node.status({fill:"green",shape:"dot",text:msg.payload});
|
}
|
||||||
}
|
//We shouldn't get into this state, but just incase, check for it
|
||||||
//We shouldn't get into this state, but just incase, check for it
|
else {
|
||||||
else {
|
// node.warn("msg.payload passed in, but tag config is not blank, defaulting to tag config");
|
||||||
this.warn("msg.payload passed in, but tag config is not blank, defaulting to tag config");
|
node.status({fill:"green", shape:"dot", text:node.tags});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
node.error(err);
|
node.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.error(RED._("twitter.errors.missingcredentials"));
|
this.error(RED._("twitter.errors.missingcredentials"));
|
||||||
}
|
}
|
||||||
|
@ -25,19 +25,23 @@
|
|||||||
"tweeting": "tweeting",
|
"tweeting": "tweeting",
|
||||||
"failed":"failed"
|
"failed":"failed"
|
||||||
},
|
},
|
||||||
|
"warn": {
|
||||||
|
"nousers":"User option selected but no users specified",
|
||||||
|
"waiting":"Waiting for search term"
|
||||||
|
},
|
||||||
"errors": {
|
"errors": {
|
||||||
"ratelimit":"tweet rate limit hit",
|
"ratelimit":"tweet rate limit hit",
|
||||||
"streamerror":"stream error: __error__ (__rc__)",
|
"streamerror":"stream errosr: __error__ (__rc__)",
|
||||||
"unexpectedend":"stream ended unexpectedly",
|
"unexpectedend":"stream ended unexpectedly",
|
||||||
"invalidtag":"invalid tag property",
|
"invalidtag":"invalid tag property",
|
||||||
"missingcredentials":"missing twitter credentials",
|
"missingcredentials":"missing twitter credentials",
|
||||||
"truncated":"truncated tweet greater than 140 characters",
|
"truncated":"truncated tweet greater than 140 characters",
|
||||||
"sendfail":"send tweet failed: __error__",
|
"sendfail":"send tweet failed: __error__",
|
||||||
"nopayload":"no payload to tweet",
|
"nopayload":"no payload to tweet",
|
||||||
|
|
||||||
"oauthbroke":"something in twitter oauth broke.",
|
"oauthbroke":"something in twitter oauth broke.",
|
||||||
"oautherror": "<html><head></head><body><p>Something went wrong with the authentication process. The following error was returned:</p><p><b>__statusCode__</b>: __errorData__</p><p>One known cause of this type of failure is if the clock is wrong on system running Node-RED</p></body></html>",
|
"oautherror": "<html><head></head><body><p>Something went wrong with the authentication process. The following error was returned:</p><p><b>__statusCode__</b>: __errorData__</p><p>One known cause of this type of failure is if the clock is wrong on system running Node-RED</p></body></html>",
|
||||||
"authorized": "<html><head></head><body><p>Authorised - you can close this window and return to Node-RED</p></body></html>"
|
"authorized": "<html><head></head><body><p>Authorised - you can close this window and return to Node-RED</p></body></html>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user