<commit_before>package ws

import (
	"encoding/json"
	"fmt"
	"github.com/gorilla/websocket"
	"jarvis/log"
	"jarvis/service"
	"jarvis/util"
	"time"
)

var (
	MasterWriteLimiter = time.Tick(1 * time.Second)
)

func SendMessage(message string, channelId string) {
	<-MasterWriteLimiter
	if len(message) > 25 {
		log.Trace(fmt.Sprintf("Writing message '%v...' to channel '%v'", message[:24], channelId))
	} else {
		log.Trace(fmt.Sprintf("Writing message '%v' to channel '%v'", message, channelId))
	}
	if len(message) > 3900 {
		log.Trace("Attempting to send message that is far too large")
		message = "The message I just attempted to send you exceeds Slack's maximum message length."
	}
	msg := util.OutgoingSlackMessage{
		Channel: channelId,
		Text:    message,
		Type:    "message",
		Id:      1,
	}
	json, err := json.Marshal(msg)
	util.Check(err)
	wsConnection.WriteMessage(websocket.TextMessage, json)
}

func SendPrivateMessage(message string, user string) {
	ch := service.Slack{}.IMChannelFromUserId(user)
	SendMessage(message, ch)
}<commit_msg>Tweaking<commit_after>package ws

import (
	"encoding/json"
	"fmt"
	"github.com/gorilla/websocket"
	"jarvis/log"
	"jarvis/service"
	"jarvis/util"
	"time"
)

var (
	MasterWriteLimiter = time.Tick(1 * time.Second)
)

func SendMessage(message string, channelId string) {
	<-MasterWriteLimiter
	if len(message) > 25 {
		log.Trace(fmt.Sprintf("Writing message '%v...' to channel '%v'", message[:24], channelId))
	} else {
		log.Trace(fmt.Sprintf("Writing message '%v' to channel '%v'", message, channelId))
	}
	if len(message) > 3000 {
		log.Trace("Attempting to send message that is far too large")
		message = "The message I just attempted to send you exceeds Slack's maximum message length."
	}
	msg := util.OutgoingSlackMessage{
		Channel: channelId,
		Text:    message,
		Type:    "message",
		Id:      1,
	}
	json, err := json.Marshal(msg)
	util.Check(err)
	wsConnection.WriteMessage(websocket.TextMessage, json)
}

func SendPrivateMessage(message string, user string) {
	ch := service.Slack{}.IMChannelFromUserId(user)
	SendMessage(message, ch)
}
{'fraction_non_alphanumeric': 0.13898143741075678, 'fraction_numerical': 0.00951927653498334, 'mean_word_length': 4.488250652741514, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7185801', 'n_tokens_mistral': 769, 'n_tokens_neox': 726, 'n_words': 182}