print debug messages

This commit is contained in:
2022-08-19 16:26:06 +02:00
parent 4c63d27acb
commit 034d473ea0

View File

@@ -3,8 +3,10 @@ package main
import ( import (
"bufio" "bufio"
"crypto/tls" "crypto/tls"
"flag"
"fmt" "fmt"
"io" "io"
"os"
"os/exec" "os/exec"
"strings" "strings"
@@ -37,6 +39,10 @@ func sendMultiline(conn io.Writer, msg string, receiver string) {
} }
func main() { func main() {
// flags parse
var debug bool
flag.BoolVar(&debug, "D", false, "Print debug messages.")
flag.Parse()
// IRC init // IRC init
conn, err := tls.Dial("tcp", host, &tls.Config{RootCAs: nil}) conn, err := tls.Dial("tcp", host, &tls.Config{RootCAs: nil})
if err != nil { if err != nil {
@@ -55,6 +61,9 @@ func main() {
for { for {
in, _ := reader.ReadString('\n') in, _ := reader.ReadString('\n')
words := strings.Fields(in) words := strings.Fields(in)
if debug {
fmt.Fprintln(os.Stderr, words)
}
who := strings.Split(words[0], "!")[0][1:] who := strings.Split(words[0], "!")[0][1:]
if who == "botik" { if who == "botik" {
continue continue