diff --git a/src/libnmdc/libnmdc.go b/src/libnmdc/libnmdc.go index b8f6227..7f1d65e 100644 --- a/src/libnmdc/libnmdc.go +++ b/src/libnmdc/libnmdc.go @@ -69,7 +69,7 @@ var rx_incomingTo *regexp.Regexp func init() { rx_protocolMessage = regexp.MustCompile("(?ms)^[^|]*|") rx_publicChat = regexp.MustCompile("(?ms)^<([^>]*)> (.*)$") - rx_incomingTo = regexp.MustCompile("(?ms)^([^ ]+) From: ([^ ]+) $<([^>]*)> (.*)$") + rx_incomingTo = regexp.MustCompile("(?ms)^([^ ]+) From: ([^ ]+) \\$<([^>]*)> (.*)") } type HubConnectionOptions struct { @@ -273,15 +273,19 @@ func (this *HubConnection) processProtocolMessage(message string) { } } - case "$To": + case "$To:": + valid := false if rx_incomingTo.MatchString(commandParts[1]) { txparts := rx_incomingTo.FindStringSubmatch(commandParts[1]) - if txparts[0] == this.Hco.Self.Nick && txparts[1] == txparts[2] { - this.OnEvent <- HubEvent{EventType: EVENT_PRIVATE, Nick: txparts[1], Message: txparts[3]} - break + if txparts[1] == this.Hco.Self.Nick && txparts[2] == txparts[3] { + this.OnEvent <- HubEvent{EventType: EVENT_PRIVATE, Nick: txparts[2], Message: txparts[4]} + valid = true } } - this.OnEvent <- HubEvent{EventType: EVENT_DEBUG_MESSAGE, Message: "Malformed private message '" + commandParts[1] + "'"} + + if !valid { + this.OnEvent <- HubEvent{EventType: EVENT_DEBUG_MESSAGE, Message: "Malformed private message '" + commandParts[1] + "'"} + } case "$UserIP": // Final message in PtokaX connection handshake - trigger connection callback.