├── .gitignore ├── LICENSE ├── README.md ├── bot.js ├── quote-bot.js └── retweet-bot.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # Compiled binary addons (http://nodejs.org/api/addons.html) 20 | build/Release 21 | 22 | # Dependency directory 23 | # Deployed apps should consider commenting this line out: 24 | # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git 25 | node_modules 26 | 27 | # My file, with my API Keys 28 | mybot.js -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Mark Rabey 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | node-twitter-bot 2 | ================ 3 | 4 | A simple Twitter Bot Built on Node.js 5 | 6 | Take a look at my [blog post](http://markrabey.com/2014/05/09/build-a-twitter-bot-with-node-js/) about this project. -------------------------------------------------------------------------------- /bot.js: -------------------------------------------------------------------------------- 1 | var Twit = require('twit'); 2 | 3 | var T = new Twit({ 4 | consumer_key: '...' 5 | , consumer_secret: '...' 6 | , access_token: '...' 7 | , access_token_secret: '...' 8 | }); 9 | 10 | function retweetRecent() { 11 | T.get('search/tweets', {q: "#coldfusion OR #cfml", result_type: "recent"}, function (err, data,response) { 12 | if (!err) { 13 | var retweetId = data.statuses[0].id_str; 14 | T.post('statuses/retweet/' + retweetId, { }, function (err, response) { 15 | if (response) { 16 | console.log('Retweeted Tweet ID: ' + retweetId); 17 | } 18 | if (err) { 19 | console.log('Retweet Error: ', err); 20 | } 21 | }); 22 | } else { 23 | console.log('Search Error: ', err); 24 | } 25 | }); 26 | } 27 | 28 | retweetRecent(); 29 | setInterval(retweetRecent, 1800000); -------------------------------------------------------------------------------- /quote-bot.js: -------------------------------------------------------------------------------- 1 | var Twit = require('twit'); 2 | 3 | var T = new Twit({ 4 | consumer_key: '...' 5 | , consumer_secret: '...' 6 | , access_token: '...' 7 | , access_token_secret: '...' 8 | }); 9 | 10 | function retweetRecent() { 11 | T.get('search/tweets', {q: "#coldfusion OR #cfml", result_type: "recent"}, function (err, data,response) { 12 | if (!err) { 13 | var tweet = data.statuses[0]; 14 | var retweetBody = 'RT @' + tweet.user.screen_name + ' ' + tweet.text; 15 | T.post('statuses/update',{status:retweetBody}, function (err,response) { 16 | if (response) { 17 | console.log('Quote Tweeted Tweet ID: ' + tweet.id_str); 18 | } 19 | if (err) { 20 | console.log('Quote Tweet Error: ', err); 21 | } 22 | }); 23 | } else { 24 | console.log('Search Error: ', err); 25 | } 26 | }); 27 | } 28 | 29 | retweetRecent(); 30 | setInterval(retweetRecent, 1800000); 31 | -------------------------------------------------------------------------------- /retweet-bot.js: -------------------------------------------------------------------------------- 1 | var Twit = require('twit'); 2 | 3 | var T = new Twit({ 4 | consumer_key: '...' 5 | , consumer_secret: '...' 6 | , access_token: '...' 7 | , access_token_secret: '...' 8 | }); 9 | 10 | function retweetRecent() { 11 | T.get('search/tweets', {q: "#coldfusion OR #cfml", result_type: "recent"}, function (err, data,response) { 12 | if (!err) { 13 | var retweetId = data.statuses[0].id_str; 14 | T.post('statuses/retweet/' + retweetId, { }, function (err, response) { 15 | if (response) { 16 | console.log('Retweeted Tweet ID: ' + retweetId); 17 | } 18 | if (err) { 19 | console.log('Retweet Error: ', err); 20 | } 21 | }); 22 | } else { 23 | console.log('Search Error: ', err); 24 | } 25 | }); 26 | } 27 | retweetRecent(); 28 | setInterval(retweetRecent, 1800000); --------------------------------------------------------------------------------