<commit_before>#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'json'
require 'yaml'
require 'optparse'
require_relative '../src/app/conf'

ENV['env'] = 'local'
conf = R2S::Conf.new
url = 'http://localhost:8082/v1/slack/feed'

args = ARGV.getopts('t:')

if args['t'].nil?
  puts 'Usage: ruby slack_test_client -t <text>'
  exit 1
end

text = args['t']

body = {
  'token' => "#{conf.slack_token}",
  'team_id' => 'Personal',
  'team_domain' => "#{conf.accept_team_domain}",
  'channel_id' => "#{conf.accept_channel_id}",
  'channel_name' => 'dev-rss2slack',
  'timestamp' => 'timestamp_hoge',
  'user_id' => 'user_id_hoge',
  'user_name' => 'naoto0822',
  'text' => "#{text}",
  'trigger_word' => '<PASSWORD>'
}

uri = URI.parse(url)
req = Net::HTTP::Post.new(uri.path)
req.set_form_data(body)
res = Net::HTTP.start(uri.host, uri.port,
                      use_ssl: uri.scheme == 'https') { |http|
  http.open_timeout = 5
  http.read_timeout = 5
  http.request(req)
}

p ':Response'
p res
p ':Status Code'
p res.code
p ':Header'
res.each { |k, v| p "#{k} => #{v}" }
p ':Body'
p res.body
<commit_msg>update test client<commit_after>#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'json'
require 'yaml'
require 'optparse'
require_relative '../src/app/conf'

conf = R2S::Conf.new(conf_path: "./conf.test.yml")
secret_var = YAML.load_file("../private/rss2slack/external_vars.yml")
url = 'http://192.168.56.30/v1/slack/feed'

args = ARGV.getopts('t:')

if args['t'].nil?
  puts 'Usage: ruby slack_test_client -t <text>'
  exit 1
end

text = args['t']

body = {
  'token' => secret_var["dev_outgoing_webhooks_token"],
  'team_id' => 'Personal',
  'team_domain' => secret_var["dev_accept_team_domain"],
  'channel_id' => secret_var["dev_accept_channel_id"],
  'channel_name' => 'dev-rss2slack',
  'timestamp' => 'timestamp_hoge',
  'user_id' => 'user_id_hoge',
  'user_name' => 'naoto0822',
  'text' => "#{text}",
  'trigger_word' => 'rss2slack_register'
}

uri = URI.parse(url)
req = Net::HTTP::Post.new(uri.path)
req.set_form_data(body)
res = Net::HTTP.start(uri.host, uri.port,
                      use_ssl: uri.scheme == 'https') { |http|
  http.open_timeout = 5
  http.read_timeout = 5
  http.request(req)
}

p ':Response'
p res
p ':Status Code'
p res.code
p ':Header'
res.each { |k, v| p "#{k} => #{v}" }
p ':Body'
p res.body

{'fraction_non_alphanumeric': 0.20229494262643433, 'fraction_numerical': 0.01529961750956226, 'mean_word_length': 4.219512195121951, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '7288246', 'n_tokens_mistral': 991, 'n_tokens_neox': 958, 'n_words': 191}