lib/twitter_ebooks/bot.rb
# Reply to a tweet or a DM.
# Applies configurable @reply_delay range
Reply to a tweet or a DM.
Applies configurable @reply_delay range
Reply to a tweet or a DM . Applies configurable @reply_delay range
def reply(ev, text, opts={})
      opts = opts.clone
      delay = @reply_delay.to_a.sample
      if ev.is_a? Twitter::DirectMessage
        log "Sending DM to @#{ev[:sender][:screen_name]}: #{text}"
        @twitter.direct_message_create(ev[:sender][:screen_name], text, opts)
      elsif ev.is_a? Twitter::Tweet
        log "Replying to @#{ev[:user][:screen_name]} with: #{text}"
        @twitter.update(text, in_reply_to_status_id: ev[:id])
      else
        raise Exception("Don't know how to reply to a #{ev.class}")
      end
    end
def reply ( ev , text , opts = { } ) opts = opts . clone delay = @reply_delay . to_a . sample if ev . is_a? Twitter :: DirectMessage log "Sending DM to @#{ev[:sender][:screen_name]}: #{text}" @twitter . direct_message_create ( ev [ :sender ] [ :screen_name ] , text , opts ) elsif ev . is_a? Twitter :: Tweet log "Replying to @#{ev[:user][:screen_name]} with: #{text}" @twitter . update ( text , in_reply_to_status_id : ev [ :id ] ) else raise Exception ( "Don't know how to reply to a #{ev.class}" ) end end
Reply to a tweet or a DM.
Reply to a tweet or a DM .
ev
text
opts