parent
190f0d3fd0
commit
434e722f92
24
upstream.go
24
upstream.go
@ -54,6 +54,7 @@ type upstreamConn struct {
|
||||
channels map[string]*upstreamChannel
|
||||
caps map[string]string
|
||||
batches map[string]batch
|
||||
away bool
|
||||
|
||||
tagsSupported bool
|
||||
labelsSupported bool
|
||||
@ -1269,6 +1270,8 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
|
||||
// TODO: relay to downstream connections that accept message-tags
|
||||
case "ACK":
|
||||
// Ignore
|
||||
case irc.RPL_NOWAWAY, irc.RPL_UNAWAY:
|
||||
// Ignore
|
||||
case irc.RPL_YOURHOST, irc.RPL_CREATED:
|
||||
// Ignore
|
||||
case irc.RPL_LUSERCLIENT, irc.RPL_LUSEROP, irc.RPL_LUSERUNKNOWN, irc.RPL_LUSERCHANNELS, irc.RPL_LUSERME:
|
||||
@ -1483,3 +1486,24 @@ func (uc *upstreamConn) appendLog(entity string, format string, a ...interface{}
|
||||
uc.logger.Printf("failed to log message to %q: %v", log.name, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (uc *upstreamConn) updateAway() {
|
||||
away := true
|
||||
uc.forEachDownstream(func(*downstreamConn) {
|
||||
away = false
|
||||
})
|
||||
if away == uc.away {
|
||||
return
|
||||
}
|
||||
if away {
|
||||
uc.SendMessage(&irc.Message{
|
||||
Command: "AWAY",
|
||||
Params: []string{"Auto away"},
|
||||
})
|
||||
} else {
|
||||
uc.SendMessage(&irc.Message{
|
||||
Command: "AWAY",
|
||||
})
|
||||
}
|
||||
uc.away = away
|
||||
}
|
||||
|
11
user.go
11
user.go
@ -175,7 +175,8 @@ func (u *user) run() {
|
||||
for e := range u.events {
|
||||
switch e := e.(type) {
|
||||
case eventUpstreamConnected:
|
||||
// Nothing to do
|
||||
uc := e.uc
|
||||
uc.updateAway()
|
||||
case eventUpstreamDisconnected:
|
||||
uc := e.uc
|
||||
for _, log := range uc.logs {
|
||||
@ -200,6 +201,10 @@ func (u *user) run() {
|
||||
}
|
||||
|
||||
u.downstreamConns = append(u.downstreamConns, dc)
|
||||
|
||||
u.forEachUpstream(func(uc *upstreamConn) {
|
||||
uc.updateAway()
|
||||
})
|
||||
case eventDownstreamDisconnected:
|
||||
dc := e.dc
|
||||
for i := range u.downstreamConns {
|
||||
@ -208,6 +213,10 @@ func (u *user) run() {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
u.forEachUpstream(func(uc *upstreamConn) {
|
||||
uc.updateAway()
|
||||
})
|
||||
case eventDownstreamMessage:
|
||||
msg, dc := e.msg, e.dc
|
||||
if dc.isClosed() {
|
||||
|
Loading…
Reference in New Issue
Block a user