CTF2021/irc_bot
Archived
4
0

Don't send welcome message if envvar is empty

This commit is contained in:
Denis Zheleztsov 2021-01-16 18:34:10 +03:00
parent 14c3b9bcf9
commit 19950face6
Signed by: Difrex
GPG Key ID: D423378A747E202E

13
main.go
View File

@ -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"))
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")
}