Don't send welcome message if envvar is empty
This commit is contained in:
parent
14c3b9bcf9
commit
19950face6
13
main.go
13
main.go
@ -17,6 +17,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var channel = "#ctf"
|
var channel = "#ctf"
|
||||||
|
var sendWelcome = ""
|
||||||
|
|
||||||
const (
|
const (
|
||||||
pattern = "(?i)\\b(cat|gato|miau|meow|garfield|lolcat|кот|кошк)[s|z]{0,1}\\b"
|
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.Privmsg("nickserv", "identify "+os.Getenv("CTF2021PASS"))
|
||||||
|
|
||||||
|
if sendWelcome != "" {
|
||||||
e.Connection.Join(channel)
|
e.Connection.Join(channel)
|
||||||
e.Connection.Privmsg(channel, `I'm a cat bot!`)
|
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, `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, `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, `Source code and issue tracker: https://gitea.difrex.ru/CTF2021/irc_bot`)
|
||||||
e.Connection.Privmsg(channel, `Now with gifs! ^_^`)
|
e.Connection.Privmsg(channel, `Now with gifs! ^_^`)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
irccon.AddCallback("PRIVMSG", func(e *irc.Event) {
|
irccon.AddCallback("PRIVMSG", func(e *irc.Event) {
|
||||||
@ -118,10 +121,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func doCommand(command string, e *irc.Event, s *stats) {
|
func doCommand(command string, e *irc.Event, s *stats) {
|
||||||
if ok := statCommand(command); ok {
|
// if ok := statCommand(command); ok {
|
||||||
s.printStats(e)
|
// s.printStats(e)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
if ok := checkCommad(command, e.Connection); !ok {
|
if ok := checkCommad(command, e.Connection); !ok {
|
||||||
return
|
return
|
||||||
@ -196,4 +199,6 @@ func init() {
|
|||||||
if ch != "" {
|
if ch != "" {
|
||||||
channel = ch
|
channel = ch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendWelcome = os.Getenv("CTF2021WC")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user