Sha256: 0d1705935a82bdb54257b028bd9c18f83cb0ad5910def782876e67636fb52c38

Contents?: true

Size: 863 Bytes

Versions: 5

Compression:

Stored size: 863 Bytes

Contents

require 'twitter'


#### Get your twitter keys & secrets:
#### https://dev.twitter.com/docs/auth/tokens-devtwittercom
Twitter.configure do |config|
  config.consumer_key = 'YOUR_CONSUMER_KEY'
  config.consumer_secret = 'YOUR_CONSUMER_SECRET'
  config.oauth_token = 'YOUR_OAUTH_TOKEN'
  config.oauth_token_secret = 'YOUR_OAUTH_SECRET'
end

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

SCHEDULER.every '10m', :first_in => 0 do |job|
  begin
    tweets = Twitter.search("#{search_term}").results

    if tweets
      tweets.map! do |tweet|
        { name: tweet.user.name, body: tweet.text, avatar: tweet.user.profile_image_url_https }
      end
      send_event('twitter_mentions', comments: tweets)
    end
  rescue Twitter::Error
    puts "\e[33mFor the twitter widget to work, you need to put in your twitter API keys in the jobs/twitter.rb file.\e[0m"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dashing-1.3.1 templates/project/jobs/twitter.rb
dashing-1.3.0 templates/project/jobs/twitter.rb
dashing-1.2.0 templates/project/jobs/twitter.rb
dashing-1.1.0 templates/project/jobs/twitter.rb
dashing-1.0.6 templates/project/jobs/twitter.rb