From d74cf45debc3a7fc727951730000ed4637af2c39 Mon Sep 17 00:00:00 2001 From: llmII Date: Fri, 5 Mar 2021 09:09:59 -0600 Subject: [PATCH] Cleanup: remove max_nick_length 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. --- README.md | 1 - bridge/bridge.go | 3 --- bridge/irc_manager.go | 2 +- config.yml | 1 - main.go | 5 ----- 5 files changed, 1 insertion(+), 11 deletions(-) diff --git a/README.md b/README.md index b971a19..40f01bf 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,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 `, 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) | diff --git a/bridge/bridge.go b/bridge/bridge.go index de65e2e..3b01188 100644 --- a/bridge/bridge.go +++ b/bridge/bridge.go @@ -65,9 +65,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 } diff --git a/bridge/irc_manager.go b/bridge/irc_manager.go index d948565..0faeee9 100644 --- a/bridge/irc_manager.go +++ b/bridge/irc_manager.go @@ -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, diff --git a/config.yml b/config.yml index c7de9fa..2fd5e55 100644 --- a/config.yml +++ b/config.yml @@ -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 diff --git a/main.go b/main.go index 58bda4e..095be34 100644 --- a/main.go +++ b/main.go @@ -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" ) @@ -115,9 +114,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") @@ -164,7 +160,6 @@ func main() { ChannelMappings: channelMappings, CooldownDuration: time.Second * time.Duration(cooldownDuration), ShowJoinQuit: showJoinQuit, - MaxNickLength: maxNickLength, Debug: *debugMode, DebugPresence: *debugPresence,