diff --git a/examples/twitter/demo1.coffee b/examples/twitter/demo1.coffee index d6e1db0..35bc3b1 100644 --- a/examples/twitter/demo1.coffee +++ b/examples/twitter/demo1.coffee @@ -1,6 +1,6 @@ #!/usr/bin/env coffee -Hydrant = require '../../lib/hydrant' +Hydrant = require 'hydrant' {inspect} = require 'util' hydrant = new Hydrant defaults: @@ -8,13 +8,17 @@ hydrant = new Hydrant compress: no # deflateRaw, deflate, gzip, or none twitter: - module: '../../lib/input/twitter' + module: './input/twitter' consumer_key: 'CONSUMER_KEY' consumer_secret: 'CONSUMER_SECRET' access_token_key: 'ACCESS_TOKEN_KEY' access_token_secret: 'ACCES_TOKEN_SECRET' + endpoint: 'statuses/filter' # or 'statuses/sample' (remove 'search' in this case) + search: + track: 'node,javascript,clojure' + # you can pass conditions to ignore some entries of the flow # warning: they are directly executed by Node, so be sure # your Hydrant config file come from a trusted source! diff --git a/lib/input/twitter.js b/lib/input/twitter.js index 611762b..9544fa0 100644 --- a/lib/input/twitter.js +++ b/lib/input/twitter.js @@ -14,6 +14,10 @@ var ignore, _i, _len, _ref; this.config = config; this.start = __bind(this.start, this); + this.endpoint = 'statuses/sample'; + if (this.config.endpoint != null) this.endpoint = this.config.endpoint; + this.search = void 0; + if (this.config.search != null) this.search = this.config.search; this.filters = []; if (this.config.ignores != null) { _ref = this.config.ignores; @@ -28,7 +32,7 @@ exports.prototype.start = function() { var _this = this; - return this.twitter.stream('statuses/sample', void 0, function(s) { + return this.twitter.stream(this.endpoint, this.search, function(s) { var process; process = function(data) { var filter, ignore, _i, _len, _ref; diff --git a/package.json b/package.json index 3ae13e9..b1e7889 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "email" : "julian.bilcke@daizoru.com", "url" : "http://github.com/daizoru" }, - "name": "node-hydrant", + "name": "hydrant", "description": "Complex event stream aggregator and broadcaster", "version": "0.0.0", "repository": { @@ -14,7 +14,7 @@ }, "directories" : { "lib" : "./lib", - "example" : "./example", + "examples" : "./examples", "test" : "./test" }, "main" : "./lib/hydrant", diff --git a/src/input/twitter.coffee b/src/input/twitter.coffee index 5c45e24..7e0aa39 100644 --- a/src/input/twitter.coffee +++ b/src/input/twitter.coffee @@ -30,6 +30,14 @@ ntwitter = require 'ntwitter' class module.exports constructor: (@config) -> + @endpoint = 'statuses/sample' + if @config.endpoint? + @endpoint = @config.endpoint + + @search = undefined + if @config.search? + @search = @config.search + @filters = [] if @config.ignores? for ignore in @config.ignores @@ -37,9 +45,10 @@ class module.exports delete @config['ignores'] @twitter = new ntwitter @config + start: => # rate limit: 400 keywords, 5,000 follow userids - @twitter.stream 'statuses/sample', undefined, (s) => + @twitter.stream @endpoint, @search, (s) => process = (data) => #console.log "data: #{inspect data}"