<commit_before>package stats

import (
	"fmt"
	"strconv"
	"time"

	"github.com/gempir/go-twitch-irc/v2"
	"github.com/gempir/spamchamp/bot/api"
	"github.com/gempir/spamchamp/bot/store"
	"github.com/paulbellamy/ratecounter"
	log "github.com/sirupsen/logrus"
)

var (
	stats          = map[string]stat{}
	joinedChannels = 0
)

type Broadcaster struct {
	messageQueue   chan twitch.PrivateMessage
	broadcastQueue chan api.BroadcastMessage
	store          *store.Store
}

func NewBroadcaster(messageQueue chan twitch.PrivateMessage, broadcastQueue chan api.BroadcastMessage, store *store.Store) Broadcaster {
	return Broadcaster{
		messageQueue:   messageQueue,
		broadcastQueue: broadcastQueue,
		store:          store,
	}
}

func (b *Broadcaster) Start() {
	log.Info("[stats] starting stats collector")

	go b.startTicker()

	for message := range b.messageQueue {
		if message.ID == "28b511cc-43b3-44b7-a605-230aadbb2f9b" {
			log.Info(message.Message)
			var err error
			joinedChannels, err = strconv.Atoi(message.Message)
			if err != nil {
				log.Errorf("Failed to parse relaybroker message: %s", err.Error())
			}
			continue
		}
		if _, ok := stats[message.RoomID]; !ok {
			stats[message.RoomID] = newStat(message.Channel)
		}

		stats[message.RoomID].messages.Incr(1)
	}
}

func (b *Broadcaster) startTicker() {
	ticker := time.NewTicker(1 * time.Second)

	for range ticker.C {
		message := api.BroadcastMessage{
			Records: []api.Record{},
		}

		msgps := api.Record{
			Title:  "Current messages/s",
			Scores: []api.Score{},
		}<commit_msg>remove log message<commit_after>package stats

import (
	"fmt"
	"strconv"
	"time"

	"github.com/gempir/go-twitch-irc/v2"
	"github.com/gempir/spamchamp/bot/api"
	"github.com/gempir/spamchamp/bot/store"
	"github.com/paulbellamy/ratecounter"
	log "github.com/sirupsen/logrus"
)

var (
	stats          = map[string]stat{}
	joinedChannels = 0
)

type Broadcaster struct {
	messageQueue   chan twitch.PrivateMessage
	broadcastQueue chan api.BroadcastMessage
	store          *store.Store
}

func NewBroadcaster(messageQueue chan twitch.PrivateMessage, broadcastQueue chan api.BroadcastMessage, store *store.Store) Broadcaster {
	return Broadcaster{
		messageQueue:   messageQueue,
		broadcastQueue: broadcastQueue,
		store:          store,
	}
}

func (b *Broadcaster) Start() {
	log.Info("[stats] starting stats collector")

	go b.startTicker()

	for message := range b.messageQueue {
		if message.ID == "28b511cc-43b3-44b7-a605-230aadbb2f9b" {
			var err error
			joinedChannels, err = strconv.Atoi(message.Message)
			if err != nil {
				log.Errorf("Failed to parse relaybroker message: %s", err.Error())
			}
			continue
		}
		if _, ok := stats[message.RoomID]; !ok {
			stats[message.RoomID] = newStat(message.Channel)
		}

		stats[message.RoomID].messages.Incr(1)
	}
}

func (b *Broadcaster) startTicker() {
	ticker := time.NewTicker(1 * time.Second)

	for range ticker.C {
		message := api.BroadcastMessage{
			Records: []api.Record{},
		}

		msgps := api.Record{
			Title:  "Current messages/s",
			Scores: []api.Score{},
		}
{'fraction_non_alphanumeric': 0.12947299934938192, 'fraction_numerical': 0.014964216005204945, 'mean_word_length': 3.7822706065318816, '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': '3354340', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1107, 'n_words': 219}