<commit_before>package RSSModule

import (
	"context"
	"fmt"
	"github.com/SlyMarbo/rss"
	"github.com/gendonl/genbot/Bot"
	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/mongo/options"
	"strings"
	"time"
)

type RSSPoll struct {
	Url string `bson:"url"`
	LastUpdated time.Time `bson:"last-updated"`
	Channels []string `bson:"channels"`
}

func (c *RSSModule) initPolling() {
	// Whatever happens, do NOT go down.
	defer func() {
		if r := recover(); r != nil {
			Log.Criticalf("Bot panicked while polling: ", r)
		}
	}()

	time.Sleep(5 * time.Second)

	// Start polling
	for {
		c.poll()

		// Lazy update once every 60 second
		// If functionality is used more often, this has to be updated to reduce latency
		time.Sleep(60 * time.Second)
		break
	}
}

func (c *RSSModule) poll() {
	if Bot.RSSCollection == nil {
		return
	}

	ctx, _ := context.WithTimeout(context.Background(), 30*time.Second)
	filter := bson.M{}
	cursor, err := Bot.RSSCollection.Find(ctx, filter)
	if err != nil {
		Log.Error(err)
		return
	}

	defer cursor.Close(ctx)
	for cursor.Next(ctx) {
		var result RSSPoll
		err := cursor.Decode(&result)
		if err != nil {
			Log.Error(err)
			continue
		}

		c.checkUpdates(result)<commit_msg>Fix bug with RSSPolling<commit_after>package RSSModule

import (
	"context"
	"fmt"
	"github.com/SlyMarbo/rss"
	"github.com/gendonl/genbot/Bot"
	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/mongo/options"
	"strings"
	"time"
)

type RSSPoll struct {
	Url string `bson:"url"`
	LastUpdated time.Time `bson:"last-updated"`
	Channels []string `bson:"channels"`
}

func (c *RSSModule) initPolling() {
	// Whatever happens, do NOT go down.
	defer func() {
		if r := recover(); r != nil {
			Log.Criticalf("Bot panicked while polling: ", r)
		}
	}()

	time.Sleep(5 * time.Second)

	// Start polling
	for {
		c.poll()

		// Lazy update once every 60 second
		// If functionality is used more often, this has to be updated to reduce latency
		time.Sleep(60 * time.Second)
	}
}

func (c *RSSModule) poll() {
	if Bot.RSSCollection == nil {
		return
	}

	ctx, _ := context.WithTimeout(context.Background(), 30*time.Second)
	filter := bson.M{}
	cursor, err := Bot.RSSCollection.Find(ctx, filter)
	if err != nil {
		Log.Error(err)
		return
	}

	defer cursor.Close(ctx)
	for cursor.Next(ctx) {
		var result RSSPoll
		err := cursor.Decode(&result)
		if err != nil {
			Log.Error(err)
			continue
		}

		c.checkUpdates(result)
{'fraction_non_alphanumeric': 0.14763458401305057, 'fraction_numerical': 0.005709624796084829, 'mean_word_length': 3.5174953959484347, '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': '4771615', 'n_tokens_mistral': 1014, 'n_tokens_neox': 921, 'n_words': 223}