commit 1e632af6642fd57c02af84a76319414084306de1
parent d3506035ac77a3623928bcee8568d47cb02d6ddf
Author: Sébastien Marie <semarie@online.fr>
Date: Tue, 18 Jul 2023 09:09:47 +0000
!xpost: get the news and format it only once
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/main.go b/main.go
@@ -282,10 +282,11 @@ func main() {
if s == "" {
return
}
- for _, xchan := range viper.GetStringSlice("irc.xchannels") {
- if news := getNewsByHash(s); news.Hash != "" {
- post := fmt.Sprintf(" {r}(from %s on %s)", e.Source.Name, channel)
- c.Cmd.Message(xchan, fmtNews(news) + girc.Fmt(post))
+ if news := getNewsByHash(s); news.Hash != "" {
+ post := fmt.Sprintf(" {r}(from %s on %s)", e.Source.Name, channel)
+ message := fmtNews(news) + girc.Fmt(post)
+ for _, xchan := range viper.GetStringSlice("irc.xchannels") {
+ c.Cmd.Message(xchan, message)
time.Sleep(viper.GetDuration("irc.delay"))
}
}