mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
fix(irc): on connect join logic error (#353)
This commit is contained in:
parent
2a3a839081
commit
aa94962dfd
1 changed files with 23 additions and 17 deletions
|
@ -345,6 +345,20 @@ func (h *Handler) onConnect(m ircmsg.Message) {
|
||||||
// if authenticated and no invite command lets join
|
// if authenticated and no invite command lets join
|
||||||
h.JoinChannels()
|
h.JoinChannels()
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// if not authenticated, no nickserv pass but invite command, send invite command to trigger MODE change then join
|
||||||
|
if h.network.NickServ.Password == "" && h.network.InviteCommand != "" {
|
||||||
|
h.log.Trace().Msg("on connect invite command not empty: send connect commands")
|
||||||
|
if err := h.sendConnectCommands(h.network.InviteCommand); err != nil {
|
||||||
|
h.log.Error().Stack().Err(err).Msgf("error sending connect command %v", h.network.InviteCommand)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
// if not authenticated but we do have a nick serv pass, send identify to trigger MODE change and then join
|
||||||
} else if h.network.NickServ.Password != "" {
|
} else if h.network.NickServ.Password != "" {
|
||||||
h.log.Trace().Msg("on connect not authenticated and password not empty: send nickserv identify")
|
h.log.Trace().Msg("on connect not authenticated and password not empty: send nickserv identify")
|
||||||
if err := h.NickServIdentify(h.network.NickServ.Password); err != nil {
|
if err := h.NickServIdentify(h.network.NickServ.Password); err != nil {
|
||||||
|
@ -354,21 +368,13 @@ func (h *Handler) onConnect(m ircmsg.Message) {
|
||||||
|
|
||||||
// return and wait for NOTICE of nickserv auth
|
// return and wait for NOTICE of nickserv auth
|
||||||
return
|
return
|
||||||
|
|
||||||
} else if h.network.InviteCommand != "" {
|
|
||||||
h.log.Trace().Msg("on connect invite command not empty: send connect commands")
|
|
||||||
if err := h.sendConnectCommands(h.network.InviteCommand); err != nil {
|
|
||||||
h.log.Error().Stack().Err(err).Msgf("error sending connect command %v", h.network.InviteCommand)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// join channels if no password or no invite command
|
|
||||||
h.log.Trace().Msg("on connect - no nickserv or invite command: join channels")
|
|
||||||
h.JoinChannels()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if no password nor invite command, join channels
|
||||||
|
h.log.Trace().Msg("on connect - no nickserv or invite command: join channels")
|
||||||
|
h.JoinChannels()
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) onDisconnect(m ircmsg.Message) {
|
func (h *Handler) onDisconnect(m ircmsg.Message) {
|
||||||
|
@ -764,7 +770,9 @@ func (h *Handler) handleMode(msg ircmsg.Message) {
|
||||||
|
|
||||||
// if our nick and user mode +r (Identifies the nick as being Registered (settable by services only)) then return
|
// if our nick and user mode +r (Identifies the nick as being Registered (settable by services only)) then return
|
||||||
if h.isOurCurrentNick(msg.Params[0]) && strings.Contains(msg.Params[1], "+r") {
|
if h.isOurCurrentNick(msg.Params[0]) && strings.Contains(msg.Params[1], "+r") {
|
||||||
h.setAuthenticated()
|
if !h.authenticated {
|
||||||
|
h.setAuthenticated()
|
||||||
|
}
|
||||||
|
|
||||||
h.resetConnectErrors()
|
h.resetConnectErrors()
|
||||||
h.failedNickServAttempts = 0
|
h.failedNickServAttempts = 0
|
||||||
|
@ -776,8 +784,6 @@ func (h *Handler) handleMode(msg ircmsg.Message) {
|
||||||
h.log.Error().Stack().Err(err).Msgf("error sending connect command %v", h.network.InviteCommand)
|
h.log.Error().Stack().Err(err).Msgf("error sending connect command %v", h.network.InviteCommand)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue