libnmdc: fix PM detection

This commit is contained in:
mappu 2016-04-02 14:01:58 +13:00
parent c532e2fe4f
commit d6339667fe
1 changed files with 10 additions and 6 deletions

View File

@ -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.