From 19950face638427af90802047026e65d3a19c73b Mon Sep 17 00:00:00 2001 From: Denis Zheleztsov Date: Sat, 16 Jan 2021 18:34:10 +0300 Subject: [PATCH] Don't send welcome message if envvar is empty --- main.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index b522f38..6cf1946 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,7 @@ import ( ) var channel = "#ctf" +var sendWelcome = "" const ( pattern = "(?i)\\b(cat|gato|miau|meow|garfield|lolcat|кот|кошк)[s|z]{0,1}\\b" @@ -95,12 +96,14 @@ func main() { e.Connection.Privmsg("nickserv", "identify "+os.Getenv("CTF2021PASS")) - e.Connection.Join(channel) - e.Connection.Privmsg(channel, `I'm a cat bot!`) - e.Connection.Privmsg(channel, `Inspired from https://github.com/go-chat-bot/plugins/blob/master/catfacts/catfacts.go`) - e.Connection.Privmsg(channel, `Try cat /etc/passwd :p`) - e.Connection.Privmsg(channel, `Source code and issue tracker: https://gitea.difrex.ru/CTF2021/irc_bot`) - e.Connection.Privmsg(channel, `Now with gifs! ^_^`) + if sendWelcome != "" { + e.Connection.Join(channel) + e.Connection.Privmsg(channel, `I'm a cat bot!`) + e.Connection.Privmsg(channel, `Inspired from https://github.com/go-chat-bot/plugins/blob/master/catfacts/catfacts.go`) + e.Connection.Privmsg(channel, `Try cat /etc/passwd :p`) + e.Connection.Privmsg(channel, `Source code and issue tracker: https://gitea.difrex.ru/CTF2021/irc_bot`) + e.Connection.Privmsg(channel, `Now with gifs! ^_^`) + } }) irccon.AddCallback("PRIVMSG", func(e *irc.Event) { @@ -118,10 +121,10 @@ func main() { } func doCommand(command string, e *irc.Event, s *stats) { - if ok := statCommand(command); ok { - s.printStats(e) - return - } + // if ok := statCommand(command); ok { + // s.printStats(e) + // return + // } if ok := checkCommad(command, e.Connection); !ok { return @@ -196,4 +199,6 @@ func init() { if ch != "" { channel = ch } + + sendWelcome = os.Getenv("CTF2021WC") }