Skip to content

Commit 6f7cb1f

Browse files
committed
refactor folders and add bots code
1 parent 9337895 commit 6f7cb1f

File tree

301 files changed

+327
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

301 files changed

+327
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
.DS_Store
2+
config.js
3+
node_modules

code_bots/node1/hello.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
console.log("Hello aribitrary video website");

code_bots/node2/bot.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
console.log('The bot is starting');
2+
3+
var Twit = require('twit');
4+
5+
var config = require('./config');
6+
var T = new Twit(config);
7+
8+
var params = {
9+
q: 'rainbow',
10+
count: 2
11+
}
12+
13+
T.get('search/tweets', params, gotData);
14+
15+
function gotData(err, data, response) {
16+
var tweets = data.statuses;
17+
for (var i = 0; i < tweets.length; i++) {
18+
console.log(tweets[i].text);
19+
}
20+
}

code_bots/node2/config-empty.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Change this file to config.js
2+
// Add your keys
3+
// Add file .gitignore: config.js
4+
// Load with
5+
// var config = require('./config.js');
6+
7+
module.exports = {
8+
consumer_key: '',
9+
consumer_secret: '',
10+
access_token: '',
11+
access_token_secret: ''
12+
}

code_bots/node2/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "npm_demo",
3+
"version": "1.0.0",
4+
"description": "I am demonstrating npm.",
5+
"main": "bot.js",
6+
"scripts": {
7+
"start": "node bot.js",
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"keywords": [
11+
"rainbow",
12+
"awkward"
13+
],
14+
"author": "",
15+
"license": "ISC",
16+
"dependencies": {
17+
"twit": "^2.1.1"
18+
}
19+
}

code_bots/node3/bot.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
console.log('The bot is starting');
2+
3+
var Twit = require('twit');
4+
5+
var config = require('./config');
6+
var T = new Twit(config);
7+
8+
9+
var tweet = {
10+
status: '#codingrainbow from node.js'
11+
}
12+
13+
T.post('statuses/update', tweet, tweeted);
14+
15+
function tweeted(err, data, response) {
16+
if (err) {
17+
console.log("Something went wwrong!");
18+
} else {
19+
console.log("It worked!");
20+
}
21+
}

code_bots/node3/config-empty.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Change this file to config.js
2+
// Add your keys
3+
// Add file .gitignore: config.js
4+
// Load with
5+
// var config = require('./config.js');
6+
7+
module.exports = {
8+
consumer_key: '',
9+
consumer_secret: '',
10+
access_token: '',
11+
access_token_secret: ''
12+
}

code_bots/node3/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "npm_demo",
3+
"version": "1.0.0",
4+
"description": "I am demonstrating npm.",
5+
"main": "bot.js",
6+
"scripts": {
7+
"start": "node bot.js",
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"keywords": [
11+
"rainbow",
12+
"awkward"
13+
],
14+
"author": "",
15+
"license": "ISC",
16+
"dependencies": {
17+
"twit": "^2.1.1"
18+
}
19+
}

code_bots/node4_a_setInterval/bot.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
console.log('The bot is starting');
2+
3+
var Twit = require('twit');
4+
5+
var config = require('./config');
6+
var T = new Twit(config);
7+
8+
tweetIt();
9+
setInterval(tweetIt, 1000*20);
10+
11+
function tweetIt() {
12+
13+
var r = Math.floor(Math.random()*100);
14+
15+
var tweet = {
16+
status: 'random number ' + r + ' #codingrainbow'
17+
}
18+
19+
T.post('statuses/update', tweet, tweeted);
20+
21+
function tweeted(err, data, response) {
22+
if (err) {
23+
console.log("Something went wwrong!");
24+
} else {
25+
console.log("It worked!");
26+
}
27+
}
28+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Change this file to config.js
2+
// Add your keys
3+
// Add file .gitignore: config.js
4+
// Load with
5+
// var config = require('./config.js');
6+
7+
module.exports = {
8+
consumer_key: '',
9+
consumer_secret: '',
10+
access_token: '',
11+
access_token_secret: ''
12+
}

0 commit comments

Comments
 (0)