gruik

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

commit 11a9a7c7da2077e0ef66bcd0fb8aff3088c4767c
parent ceeb962d84ef5adb1a9c119c45df9d167dc07d4b
Author: S├ębastien Marie <semarie@online.fr>
Date:   Tue, 18 Jul 2023 09:16:41 +0000

!latest: show "no news available" later (to support it when origin is used)

Diffstat:
Mmain.go | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/main.go b/main.go @@ -293,11 +293,7 @@ func main() { } if strings.HasPrefix(e.Last(), "!latest") && e.Params[0] != channel { numNews := len(newsList) - if numNews < 1 { - c.Cmd.Message(dest, "no news available") - time.Sleep(viper.GetDuration("irc.delay")) - return - } + args := strings.SplitN(e.Last(), " ", 3) if len(args) < 2 { c.Cmd.Message(dest, "usage: !latest <number> [origin]") @@ -317,6 +313,12 @@ func main() { showNews = getNewsByOrigin(args[2]) numNews = len(showNews) } + // check if some news are available + if numNews < 1 { + c.Cmd.Message(dest, "no news available") + time.Sleep(viper.GetDuration("irc.delay")) + return + } // user gave a greater number that we have news if n > numNews { n = numNews