Sha256: d10133919e921cecd0faee12dc5d8e42c0f99d42225d303ea14fcd4a64ecd333

Contents?: true

Size: 510 Bytes

Versions: 7

Compression:

Stored size: 510 Bytes

Contents

require 'net/http'
require 'json'

search_term = URI::encode('#todayilearned')

SCHEDULER.every '10m', :first_in => 0 do |job|
  http = Net::HTTP.new('search.twitter.com')
  response = http.request(Net::HTTP::Get.new("/search.json?q=#{search_term}"))
  tweets = JSON.parse(response.body)["results"]
  if tweets
    tweets.map! do |tweet| 
      { name: tweet['from_user'], body: tweet['text'], avatar: tweet['profile_image_url_https'] }
    end
  
    send_event('twitter_mentions', comments: tweets)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dashing-1.0.5 templates/project/jobs/twitter.rb
dashing-1.0.4 templates/project/jobs/twitter.rb
dashing-1.0.3 templates/project/jobs/twitter.rb
dashing-1.0.2 templates/project/jobs/twitter.rb
dashing-1.0.1 templates/project/jobs/twitter.rb
dashing-1.0 templates/project/jobs/twitter.rb
dashing-0.1.2 templates/project/jobs/twitter.rb