quirks support

--HG--
branch : nmdc-ircfrontend
This commit is contained in:
mappu 2017-05-28 17:36:31 +12:00
parent 1056493211
commit f076aeaeda

View File

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