Sha256: e1d8084df69dfaaefcf2f335d7fe23c3e504dc86fd7650137f6cdd326ab29753

Contents?: true

Size: 958 Bytes

Versions: 5

Compression:

Stored size: 958 Bytes

Contents

module Chatterbot

  #
  # routines for sending tweets
  module Tweet 
    # simple wrapper for sending a message
    def tweet(txt, params = {}, original = nil)
      return if require_login == false

      txt = replace_variables(txt, original)
      
      if debug_mode?
        debug "I'm in debug mode, otherwise I would tweet: #{txt}"
      else
        debug txt
        if params.has_key?(:media)
          file = params.delete(:media)
          if ! file.is_a?(File)
            file = File.new(file)
          end

          client.update_with_media txt, file, params
        else
          client.update txt, params
        end
      end
    rescue Twitter::Error::Forbidden => e
      #:nocov:
      debug e
      false
      #:nocov:
    end

    
    # reply to a tweet
    def reply(txt, source, params = {})
      debug txt
      params = {:in_reply_to_status_id => source.id}.merge(params)
      tweet txt, params, source
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
chatterbot-2.2.0 lib/chatterbot/tweet.rb
chatterbot-2.1.0 lib/chatterbot/tweet.rb
chatterbot-2.0.5 lib/chatterbot/tweet.rb
chatterbot-2.0.4 lib/chatterbot/tweet.rb
chatterbot-2.0.3 lib/chatterbot/tweet.rb