Sha256: c34dce3c9e9e59d44b880b6765934dc3dffd4b543bd9991b55fb3bf4920851dd

Contents?: true

Size: 868 Bytes

Versions: 5

Compression:

Stored size: 868 Bytes

Contents

class Fluent::TwitterOutput < Fluent::Output
  Fluent::Plugin.register_output('twitter', self)

  config_param :consumer_key, :string
  config_param :consumer_secret, :string
  config_param :oauth_token, :string
  config_param :oauth_token_secret, :string

  def initialize
    super
    require 'twitter'
  end

  def configure(conf)
    super

    @twitter = Twitter::Client.new(
      :consumer_key => conf['consumer_key'],
      :consumer_secret => conf['consumer_secret'],
      :oauth_token => conf['oauth_token'],
      :oauth_token_secret => conf['oauth_token_secret']
    )
  end

  def emit(tag, es, chain)
    es.each do |time,record|
      tweet(record['message'])
    end

    chain.next
  end

  def tweet(message)
    begin
      @twitter.update(message)
    rescue Twitter::Error => e
      $log.error("Twitter Error: #{e.message}")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fluent-plugin-twitter-0.2.4 lib/fluent/plugin/out_twitter.rb
fluent-plugin-twitter-0.2.2 lib/fluent/plugin/out_twitter.rb
fluent-plugin-twitter-0.2.1 lib/fluent/plugin/out_twitter.rb
fluent-plugin-twitter-0.1.1 lib/fluent/plugin/out_twitter.rb
fluent-plugin-twitter-0.0.1 lib/fluent/plugin/out_twitter.rb