gruik

Fork of GCU-Squad's RSS-to-IRC bridge
git clone https://git.instinctive.eu/gruik.git
Log | Files | Refs | README | LICENSE

commit f88acabad277472e61633904709cf52c3b5005ae
parent 39c87f159c0ba63661a3775239505f0d563cd8d3
Author: Emile 'iMil' Heitor <imil@NetBSD.org>
Date:   Fri, 14 Jul 2023 18:18:54 +0200

feat: make news ring configurable

Diffstat:
MREADME.md | 1+
Mmain.go | 5++---
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md @@ -48,6 +48,7 @@ feeds: maxnews: 10 # optional maxage: 1h # optional frequency: 5m # optional + ringsize: 100 # optional, number of news to rotate on ``` ## Usage diff --git a/main.go b/main.go @@ -24,8 +24,6 @@ type News struct { Hash string `json:"hash"` } -const maxNews = 100 - var newsList []News // Create a hash out of news title and link @@ -149,7 +147,7 @@ func newsFetch(client *girc.Client, channel string) { time.Sleep(viper.GetDuration("irc.delay")) // Mark item as posted - if len(newsList) < maxNews { + if len(newsList) < viper.GetInt("feeds.ringsize") { newsList = append(newsList, news) } else { newsList = append(newsList[1:], news) @@ -188,6 +186,7 @@ func confDefault() { "feeds.maxnews": 10, "feeds.maxage": "1h", "feeds.frequency": "10m", + "feeds.ringsize": 100, } for k, v := range kv {