|
|
|
@ -237,6 +237,7 @@ func main() {
|
|
|
|
|
flagSkipVerify := getopt.BoolLong("no-tls-verify", 'n',
|
|
|
|
|
"Skip verification of TLS certificates (not recommended).")
|
|
|
|
|
flagRaw := getopt.BoolLong("raw", 0, "Send raw XML.")
|
|
|
|
|
flagListen := getopt.BoolLong("listen", 'l', "Listen for first message from user and echo.")
|
|
|
|
|
|
|
|
|
|
// Parse command line flags.
|
|
|
|
|
getopt.Parse()
|
|
|
|
@ -248,10 +249,11 @@ func main() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Read recipients from command line and quit if none are specified.
|
|
|
|
|
// For sending raw XML it's not required to specify a recipient except
|
|
|
|
|
// for MUCs (go-sendxmpp will join the MUC automatically).
|
|
|
|
|
// For listening or sending raw XML it's not required to specify a recipient except
|
|
|
|
|
// when sending raw messages to MUCs (go-sendxmpp will join the MUC automatically).
|
|
|
|
|
recipients := getopt.Args()
|
|
|
|
|
if (len(recipients) == 0 && !*flagRaw) || (len(recipients) == 0 && *flagChatroom) {
|
|
|
|
|
if (len(recipients) == 0 && !*flagRaw && !*flagListen) ||
|
|
|
|
|
(len(recipients) == 0 && *flagChatroom) {
|
|
|
|
|
log.Fatal("No recipient specified.")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -361,7 +363,8 @@ func main() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Skip reading message if '-i' or '--interactive' is set to work with e.g. 'tail -f'.
|
|
|
|
|
if !*flagInteractive {
|
|
|
|
|
// Also for listening mode.
|
|
|
|
|
if !*flagInteractive && !*flagListen {
|
|
|
|
|
if message == "" {
|
|
|
|
|
|
|
|
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
|
|
@ -418,6 +421,24 @@ func main() {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if *flagListen {
|
|
|
|
|
for {
|
|
|
|
|
recieved, err := client.Recv()
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Println(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch v := recieved.(type) {
|
|
|
|
|
case xmpp.Chat:
|
|
|
|
|
if v.Text != "" {
|
|
|
|
|
fmt.Println(v.Text)
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send message to chatroom(s) if the flag is set.
|
|
|
|
|
if *flagChatroom {
|
|
|
|
|
|
|
|
|
|