quirks support
--HG-- branch : nmdc-ircfrontend
This commit is contained in:
parent
1056493211
commit
f076aeaeda
32
server.go
32
server.go
@ -40,6 +40,30 @@ const (
|
|||||||
CSJoined
|
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 {
|
type Server struct {
|
||||||
name string
|
name string
|
||||||
motd string
|
motd string
|
||||||
@ -59,6 +83,8 @@ type Server struct {
|
|||||||
recievedFirstServerMessage bool
|
recievedFirstServerMessage bool
|
||||||
recievedCtcpVersion bool
|
recievedCtcpVersion bool
|
||||||
nickChangeAttempt int
|
nickChangeAttempt int
|
||||||
|
|
||||||
|
quirks Quirks
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(name string, upstream libnmdc.HubAddress, conn net.Conn) *Server {
|
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,
|
SkipAutoReconnect: true,
|
||||||
},
|
},
|
||||||
upstreamCloser: make(chan struct{}, 1),
|
upstreamCloser: make(chan struct{}, 1),
|
||||||
|
quirks: DefaultQuirks(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,6 +466,7 @@ func (s *Server) handleRegisteredCommand(command string, args []string) {
|
|||||||
versionString := message[9:]
|
versionString := message[9:]
|
||||||
versionString = versionString[:len(versionString)-1]
|
versionString = versionString[:len(versionString)-1]
|
||||||
s.SetClientSoftwareVersion(versionString)
|
s.SetClientSoftwareVersion(versionString)
|
||||||
|
s.quirks = GetQuirksForClient(versionString)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -636,6 +664,10 @@ func (s *Server) handleJoinedCommand(command string, args []string) {
|
|||||||
// s.sendWho(args[0])
|
// s.sendWho(args[0])
|
||||||
// s.sendNames() // fixes hexchat, but andchat always sends WHO /immediately/ after NAMES end, causing an infinite loop
|
// 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":
|
case "MODE":
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
s.reply(errMoreArgs)
|
s.reply(errMoreArgs)
|
||||||
|
Loading…
Reference in New Issue
Block a user