<commit_before>require 'slack'

module Komonjo
  module Connection
    # Connection for slack
    class SlackConnection
      attr_reader :client
      def initialize(api_token)
        @client = Slack::Client.new(token: api_token)
      end

      def channels_history(channel_name)
        channel_name[0] = '' if channel_name[0] == '#'
        channel_id = channel_id channel_name
        ret = client.channels_history(channel: channel_id)
        fail 'error' unless ret['ok']
        ret['messages']
      end

      def users_info(user_id)
        ret = client.users_info(user: user_id)
        fail 'error' unless ret['ok']
        ret['user']
      end

      def users_list
        ret = client.users_list
        fail 'error' unless ret['ok']
        ret['members']
      end

      def channels_list
        ret = client.channels_list
        fail 'error' unless ret['ok']
        ret['channels']
      end

      def auth_test
        ret = client.auth_test
        ret['ok']
      end
<commit_msg>any params<commit_after>require 'slack'

module Komonjo
  module Connection
    # Connection for slack
    class SlackConnection
      attr_reader :client
      def initialize(api_token)
        @client = Slack::Client.new(token: api_token)
      end

      def channels_history(opts)
        channel_name = opts.delete(:channel_name)
        unless opts[:channel]
          channel_name[0] = '' if channel_name[0] == '#'
          channel_id = channel_id channel_name
          opts[:channel] = channel_id
        end
        ret = client.channels_history(opts)
        fail 'error' unless ret['ok']
        ret['messages']
      end

      def users_info(user_id)
        ret = client.users_info(user: user_id)
        fail 'error' unless ret['ok']
        ret['user']
      end

      def users_list
        ret = client.users_list
        fail 'error' unless ret['ok']
        ret['members']
      end

      def channels_list
        ret = client.channels_list
        fail 'error' unless ret['ok']
        ret['channels']
      end

      def auth_test
        ret = client.auth_test
        ret['ok']
      end

{'fraction_non_alphanumeric': 0.09351503759398497, 'fraction_numerical': 0.0018796992481203006, 'mean_word_length': 2.0810419681620838, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '122560', 'n_tokens_mistral': 628, 'n_tokens_neox': 615, 'n_words': 153}