Skip to content

Commit

Permalink
Cleanup: remove max_nick_length
Browse files Browse the repository at this point in the history
This setting is no longer needed as the information can be gained via
the listener at runtime. This changes things to use go-ircevent's
ISUPPORT support instead of defining it in the config.

Closes #106.
  • Loading branch information
llmII committed Mar 5, 2021
1 parent 0426fb7 commit e58253f
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 11 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ The config file is a yaml formatted file with the following fields:
| `nickserv_identify` | No | | Yes | on connect this message will be sent: `PRIVMSG nickserv IDENTIFY <value>`, you can provide both a username and password if your ircd supports it |
| `cooldown_duration` | No | 86400 (24 hours) | Yes | time in seconds for a discord user to be offline before it's puppet disconnects from irc |
| `show_joinquit` | No | false | yes | displays JOIN, PART, QUIT, KICK on discord |
| `max_nick_length` | No | 30 | yes | Maximum allowed nick length |
| `ignored_irc_hostmasks` | No | | Yes | A list of IRC users identified by hostmask to not relay to Discord, uses matching syntax as in [glob](https://github.com/gobwas/glob) |
| `connection_limit` | Yes | 0 | Yes | How many connections to IRC (including our listener) to spawn (limit of 0 or less means unlimited) |

Expand Down
3 changes: 0 additions & 3 deletions bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ type Config struct {
// ShowJoinQuit determines whether or not to show JOIN, QUIT, KICK messages on Discord
ShowJoinQuit bool

// Maximum Nicklength for irc server
MaxNickLength int

Debug bool
DebugPresence bool
}
Expand Down
2 changes: 1 addition & 1 deletion bridge/irc_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func (m *IRCManager) generateNickname(discord DiscordUser) string {
suffix := m.bridge.Config.Suffix
newNick := nick + suffix

useFallback := len(newNick) > m.bridge.Config.MaxNickLength || m.bridge.ircListener.DoesUserExist(newNick)
useFallback := len(newNick) > int(m.bridge.ircListener.NickLength()) || m.bridge.ircListener.DoesUserExist(newNick)
// log.WithFields(log.Fields{
// "length": len(newNick) > ircnick.MAXLENGTH,
// "useFallback": useFallback,
Expand Down
1 change: 0 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ webirc_pass: abcdef.ghijk.lmnop

show_joinquit: false # displays JOIN, PART, QUIT, KICK on discord
cooldown_duration: 86400 # optional, default 86400 (24 hours), time in seconds for a discord user to be offline before it's puppet disconnects from irc
max_nick_length: 30 # Maximum Length of a nick allowed

# You definitely should restart the bridge after changing the following:
insecure: true
Expand Down
5 changes: 0 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/gobwas/glob"
"github.com/pkg/errors"
"github.com/qaisjp/go-discord-irc/bridge"
ircnick "github.com/qaisjp/go-discord-irc/irc/nick"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -117,9 +116,6 @@ func main() {
//
viper.SetDefault("show_joinquit", false)
showJoinQuit := viper.GetBool("show_joinquit")
// Maximum length of user nicks aloud
viper.SetDefault("max_nick_length", ircnick.MAXLENGTH)
maxNickLength := viper.GetInt("max_nick_length")

if webIRCPass == "" {
log.Warnln("webirc_pass is empty")
Expand Down Expand Up @@ -167,7 +163,6 @@ func main() {
WebhookPrefix: webhookPrefix,
CooldownDuration: time.Second * time.Duration(cooldownDuration),
ShowJoinQuit: showJoinQuit,
MaxNickLength: maxNickLength,

Debug: *debugMode,
DebugPresence: *debugPresence,
Expand Down

0 comments on commit e58253f

Please sign in to comment.