module Termtter::API
Attributes
connection[R]
twitter[R]
Public Class Methods
call_by_channel(c, *opt)
click to toggle source
# File lib/plugins/channel.rb, line 21 def call_by_channel(c, *opt) case c.to_s when "main" Termtter::API.twitter.home_timeline(*opt) when "replies" Termtter::API.twitter.replies(*opt) when /^(.+)_s(earch)?$/ Termtter::API.twitter.search($1, *opt) else user_name, slug = c.to_s.split('/') if !user_name.nil? && slug.nil? slug = user_name user_name = config.user_name elsif user_name.empty? user_name = config.user_name end user_name = Termtter::Client.normalize_as_user_name(user_name) Termtter::API.twitter.list_statuses(user_name, slug, *opt) end end
consumer()
click to toggle source
# File lib/termtter/api.rb, line 91 def consumer @consumer ||= OAuth::Consumer.new( Termtter::Crypt.decrypt(CONSUMER_KEY), Termtter::Crypt.decrypt(CONSUMER_SECRET), :site => config.oauth_consumer_site, :proxy => proxy_string ) end
proxy_string()
click to toggle source
# File lib/termtter/api.rb, line 118 def proxy_string return unless config.proxy.host if config.proxy.user_name && config.proxy.password "http://#{config.proxy.user_name}:#{config.proxy.password}@#{config.proxy.host}:#{config.proxy.port}" else "http://#{config.proxy.host}:#{config.proxy.port}" end end
setup()
click to toggle source
# File lib/termtter/api.rb, line 32 def setup # NOTE: for compatible @connection = twitter.instance_variable_get(:@connection) if config.access_token.empty? || config.access_token_secret.empty? if config.token_file && File.exist?(File.expand_path(config.token_file)) config.access_token, config.access_token_secret = File.read(File.expand_path(config.token_file)) \ .split(/\r?\n/).map(&:chomp) else self.authorize_by_oauth(true) end end access_token = OAuth::AccessToken.new(consumer, config.access_token, config.access_token_secret) @twitter = RubytterProxy.new(access_token, twitter_option) config.user_name = @twitter.verify_credentials[:screen_name] end
twitter_option()
click to toggle source
# File lib/termtter/api.rb, line 100 def twitter_option { :app_name => config.app_name.empty? ? Termtter::APP_NAME : config.app_name, :host => config.host, :header => { 'User-Agent' => 'Termtter http://github.com/termtter/termtter', 'X-Twitter-Client' => 'Termtter', 'X-Twitter-Client-URL' => 'http://github.com/termtter/termtter', 'X-Twitter-Client-Version' => Termtter::VERSION }, :enable_ssl => config.enable_ssl, :proxy_host => config.proxy.host, :proxy_port => config.proxy.port, :proxy_user_name => config.proxy.user_name, :proxy_password => config.proxy.password } end