Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit 7b0267bd3138233b7d84d79f9aeca50ac8c48cdf Author: Iris Morelle <shadowm@wesnoth.org> Date: Sat Oct 16 18:59:39 2021 +0000 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 <wim@42.be> diff --git a/bridge/config/config.go b/bridge/config/config.go index a6e3c54..7b7c2f2 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -1386 +1387 @@ 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 @@ -1696 +1707 @@ 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 e54f803..ac8222c 100644 --- a/bridge/irc/irc.go +++ b/bridge/irc/irc.go @@ -2718 +27111 @@ 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" @@ -2806 +28310 @@ 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 { @@ -2997 +3067 @@ 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 b622175..f41b260 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -556 +5514 @@ 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  #