libnmdc: fix PM detection

This commit is contained in:
mappu 2016-04-02 14:01:58 +13:00
parent c532e2fe4f
commit d6339667fe

View File

@ -69,7 +69,7 @@ var rx_incomingTo *regexp.Regexp
func init() { func init() {
rx_protocolMessage = regexp.MustCompile("(?ms)^[^|]*|") rx_protocolMessage = regexp.MustCompile("(?ms)^[^|]*|")
rx_publicChat = regexp.MustCompile("(?ms)^<([^>]*)> (.*)$") rx_publicChat = regexp.MustCompile("(?ms)^<([^>]*)> (.*)$")
rx_incomingTo = regexp.MustCompile("(?ms)^([^ ]+) From: ([^ ]+) $<([^>]*)> (.*)$") rx_incomingTo = regexp.MustCompile("(?ms)^([^ ]+) From: ([^ ]+) \\$<([^>]*)> (.*)")
} }
type HubConnectionOptions struct { 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]) { if rx_incomingTo.MatchString(commandParts[1]) {
txparts := rx_incomingTo.FindStringSubmatch(commandParts[1]) txparts := rx_incomingTo.FindStringSubmatch(commandParts[1])
if txparts[0] == this.Hco.Self.Nick && txparts[1] == txparts[2] { if txparts[1] == this.Hco.Self.Nick && txparts[2] == txparts[3] {
this.OnEvent <- HubEvent{EventType: EVENT_PRIVATE, Nick: txparts[1], Message: txparts[3]} this.OnEvent <- HubEvent{EventType: EVENT_PRIVATE, Nick: txparts[2], Message: txparts[4]}
break valid = true
} }
} }
if !valid {
this.OnEvent <- HubEvent{EventType: EVENT_DEBUG_MESSAGE, Message: "Malformed private message '" + commandParts[1] + "'"} this.OnEvent <- HubEvent{EventType: EVENT_DEBUG_MESSAGE, Message: "Malformed private message '" + commandParts[1] + "'"}
}
case "$UserIP": case "$UserIP":
// Final message in PtokaX connection handshake - trigger connection callback. // Final message in PtokaX connection handshake - trigger connection callback.