Thumbnail

rani/matterbridge.git

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

commit c9903cdec9cde74a5c6c6ad12c4a705a4139e91b Author: Gary Kim <gary@garykim.dev> Date: Thu Oct 01 16:59:35 2020 +0000 Append a suffix if user is a guest user (nctalk) (#1250) Signed-off-by: Gary Kim <gary@garykim.dev> diff --git a/bridge/nctalk/nctalk.go b/bridge/nctalk/nctalk.go index 94bb1a0..23b5913 100644 --- a/bridge/nctalk/nctalk.go +++ b/bridge/nctalk/nctalk.go @@ -706 +7013 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error {   return err   }   b.rooms = append(b.rooms, newRoom) + + // Config + guestSuffix := " (Guest)" + if b.IsKeySet("GuestSuffix") { + guestSuffix = b.GetString("GuestSuffix") + } +   go func() {   for msg := range c {   // ignore messages that are one of the following @@ -817 +887 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error {   remoteMessage := config.Message{   Text: formatRichObjectString(msg.Message, msg.MessageParameters),   Channel: newRoom.room.Token, - Username: msg.ActorDisplayName, + Username: DisplayName(msg, guestSuffix),   UserID: msg.ActorID,   Account: b.Account,   } @@ -1443 +15115 @@ func formatRichObjectString(message string, parameters map[string]ocs.RichObject     return message  } + +func DisplayName(msg ocs.TalkRoomMessageData, suffix string) string { + if msg.ActorType == ocs.ActorGuest { + if msg.ActorDisplayName == "" { + return "Guest" + } + + return msg.ActorDisplayName + suffix + } + + return msg.ActorDisplayName +} diff --git a/go.mod b/go.mod index bf5513a..8b72aa8 100644 --- a/go.mod +++ b/go.mod @@ -507 +507 @@ require (   github.com/zfjagann/golang-ring v0.0.0-20190304061218-d34796e0a6c2   golang.org/x/image v0.0.0-20200801110659-972c09e46d76   golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 - gomod.garykim.dev/nc-talk v0.1.3 + gomod.garykim.dev/nc-talk v0.1.4   gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376   layeh.com/gumble v0.0.0-20200818122324-146f9205029b  ) diff --git a/go.sum b/go.sum index bda19a2..bb00f75 100644 --- a/go.sum +++ b/go.sum @@ -9936 +9938 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1N  golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=  gomod.garykim.dev/nc-talk v0.1.3 h1:u4TPUR5++xjNTHoiO82/E8xhGFpCbwwfcY/yUv3Rp60=  gomod.garykim.dev/nc-talk v0.1.3/go.mod h1:zKg8yxCk2KaTy6aPDEfRac0Jik72czX+nRsG8CZuhtc= +gomod.garykim.dev/nc-talk v0.1.4 h1:U9viudEgq/biocorgWvZRVR+27IPEczYl/yszSvzN+8= +gomod.garykim.dev/nc-talk v0.1.4/go.mod h1:zKg8yxCk2KaTy6aPDEfRac0Jik72czX+nRsG8CZuhtc=  google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=  google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=  google.golang.org/api v0.0.0-20181220000619-583d854617af/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= diff --git a/matterbridge.toml.sample b/matterbridge.toml.sample index c9263e7..c82b33c 100644 --- a/matterbridge.toml.sample +++ b/matterbridge.toml.sample @@ -14056 +14059 @@ Login = "talkuser"  # Password of the bot  Password = "talkuserpass"   +# Suffix for Guest Users +GuestSuffix = " (Guest)" +  ###################################################################  #  # Mumble