<commit_before>package main

import (
	"bytes"
	"encoding/json"
	"errors"
	"net/http"
	"net/url"
)

type SlackCommand struct {
	Token       string
	Command     string
	Text        string
	ResponseUrl string
	User        SlackUser
	Channel     SlackChannel
	Team        SlackTeam
}

type SlackTeam struct {
	Id     string
	Domain string
}

type SlackChannel struct {
	Team SlackTeam
	Id   string
	Name string
}

type SlackUser struct {
	Team SlackTeam
	Id   string
	Name string
}

func ParseCommand(values url.Values) (SlackCommand, error) {
	team := SlackTeam{
		Id:     values.Get("team_id"),
		Domain: values.Get("team_domain"),
	}
	channel := SlackChannel{
		Team: team,
		Id:   values.Get("channel_id"),
		Name: values.Get("channel_name"),
	}
	user := SlackUser{
		Team: team,
		Id:   values.Get("user_id"),
		Name: values.Get("user_name"),
	}
	command := SlackCommand{
		Token:       values.Get("token"),
		Command:     values.Get("command"),
		Text:        values.Get("text"),
		ResponseUrl: values.Get("response_url"),
		User:        user,
		Channel:     channel,
		Team:        team,
	}
	// validate
	return command, nil
}

type SlackResponse struct {
	Text         string `json:"text"`
	ResponseType string `json:"response_type,omitempty"`
}

func (cmd SlackCommand) Respond(message string, toChannel bool) error {
	response := SlackResponse{}
	response.Text = message
	if toChannel {
		response.ResponseType = "in_channel"
	}

	toSend, err := json.Marshal(response)
	if err != nil {
		return err
	}
	req, err := http.NewRequest("POST",
		cmd.ResponseUrl,
		bytes.NewReader(toSend))
	if err != nil {
		return err
	}
	req.Header.Add("Content-Type", "application/json")

	dbgReq(req)
	hc := http.Client{}
	resp, err := hc.Do(req)
	if err != nil {<commit_msg>works<commit_after>package main

import (
	"bytes"
	"encoding/json"
	"errors"
	"net/http"
	"net/url"
)

type SlackCommand struct {
	Token       string
	Command     string
	Text        string
	ResponseUrl string
	User        SlackUser
	Channel     SlackChannel
	Team        SlackTeam
}

type SlackTeam struct {
	Id     string
	Domain string
}

type SlackChannel struct {
	Team SlackTeam
	Id   string
	Name string
}

type SlackUser struct {
	Team SlackTeam
	Id   string
	Name string
}

func ParseCommand(values url.Values) (SlackCommand, error) {
	team := SlackTeam{
		Id:     values.Get("team_id"),
		Domain: values.Get("team_domain"),
	}
	channel := SlackChannel{
		Team: team,
		Id:   values.Get("channel_id"),
		Name: values.Get("channel_name"),
	}
	user := SlackUser{
		Team: team,
		Id:   values.Get("user_id"),
		Name: values.Get("user_name"),
	}
	command := SlackCommand{
		Token:       values.Get("token"),
		Command:     values.Get("command"),
		Text:        values.Get("text"),
		ResponseUrl: values.Get("response_url"),
		User:        user,
		Channel:     channel,
		Team:        team,
	}
	// validate
	return command, nil
}

type SlackResponse struct {
	Text         string `json:"text"`
	ResponseType string `json:"response_type,omitempty"`
}

func (cmd SlackCommand) Respond(message string, toChannel bool) error {
	response := SlackResponse{}
	response.Text = message
	if toChannel {
		response.ResponseType = "in_channel"
	}

	toSend, err := json.Marshal(response)
	if err != nil {
		return err
	}
	req, err := http.NewRequest("POST",
		cmd.ResponseUrl,
		bytes.NewReader(toSend))
	if err != nil {
		return err
	}
	req.Header.Add("Content-Type", "application/json")

	hc := http.Client{}
	resp, err := hc.Do(req)
	if err != nil {
{'fraction_non_alphanumeric': 0.12425192362496437, 'fraction_numerical': 0.0, 'mean_word_length': 3.2857142857142856, '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': '430555', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1211, 'n_words': 301}