parent
190f0d3fd0
commit
434e722f92
24
upstream.go
24
upstream.go
@ -54,6 +54,7 @@ type upstreamConn struct {
|
|||||||
channels map[string]*upstreamChannel
|
channels map[string]*upstreamChannel
|
||||||
caps map[string]string
|
caps map[string]string
|
||||||
batches map[string]batch
|
batches map[string]batch
|
||||||
|
away bool
|
||||||
|
|
||||||
tagsSupported bool
|
tagsSupported bool
|
||||||
labelsSupported bool
|
labelsSupported bool
|
||||||
@ -1269,6 +1270,8 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
|
|||||||
// TODO: relay to downstream connections that accept message-tags
|
// TODO: relay to downstream connections that accept message-tags
|
||||||
case "ACK":
|
case "ACK":
|
||||||
// Ignore
|
// Ignore
|
||||||
|
case irc.RPL_NOWAWAY, irc.RPL_UNAWAY:
|
||||||
|
// Ignore
|
||||||
case irc.RPL_YOURHOST, irc.RPL_CREATED:
|
case irc.RPL_YOURHOST, irc.RPL_CREATED:
|
||||||
// Ignore
|
// Ignore
|
||||||
case irc.RPL_LUSERCLIENT, irc.RPL_LUSEROP, irc.RPL_LUSERUNKNOWN, irc.RPL_LUSERCHANNELS, irc.RPL_LUSERME:
|
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)
|
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 {
|
for e := range u.events {
|
||||||
switch e := e.(type) {
|
switch e := e.(type) {
|
||||||
case eventUpstreamConnected:
|
case eventUpstreamConnected:
|
||||||
// Nothing to do
|
uc := e.uc
|
||||||
|
uc.updateAway()
|
||||||
case eventUpstreamDisconnected:
|
case eventUpstreamDisconnected:
|
||||||
uc := e.uc
|
uc := e.uc
|
||||||
for _, log := range uc.logs {
|
for _, log := range uc.logs {
|
||||||
@ -200,6 +201,10 @@ func (u *user) run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
u.downstreamConns = append(u.downstreamConns, dc)
|
u.downstreamConns = append(u.downstreamConns, dc)
|
||||||
|
|
||||||
|
u.forEachUpstream(func(uc *upstreamConn) {
|
||||||
|
uc.updateAway()
|
||||||
|
})
|
||||||
case eventDownstreamDisconnected:
|
case eventDownstreamDisconnected:
|
||||||
dc := e.dc
|
dc := e.dc
|
||||||
for i := range u.downstreamConns {
|
for i := range u.downstreamConns {
|
||||||
@ -208,6 +213,10 @@ func (u *user) run() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u.forEachUpstream(func(uc *upstreamConn) {
|
||||||
|
uc.updateAway()
|
||||||
|
})
|
||||||
case eventDownstreamMessage:
|
case eventDownstreamMessage:
|
||||||
msg, dc := e.msg, e.dc
|
msg, dc := e.msg, e.dc
|
||||||
if dc.isClosed() {
|
if dc.isClosed() {
|
||||||
|
Loading…
Reference in New Issue
Block a user