downstream: improve unmarshalEntityNetwork error message

Closes: https://todo.sr.ht/~emersion/soju/162
This commit is contained in:
Simon Ser 2021-11-29 16:41:52 +01:00
parent c36192ab02
commit 522e20cca1

View File

@ -431,6 +431,12 @@ func (dc *downstreamConn) unmarshalEntityNetwork(name string) (*network, string,
if dc.network != nil {
return dc.network, name, nil
}
if !dc.isMultiUpstream {
return nil, "", ircError{&irc.Message{
Command: irc.ERR_NOSUCHCHANNEL,
Params: []string{dc.nick, name, "Cannot interact with channels and users on the bouncer connection. Did you mean to use a specific network?"},
}}
}
var net *network
if i := strings.LastIndexByte(name, '/'); i >= 0 {
@ -448,7 +454,7 @@ func (dc *downstreamConn) unmarshalEntityNetwork(name string) (*network, string,
if net == nil {
return nil, "", ircError{&irc.Message{
Command: irc.ERR_NOSUCHCHANNEL,
Params: []string{name, "Missing network suffix in name"},
Params: []string{dc.nick, name, "Missing network suffix in name"},
}}
}
@ -466,7 +472,7 @@ func (dc *downstreamConn) unmarshalEntity(name string) (*upstreamConn, string, e
if net.conn == nil {
return nil, "", ircError{&irc.Message{
Command: irc.ERR_NOSUCHCHANNEL,
Params: []string{name, "Disconnected from upstream network"},
Params: []string{dc.nick, name, "Disconnected from upstream network"},
}}
}