lib/limp.rb in limp-0.0.3 vs lib/limp.rb in limp-0.0.4

- old
+ new

@@ -1,13 +1,26 @@ +require 'slack-ruby-client' + ## # Singleton module for exposing tokens module Limp class << self def tokens @tokens ||= db_files.map { |x| read_tokens(x) }.flatten.uniq end + def clients + @clients ||= tokens.map { |x| team_and_client(x) }.compact.to_h.values + end + private + + def team_and_client(token) + client = Slack::Web::Client.new(token: token) + [client.team_info.team.id, client] + rescue Slack::Web::Api::Errors::SlackError + nil + end def base_dir @base_dir ||= File.expand_path( '~/Library/Application Support/Google/Chrome' )