CTF2021/irc_bot
Archived
4
0

Get channel from env

This commit is contained in:
Denis Zheleztsov 2021-01-16 18:23:56 +03:00
parent c838efbf27
commit 14c3b9bcf9
Signed by: Difrex
GPG Key ID: D423378A747E202E

15
main.go
View File

@ -16,10 +16,10 @@ import (
irc "github.com/thoj/go-ircevent" irc "github.com/thoj/go-ircevent"
) )
const channel = "#ctf" var channel = "#ctf"
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"
nyastat = "nyastat" nyastat = "nyastat"
msgPrefix = "I love cats! Here's a fact: %s ^_^" msgPrefix = "I love cats! Here's a fact: %s ^_^"
gifPrefix = "Meow! Here's a gif: %s ^_^" gifPrefix = "Meow! Here's a gif: %s ^_^"
@ -103,10 +103,6 @@ func main() {
e.Connection.Privmsg(channel, `Now with gifs! ^_^`) e.Connection.Privmsg(channel, `Now with gifs! ^_^`)
}) })
irccon.AddCallback("MODE", func(e *irc.Event) {
log.Println(e.Message())
})
irccon.AddCallback("PRIVMSG", func(e *irc.Event) { irccon.AddCallback("PRIVMSG", func(e *irc.Event) {
log.Printf("Message from %s received: %s", e.Nick, e.Message()) log.Printf("Message from %s received: %s", e.Nick, e.Message())
s.addUser(e.Nick) s.addUser(e.Nick)
@ -194,3 +190,10 @@ func catFacts(con *irc.Connection) (string, error) {
con.Privmsg(channel, fmt.Sprintf(msgPrefix, data.Fact)) con.Privmsg(channel, fmt.Sprintf(msgPrefix, data.Fact))
return fmt.Sprintf(msgPrefix, data.Fact), nil return fmt.Sprintf(msgPrefix, data.Fact), nil
} }
func init() {
ch := os.Getenv("CTF2021CHANNEL")
if ch != "" {
channel = ch
}
}