From 61bab22dde8e3abd2e1cbeb57d1f7a8d28ef95f8 Mon Sep 17 00:00:00 2001 From: Iris Morelle Date: Sat, 16 Oct 2021 18:59:39 -0300 Subject: Add UserName and RealName options for IRC (#1590) This allows setting custom values for the IRC username/ident and real name (gecos) fields at server registration time with gIRC. Co-authored-by: Wim --- bridge/config/config.go | 2 ++ bridge/irc/irc.go | 11 +++++++++-- matterbridge.toml.sample | 8 ++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/bridge/config/config.go b/bridge/config/config.go index a6e3c546..7b7c2f2e 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -138,6 +138,7 @@ type Protocol struct { QuoteDisable bool // telegram QuoteFormat string // telegram QuoteLengthLimit int // telegram + RealName string // IRC RejoinDelay int // IRC ReplaceMessages [][]string // all protocols ReplaceNicks [][]string // all protocols @@ -169,6 +170,7 @@ type Protocol struct { UseFirstName bool // telegram UseUserName bool // discord, matrix UseInsecureURL bool // telegram + UserName string // IRC VerboseJoinPart bool // IRC WebhookBindAddress string // mattermost, slack WebhookURL string // mattermost, slack diff --git a/bridge/irc/irc.go b/bridge/irc/irc.go index e54f8030..ac8222c6 100644 --- a/bridge/irc/irc.go +++ b/bridge/irc/irc.go @@ -271,8 +271,11 @@ func (b *Birc) getClient() (*girc.Client, error) { if err != nil { return nil, err } + user := b.GetString("UserName") + if user == "" { + user = b.GetString("Nick") + } // fix strict user handling of girc - user := b.GetString("Nick") for !girc.IsValidUser(user) { if len(user) == 1 || len(user) == 0 { user = "matterbridge" @@ -280,6 +283,10 @@ func (b *Birc) getClient() (*girc.Client, error) { } user = user[1:] } + realName := b.GetString("RealName") + if realName == "" { + realName = b.GetString("Nick") + } debug := ioutil.Discard if b.GetInt("DebugLevel") == 2 { @@ -299,7 +306,7 @@ func (b *Birc) getClient() (*girc.Client, error) { Port: port, Nick: b.GetString("Nick"), User: user, - Name: b.GetString("Nick"), + Name: realName, SSL: b.GetBool("UseTLS"), TLSConfig: &tls.Config{InsecureSkipVerify: b.GetBool("SkipTLSVerify"), ServerName: server}, //nolint:gosec PingDelay: pingDelay, diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index b6221757..f41b260d 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -55,6 +55,14 @@ Charset="" #REQUIRED Nick="matterbot" +#Real name/gecos displayed in e.g. /WHOIS and /WHO +#OPTIONAL (defaults to the nick) +RealName="Matterbridge instance on IRC" + +#IRC username/ident preceding the hostname in hostmasks and /WHOIS +#OPTIONAL (defaults to the nick) +UserName="bridge" + #If you registered your bot with a service like Nickserv on libera. #Also being used when UseSASL=true # -- cgit v1.2.3