gruik

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

commit 7b52af3365e4c832904ffac23d8d287b5a44854f
parent 600f0c1eb1fc25636a01121b47b1b8ee2d3ce168
Author: Emile "iMil" Heitor <imil@netbsd.org>
Date:   Mon, 25 Sep 2023 07:27:02 +0000

Merge branch 'addfeed_check_exists' into 'main'

!addfeed: check if a feed already exists before adding it

See merge request gcu-squad/gruik!3
Diffstat:
Mmain.go | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/main.go b/main.go @@ -349,7 +349,13 @@ func main() { if url == "" { return } - feeds := append(viper.GetStringSlice("feeds.urls"), url) + feeds := viper.GetStringSlice("feeds.urls") + for _, feed := range feeds { + if feed == url { + return + } + } + feeds = append(feeds, url) viper.Set("feeds.urls", feeds) c.Cmd.ReplyTo(e, girc.Fmt("feed {b}{green}added{c}{b}")) if err := viper.WriteConfig(); err != nil {