|
|
|
@ -420,10 +420,17 @@ func main() {
|
|
|
|
|
}
|
|
|
|
|
case *flagInteractive:
|
|
|
|
|
// Send in endless loop (for usage with e.g. "tail -f").
|
|
|
|
|
var reader = bufio.NewReader(os.Stdin)
|
|
|
|
|
for {
|
|
|
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
|
|
|
scanner.Scan()
|
|
|
|
|
message = scanner.Text()
|
|
|
|
|
message, err = reader.ReadString('\n')
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatal("failed to read from stdin")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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, "")
|
|
|
|
|
if message == "" {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|