42wim / matterbridge

bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API (mattermost not required!)
Apache License 2.0
6.66k stars 619 forks source link

{NICK} Uses Rocket.Chat Username, Not Nickname #631

Open jamoffat opened 5 years ago

jamoffat commented 5 years ago

Describe the bug When bridging a Rocket.Chat room, the user's Rocket.Chat username is displayed on other Discord rather than their nickname. This works fine in reverse, i.e., Discord nickname is properly displayed on Rocket.Chat, however.

To Reproduce Bridge Rocket.Chat with Discord, change your nickname on Discord to be different from your username. Post messages from Rocket.Chat to Discord, observe behaviour. Notice behaviour of the inverse case.

Expected behavior Bridge should use the nickname for the {NICK} formatting option, rather than the username.

Screenshots/debug logs Rocket.Chat: image

Discord: image

Environment (please complete the following information):

Additional context

[discord.redacted] Token="redacted" Server="redacted"

ShowEmbeds=false UseUserName=false EditDisable=false EditSuffix=" (edited)" Label="" RemoteNickFormat="<{NICK}> " ShowJoinPart=false StripNick=false ShowTopicChange=false

[rocketchat.redacted] WebhookURL="http://rocketchat:3000/hooks/redacted/redacted" WebhookBindAddress="0.0.0.0:9999" Nick="rocket.cat" NoTLS=true SkipTLSVerify=false PrefixMessagesWithNick=true Label="" RemoteNickFormat="<{NICK}> " ShowJoinPart=false StripNick=false ShowTopicChange=false

[general] RemoteNickFormat="<{NICK}> "

[[gateway]] name="gateway1" enable=true

[[gateway.inout]]
account="discord.redacted"
channel="testing"

    [gateway.inout.options]
    webhookurl="https://discordapp.com/api/webhooks/redacted/redacted"

[[gateway.inout]]
account="rocketchat.redacted"
channel="#testing"
patcon commented 5 years ago

Thanks @jamoffat! So you're saying that you would prefer instead of rocketchat "username" to be relayed, you would like "name" (sometimes called "Real Name" in UI, it seems). Re: https://rocket.chat/docs/developer-guides/rest-api/users/info/#example-result-regular-user-callee

This seems to be what you'd need to change, if others think this change makes sense: https://github.com/42wim/matterbridge/blob/e538a4d30459e9da1a021400b5de85894b4efabc/bridge/rocketchat/rocketchat.go#L81-L92

Also, https://github.com/42wim/matterbridge/issues/614 might let you set this as you please to any value on user object.

jamoffat commented 5 years ago

Thanks @jamoffat!

No problem @patcon! I spent ages tinkering with various settings and scouring the repo before asking, but discovered myself diving down a few too many "rabbit holes" so thought it might be quicker to ask on here. 😄

So you're saying that you would prefer instead of rocketchat "username" to be relayed, you would like "name" (sometimes called "Real Name" in UI, it seems). Re: https://rocket.chat/docs/developer-guides/rest-api/users/info/#example-result-regular-user-callee

Bingo, it is given as "Name" in the Rocket.Chat UI as shown below (via User -> My Account -> Profile): image

And as you've correctly pointed out, it is also referred to as "Real Name" elsewhere within Rocket.Chat sometimes: image

So I think it is indeed "name" rather than "username" that I want relayed here.

This seems to be what you'd need to change, if others think this change makes sense: https://github.com/42wim/matterbridge/blob/e538a4d30459e9da1a021400b5de85894b4efabc/bridge/rocketchat/rocketchat.go#L81-L92

I had wondered about this function specifically and whether it was the key to solving this. I'll run a few tests and see what I can come up with! Thanks for your help! 😀

patcon commented 5 years ago

No prob! I can't speak for @42wim and whether this wouod be a mergeable change, but in a pinch I can help you build your own binary, if that's helpful. (Perhaps you're more skilled at golang, but it took me awhile to figure my system out at first!)

Also, does rocketchat notify on both name and username? I suspect that would be the sort of thing that would be a decider :)

jamoffat commented 5 years ago

No prob! I can't speak for @42wim and whether this wouod be a mergeable change, but in a pinch I can help you build your own binary, if that's helpful. (Perhaps you're more skilled at golang, but it took me awhile to figure my system out at first!)

I'm going to throw my hands up here and say I'm at your mercy on this one @patcon! I've put together a development environment which is getting close to where I need it to be, but I have to admit the finer points of actually getting the quoted code above into a workable binary is proving challenging! If you don't mind terribly much I would sincerely appreciate your assistance in producing a binary if this isn't significant enough to be merged! :)

Also, does rocketchat notify on both name and username? I suspect that would be the sort of thing that would be a decider :)

Rocket.chat notifies on username, i.e., "@jamoffat" will notify however "James Moffat" will not. That's not too much of an issue though, it's more important for names to be displayed rather than usernames for our use-case -- I think at this point anyway! :)

Cheers @patcon for all your help! Legend!