package main import ( "bufio" "crypto/tls" "fmt" "strings" ) const ( host string = "pph21.duckdns.org:6697" ) func main() { conn, err := tls.Dial("tcp", host, &tls.Config{RootCAs: nil}) if err != nil { panic("Failed to connect") } defer conn.Close() reader := bufio.NewReader(conn) fmt.Fprintln(conn, "PASS horal") fmt.Fprintln(conn, "USER bot rpi3 rpi3 :botik obecny") fmt.Fprintln(conn, "NICK botik") fmt.Fprintln(conn, "JOIN #test") for { in, _ := reader.ReadString('\n') words := strings.Fields(in) who := strings.Split(words[0], "!")[0][1:] if who == "botik" { continue } switch words[1] { case "JOIN": fmt.Fprintln(conn, "PRIVMSG "+words[2]+" :VĂ­tej "+who) case "PRIVMSG": if words[3] == ":!pozdrav" { if []rune(words[2])[0] == '#' { fmt.Fprintln(conn, "PRIVMSG "+words[2]+" :Ahoj "+who) } else { fmt.Fprintln(conn, "PRIVMSG "+who+" :Ahoj "+who) } } } if words[0] == "PING" { fmt.Println("PONG") fmt.Fprintln(conn, "PONG "+words[1]) } } }