|
|
|
@ -267,6 +267,39 @@ func main() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Skip reading message if '-i' or '--interactive' is set to work with e.g. 'tail -f'.
|
|
|
|
|
// Also for listening mode.
|
|
|
|
|
if !*flagInteractive && !*flagListen {
|
|
|
|
|
if message == "" {
|
|
|
|
|
|
|
|
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
|
|
|
for scanner.Scan() {
|
|
|
|
|
|
|
|
|
|
if message == "" {
|
|
|
|
|
message = scanner.Text()
|
|
|
|
|
} else {
|
|
|
|
|
message = message + "\n" + scanner.Text()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := scanner.Err(); err != nil {
|
|
|
|
|
if err != io.EOF {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove invalid code points.
|
|
|
|
|
message = strings.ToValidUTF8(message, "")
|
|
|
|
|
reg := regexp.MustCompile(`[\x{0000}-\x{0008}\x{000B}\x{000C}\x{000E}-\x{001F}]`)
|
|
|
|
|
message = reg.ReplaceAllString(message, "")
|
|
|
|
|
|
|
|
|
|
// Exit if message is empty.
|
|
|
|
|
if message == "" && !*flagInteractive {
|
|
|
|
|
os.Exit(0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Connect to server.
|
|
|
|
|
client, err := connect(options, *flagDirectTLS)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -357,34 +390,6 @@ func main() {
|
|
|
|
|
*flagHTTPUpload)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Skip reading message if '-i' or '--interactive' is set to work with e.g. 'tail -f'.
|
|
|
|
|
// Also for listening mode.
|
|
|
|
|
if !*flagInteractive && !*flagListen {
|
|
|
|
|
if message == "" {
|
|
|
|
|
|
|
|
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
|
|
|
for scanner.Scan() {
|
|
|
|
|
|
|
|
|
|
if message == "" {
|
|
|
|
|
message = scanner.Text()
|
|
|
|
|
} else {
|
|
|
|
|
message = message + "\n" + scanner.Text()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := scanner.Err(); err != nil {
|
|
|
|
|
if err != io.EOF {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove invalid code points.
|
|
|
|
|
message = strings.ToValidUTF8(message, "")
|
|
|
|
|
reg := regexp.MustCompile(`[\x{0000}-\x{0008}\x{000B}\x{000C}\x{000E}-\x{001F}]`)
|
|
|
|
|
message = reg.ReplaceAllString(message, "")
|
|
|
|
|
|
|
|
|
|
var msgType string
|
|
|
|
|
msgType = "chat"
|
|
|
|
|
if *flagChatroom {
|
|
|
|
|