Sha256: f05c352bccf8f3bb0369d41548c8930b9cca3ec6ee22c24f5fc5bfc8a33168d1

Contents?: true

Size: 780 Bytes

Versions: 1

Compression:

Stored size: 780 Bytes

Contents

require "twitter"
require "keyword_struct"

module Lita
  module Handlers
    class Tweet < Handler

      Account = KeywordStruct.new(:username, :token, :secret, :config, :last_tweet) do
        def username
          @username ||= client.user.screen_name
        end

        def tweet(text)
          client.update(text)
        end

        def untweet
          last_tweet ? client.destroy_status(last_tweet) : false
        end

      private

        def client
          @client ||= ::Twitter::REST::Client.new do |c|
            c.consumer_key        = config.consumer_key
            c.consumer_secret     = config.consumer_secret
            c.access_token        = token
            c.access_token_secret = secret
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-tweet-0.3.0 lib/lita/handlers/tweet/account.rb