mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
feat(irc): allow lazy announcer nicks (#1322)
* feat(irc): allow lazy announcer nicks * fix web * fix: indents * fix: add missing entries * feat: extend announcer validation with digit suffix support this reverts the previous commits * feat(irc): allow lazy announcer match * fix(irc): imports --------- Co-authored-by: ze0s <43699394+zze0s@users.noreply.github.com>
This commit is contained in:
parent
46b3ae8a0f
commit
f48b103a52
1 changed files with 19 additions and 3 deletions
|
@ -6,7 +6,6 @@ package irc
|
|||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"golang.org/x/net/proxy"
|
||||
"net/url"
|
||||
"slices"
|
||||
"strings"
|
||||
|
@ -26,6 +25,7 @@ import (
|
|||
"github.com/r3labs/sse/v2"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/sasha-s/go-deadlock"
|
||||
"golang.org/x/net/proxy"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -1019,8 +1019,24 @@ func (h *Handler) isValidAnnouncer(nick string) bool {
|
|||
h.m.RLock()
|
||||
defer h.m.RUnlock()
|
||||
|
||||
_, ok := h.validAnnouncers[strings.ToLower(nick)]
|
||||
return ok
|
||||
nick = strings.ToLower(nick)
|
||||
for announcer := range h.validAnnouncers {
|
||||
if nick == announcer {
|
||||
return true
|
||||
}
|
||||
|
||||
// Confirm if the nickname starts with the announcer and comprises one additional character
|
||||
if strings.HasPrefix(nick, announcer) && len(nick) == len(announcer)+1 {
|
||||
return true
|
||||
}
|
||||
|
||||
// Verify if the nickname concludes with an asterisk and holds the correct prefix
|
||||
if strings.HasSuffix(announcer, "*") && strings.HasPrefix(nick, announcer) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// check if channel is one from the list in the definition
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue