diff --git a/server.go b/server.go index f4987f1..df5d0f1 100644 --- a/server.go +++ b/server.go @@ -40,6 +40,30 @@ const ( CSJoined ) +type Quirks struct { + SendNamesOnWho bool +} + +func DefaultQuirks() Quirks { + return Quirks{ + SendNamesOnWho: false, + } +} + +func HexChatQuirks() Quirks { + return Quirks{ + SendNamesOnWho: true, + } +} + +func GetQuirksForClient(ver string) Quirks { + if strings.Contains(ver, "HexChat") { + return HexChatQuirks() + } else { + return DefaultQuirks() + } +} + type Server struct { name string motd string @@ -59,6 +83,8 @@ type Server struct { recievedFirstServerMessage bool recievedCtcpVersion bool nickChangeAttempt int + + quirks Quirks } func NewServer(name string, upstream libnmdc.HubAddress, conn net.Conn) *Server { @@ -77,6 +103,7 @@ func NewServer(name string, upstream libnmdc.HubAddress, conn net.Conn) *Server SkipAutoReconnect: true, }, upstreamCloser: make(chan struct{}, 1), + quirks: DefaultQuirks(), } } @@ -439,6 +466,7 @@ func (s *Server) handleRegisteredCommand(command string, args []string) { versionString := message[9:] versionString = versionString[:len(versionString)-1] s.SetClientSoftwareVersion(versionString) + s.quirks = GetQuirksForClient(versionString) return } @@ -636,6 +664,10 @@ func (s *Server) handleJoinedCommand(command string, args []string) { // s.sendWho(args[0]) // s.sendNames() // fixes hexchat, but andchat always sends WHO /immediately/ after NAMES end, causing an infinite loop + if s.quirks.SendNamesOnWho { + s.sendNames() + } + case "MODE": if len(args) < 1 { s.reply(errMoreArgs)