commit 7243ec742af4d67eb619b4476331213d5f0eecb2
parent 600f0c1eb1fc25636a01121b47b1b8ee2d3ce168
Author: Gregory 'GaLi' Cavelier <gcavelier@cleia.org>
Date: Thu, 31 Aug 2023 11:31:57 +0200
!addfeed: check if a feed already exists before adding it
Diffstat:
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 {