Sha256: c17807a6d61b5d3a6d50c35e6073d36dc9355dee38c4936a3e25ccf9f7c28171
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require "twitter" require "fluent/plugin/output" class Fluent::Plugin::TwitterOutput < Fluent::Plugin::Output Fluent::Plugin.register_output('twitter', self) config_param :consumer_key, :string, secret: true config_param :consumer_secret, :string, secret: true config_param :access_token, :string, secret: true config_param :access_token_secret, :string, secret: true config_section :proxy, multi: false do config_param :host, :string config_param :port, :string config_param :username, :string, default: nil config_param :password, :string, default: nil, secret: true end def initialize super end def configure(conf) super @twitter = Twitter::REST::Client.new do |config| config.consumer_key = @consumer_key config.consumer_secret = @consumer_secret config.access_token = @access_token config.access_token_secret = @access_token_secret config.proxy = @proxy.to_h if @proxy end end def process(tag, es) es.each do |_time, record| tweet(record['message']) end end def tweet(message) begin @twitter.update(message) rescue Twitter::Error => e log.error("Twitter Error: #{e.message}") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-twitter-enchanced-0.6.1 | lib/fluent/plugin/out_twitter.rb |