<commit_before>package slack

import (
	"time"

	"github.com/uva-its/gopherbot/bot"
)

// Message send delay; slack has problems with scrolling if messages fly out
// too fast.
const msgDelay = 200 * time.Millisecond

// GetUserAttribute returns a string attribute or nil if slack doesn't
// have that information
func (s *slackConnector) GetProtocolUserAttribute(u, attr string) (value string, ret bot.RetVal) {
	user, ok := s.getUser(u)
	if !ok {
		return "", bot.UserNotFound
	}
	switch attr {
	case "email":
		return user.Profile.Email, bot.Ok
	case "realName", "fullName":
		return user.RealName, bot.Ok
	case "firstName":
		return user.Profile.FirstName, bot.Ok
	case "lastName":
		return user.Profile.LastName, bot.Ok
	case "phone":
		return user.Profile.Phone, bot.Ok
	// that's all the attributes we can currently get from slack
	default:
		return "", bot.AttributeNotFound
	}
}

func (s *slackConnector) sendMessages(msgs []string, chanID string) {
	l := len(msgs)
	for i, msg := range msgs {
		time.Sleep(msgDelay)
		s.conn.SendMessage(s.conn.NewOutgoingMessage(msg, chanID))
		if i != (l - 1) {
			time.Sleep(msgDelay)
		}
	}
}

// SendProtocolChannelMessage sends a message to a channel
func (s *slackConnector) SendProtocolChannelMessage(ch string, msg string, f bot.MessageFormat) (ret bot.RetVal) {
	chanID, ok := s.chanID(ch)
	if !ok {<commit_msg>Slightly increased message delay with typing indicator<commit_after>package slack

import (
	"time"

	"github.com/uva-its/gopherbot/bot"
)

// Message send delay; slack has problems with scrolling if messages fly out
// too fast.
const msgDelay = 200 * time.Millisecond

// GetUserAttribute returns a string attribute or nil if slack doesn't
// have that information
func (s *slackConnector) GetProtocolUserAttribute(u, attr string) (value string, ret bot.RetVal) {
	user, ok := s.getUser(u)
	if !ok {
		return "", bot.UserNotFound
	}
	switch attr {
	case "email":
		return user.Profile.Email, bot.Ok
	case "realName", "fullName":
		return user.RealName, bot.Ok
	case "firstName":
		return user.Profile.FirstName, bot.Ok
	case "lastName":
		return user.Profile.LastName, bot.Ok
	case "phone":
		return user.Profile.Phone, bot.Ok
	// that's all the attributes we can currently get from slack
	default:
		return "", bot.AttributeNotFound
	}
}

func (s *slackConnector) sendMessages(msgs []string, chanID string) {
	for i, msg := range msgs {
		if i == 0 {
			time.Sleep(msgDelay / 2)
			s.conn.SendMessage(s.conn.NewTypingMessage(chanID))
			time.Sleep(2 * msgDelay)
		}
		time.Sleep(msgDelay)
		s.conn.SendMessage(s.conn.NewOutgoingMessage(msg, chanID))
	}
}

// SendProtocolChannelMessage sends a message to a channel
func (s *slackConnector) SendProtocolChannelMessage(ch string, msg string, f bot.MessageFormat) (ret bot.RetVal) {
	chanID, ok := s.chanID(ch)
	if !ok {
{'fraction_non_alphanumeric': 0.11714890613973183, 'fraction_numerical': 0.0035285815102328866, 'mean_word_length': 4.135869565217392, 'pattern_counts': {'":': 10, '<': 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': '912956', 'n_tokens_mistral': 1006, 'n_tokens_neox': 946, 'n_words': 285}