diff --git a/.env.example b/.env.example index 4661988..e6f3601 100644 --- a/.env.example +++ b/.env.example @@ -5,6 +5,8 @@ APP_DEBUG=true APP_LOG_LEVEL=debug APP_URL=http://localhost +GAME_HASHTAG="#thegame" + DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 diff --git a/twitter/stream.rb b/twitter/stream.rb index 8f56270..3096548 100644 --- a/twitter/stream.rb +++ b/twitter/stream.rb @@ -14,12 +14,16 @@ client = Twitter::Streaming::Client.new do |config| config.access_token_secret = $config['global']['TWITTER_ACCESS_TOKEN_SECRET'] end -client.user do |obj| +filters = { + track: $config['global']['GAME_HASHTAG'] +} + +client.filter(filters) do |obj| case obj when Twitter::Tweet puts "Got a tweet" puts obj.to_h.to_json - + response = HTTParty.post "#{$config['global']['APP_URL']}/twitter/stream", { body: obj.to_h.to_json, headers: {'Content-Type' => 'application/json'} @@ -32,4 +36,3 @@ client.user do |obj| puts "Falling behind!" end end -