<commit_before>package slack

import (
	"bytes"
	"encoding/json"
	"github.com/aphistic/gomol"
	"io/ioutil"
	"net/http"
)

type IncomingWebhook struct {
	Username string `json:username`
	Text     string `json:text`
	Channel  string `json:channel`
}

func GetLinkMarkup(path string, text string) string {
	return "<" + path + "|" + text + ">"
}

func GetImageMarkup(imageUrl string) string {
	return "<" + imageUrl + ">"
}

func SendIncomingWebhook(model IncomingWebhook) ([]byte, error) {
	modelJson, err := json.Marshal(model)
	if err != nil {
		gomol.Err("Could not marshal json from IncomingWebhook model. " +
			err.Error())
		return nil, err
	}

	payload := bytes.NewBuffer(modelJson)

	// send post
	req, err := http.NewRequest("POST", Config.WebhookUrl, payload)
	req.Header.Add("Content=Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		gomol.Err("Could not send IncomingWebhook. " + err.Error())
		return nil, err
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body) // must read to close?

	if err != nil {
		gomol.Err("Could not .ReadAll() of response body when sending IncomingWebhook. " +
			err.Error())
		return nil, err
	}
<commit_msg>corrected silly stuff<commit_after>package slack

import (
	"bytes"
	"encoding/json"
	"github.com/aphistic/gomol"
	"io/ioutil"
	"net/http"
)

type IncomingWebhook struct {
	Username string `json:"username"`
	Text     string `json:"text"`
	Channel  string `json:"channel"`
}

func GetLinkMarkup(path string, text string) string {
	return "<" + path + "|" + text + ">"
}

func GetImageMarkup(imageUrl string) string {
	return "<" + imageUrl + ">"
}

func SendIncomingWebhook(model IncomingWebhook) ([]byte, error) {
	modelJson, err := json.Marshal(model)
	if err != nil {
		gomol.Err("Could not marshal json from IncomingWebhook model. " +
			err.Error())
		return nil, err
	}

	payload := bytes.NewBuffer(modelJson)

	// send post
	req, err := http.NewRequest("POST", Config.WebhookUrl, payload)
	req.Header.Add("Content-Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		gomol.Err("Could not send IncomingWebhook. " + err.Error())
		return nil, err
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body) // must read to close?

	if err != nil {
		gomol.Err("Could not .ReadAll() of response body when sending IncomingWebhook. " +
			err.Error())
		return nil, err
	}

{'fraction_non_alphanumeric': 0.14869281045751634, 'fraction_numerical': 0.0, 'mean_word_length': 4.01844262295082, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3711826', 'n_tokens_mistral': 893, 'n_tokens_neox': 860, 'n_words': 220}