-
Notifications
You must be signed in to change notification settings - Fork 5
/
watcher.js
34 lines (30 loc) · 1.07 KB
/
watcher.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var _ = require('underscore');
_.mixin( require('underscore.deferred') );
var inflection = require('inflection');
var Twit = require('twit');
var T = new Twit(require('./config.js'));
var wordfilter = require('wordfilter');
var rita = require('rita');
var lexicon = new rita.RiLexicon();
var r = rita.RiTa;
var corpora = require('corpora-project');
var animals = require('./animals.js');//corpora.getFile('animals','common').animals;
var bodyParts = require('./bodyParts.js');
var redis = require('redis'), client = redis.createClient();
Array.prototype.pick = function() {
return this[Math.floor(Math.random()*this.length)];
};
Array.prototype.pickRemove = function() {
var index = Math.floor(Math.random()*this.length);
return this.splice(index,1)[0];
};
console.log('START');
var stream = T.stream('user');
stream.on('follow', function (eventMsg) {
var name = eventMsg.source.name;
var screenName = eventMsg.source.screen_name;
console.log(eventMsg);
console.log(name, screenName);
// add new followers to the queue
client.rpush('queue', screenName, redis.print);
});