diff --git a/AdcProtocol.go b/AdcProtocol.go index 56b42aa..e079df9 100644 --- a/AdcProtocol.go +++ b/AdcProtocol.go @@ -229,14 +229,36 @@ func (this *AdcProtocol) ProcessCommand(msg string) { case "IQUI": // Error message from the hub // IQUI V3M6 DI1 MSNick\staken,\splease\spick\sanother\sone TL-1 - flags, err := this.parts2flags(parts[1:]) + if len(parts) < 2 { + this.malformed(parts) + return + } + + sid := parts[1] + + flags, err := this.parts2flags(parts[2:]) if err != nil { return } - if msg, ok := flags["MS"]; ok { - this.hc.processEvent(HubEvent{EventType: EVENT_SYSTEM_MESSAGE_FROM_HUB, Message: "The hub is closing our connection because: " + this.unescape(msg)}) + + if sid == this.sid { + if msg, ok := flags["MS"]; ok { + this.hc.processEvent(HubEvent{EventType: EVENT_SYSTEM_MESSAGE_FROM_HUB, Message: "The hub is closing our connection because: " + this.unescape(msg)}) + } else { + this.hc.processEvent(HubEvent{EventType: EVENT_SYSTEM_MESSAGE_FROM_HUB, Message: "The hub is closing our connection"}) + } } else { - this.hc.processEvent(HubEvent{EventType: EVENT_SYSTEM_MESSAGE_FROM_HUB, Message: "The hub is closing our connection"}) + this.hc.usersMut.Lock() + defer this.hc.usersMut.Unlock() + otherSidNick, ok := this.hc.userSIDs[sid] + if ok { + delete(this.hc.userSIDs, sid) + delete(this.hc.users, otherSidNick) + this.hc.processEvent(HubEvent{EventType: EVENT_USER_PART, Nick: otherSidNick}) + } else { + // ?? + this.logError(fmt.Errorf("An unknown user quit the hub (SID=%s)", sid)) + } } case "BMSG":