<commit_before>package main

import (
	"fmt"
	"log"
	"math/rand"
	"time"

	"github.com/tbruyelle/hipchat-go/hipchat"
)

const (
	hipchatRetry          = 30 // 30 seconds
	hipChatInterval int32 = 6  // Will be modify with random 0 to 5
)

func newHipChatPull(roomID, token string) *HipChatPull {
	hb := &HipChatPull{
		roomID:     roomID,
		token:      token,
		maxResults: 1,
		client:     hipchat.NewClient(token),
	}

	go hb.receiver()

	return hb
}

type HipChatPull struct {
	roomID    string
	token     string
	client    *hipchat.Client
	lastMsgID string
	related   []*HipChat

	maxResults int
}

func (hb *HipChatPull) sender(message *Message) {

	if !ignoreDup(fmt.Sprintf("hipchat:%s:%s", hb.roomID, message.msg)) {
		log.Printf("Ignore repeated message on %s %s", "hipchat", hb.roomID)
		return
	}

	if message.score > 5 {
		notifRq := &hipchat.NotificationRequest{
			Color:   "red",
			Message: fmt.Sprintf("@all %s", message.msg),
		}
		_, err := hb.client.Room.Notification(hb.roomID, notifRq)
		if err != nil {
			log.Printf("HipChat Pull ERROR [%s]: %s", hb.roomID, err)
		}
	} else {
		msgReq := &hipchat.RoomMessageRequest{
			Message: fmt.Sprintf("%s", message.msg),
		}
		_, err := hb.client.Room.Message(hb.roomID, msgReq)
		if err != nil {
			log.Printf("HipChat Pull ERROR [%s]: %s", hb.roomID, err)
		}
	}
}

func (hb *HipChatPull) receiver() {

	hb.maxResults = 1

	for {

		hist, resp, err := hb.client.Room.Latest(hb.roomID, &hipchat.LatestHistoryOptions{
			MaxResults: hb.maxResults,
			NotBefore:  hb.lastMsgID,
		})

		if err != nil {
			log.Printf("HipChat Pull ERROR [RoomID %s] [code %d]: %s", hb.roomID, resp.StatusCode, err)<commit_msg>Limits for hipchat<commit_after>package main

import (
	"fmt"
	"log"
	"math/rand"
	"time"

	"github.com/tbruyelle/hipchat-go/hipchat"
)

const (
	hipchatRetry          = 30 // 30 seconds
	hipChatInterval int32 = 15 // Will be modify with random 0 to 5
)

func newHipChatPull(roomID, token string) *HipChatPull {
	hb := &HipChatPull{
		roomID:     roomID,
		token:      token,
		maxResults: 1,
		client:     hipchat.NewClient(token),
	}

	go hb.receiver()

	return hb
}

type HipChatPull struct {
	roomID    string
	token     string
	client    *hipchat.Client
	lastMsgID string
	related   []*HipChat

	maxResults int
}

func (hb *HipChatPull) sender(message *Message) {

	if !ignoreDup(fmt.Sprintf("hipchat:%s:%s", hb.roomID, message.msg)) {
		log.Printf("Ignore repeated message on %s %s", "hipchat", hb.roomID)
		return
	}

	if message.score > 5 {
		notifRq := &hipchat.NotificationRequest{
			Color:   "red",
			Message: fmt.Sprintf("@all %s", message.msg),
		}
		_, err := hb.client.Room.Notification(hb.roomID, notifRq)
		if err != nil {
			log.Printf("HipChat Pull ERROR [%s]: %s", hb.roomID, err)
		}
	} else {
		msgReq := &hipchat.RoomMessageRequest{
			Message: fmt.Sprintf("%s", message.msg),
		}
		_, err := hb.client.Room.Message(hb.roomID, msgReq)
		if err != nil {
			log.Printf("HipChat Pull ERROR [%s]: %s", hb.roomID, err)
		}
	}
}

func (hb *HipChatPull) receiver() {

	hb.maxResults = 1

	for {

		hist, resp, err := hb.client.Room.Latest(hb.roomID, &hipchat.LatestHistoryOptions{
			MaxResults: hb.maxResults,
			NotBefore:  hb.lastMsgID,
		})

		if err != nil {
			log.Printf("HipChat Pull ERROR [RoomID %s]: %s", hb.roomID, err)
			log.Printf("HipChat Pull ERROR [RoomID %s] response: %#v", hb.roomID, resp)
{'fraction_non_alphanumeric': 0.14798470138275963, 'fraction_numerical': 0.0073551044424830835, 'mean_word_length': 3.4041450777202074, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5773280', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1328, 'n_words': 305}