Sha256: 3df704ed5e30b582c8b7e41ac7e354baa757374df7ef84fee98c8d5622e71d3d

Contents?: true

Size: 789 Bytes

Versions: 2

Compression:

Stored size: 789 Bytes

Contents

require 'thor'
require 'slackgetter'
require 'pry'

module Slackgetter
  class CLI < Thor
    desc "time", "get messages"
    def time(channel_name, oldest=nil, latest=nil)
      Slackgetter.configure_token ENV['SLACK_TOKEN']
      oldest ||= (Time.now - 24*60*60).to_s
      latest ||= Time.now.to_s
      messages = Slackgetter.messages(channel_name, oldest, latest)
      puts messages
    end

    desc "url", "get messages"
    def url(channel_name, oldest_url, latest_url=nil)
      Slackgetter.configure_token ENV['SLACK_TOKEN']
      oldest = Slackgetter.url_to_time(oldest_url).to_s
      latest = latest_url ? (Slackgetter.url_to_time(latest_url) + 1).to_s : Time.now.to_s
      messages = Slackgetter.messages(channel_name, oldest, latest)
      puts messages
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slackgetter-0.1.1 lib/slackgetter/cli.rb
slackgetter-0.1.0 lib/slackgetter/cli.rb