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.57k stars 616 forks source link

Fun with generated avatars #1577

Open Lantizia opened 3 years ago

Lantizia commented 3 years ago

Hi,

Little side note

I've found that IconURL= can be placed in [general] and it'll work across multiple networks. This doesn't seem to be documented, instead IconURL= only appears in the sample config file under [slack] and [mattermost] sections, so might be worth tweaking?

[general]
IconURL="https://robohash.org/{NICK}.png?size=48x48"

In my testing of this I've found it worked just as I'd hoped... our Discord users' avatars still appearing on Slack... and our Slack users' avatars still appearing on Discord... but messages from networks/users that doesn't support/have an avatar (like IRC) get the same generated avatar appearring on both Discord and Slack. I just wanted to check IconURL= didn't override avatars that already existed.

Actual feature request...

It'd seem that the Gravatar service... doesn't just serve up Gravatars. When looking at their API docs, it explains they do 5 different kinds of generated avatar too...

Selection_478 From left to right... identicon, monsterid, wavatar, retro and robohash (seemingly the same as robohash.org).

Although I much more prefer the idea of self-hosted "Pavatars"... the Gravatar service is used on a massive scale by various big websites (including Slack) as well as millions of WordPress sites... so it's likely reliable enough for most people to rely on.

However it requires giving it an MD5 hash to function properly. They suggest here some steps for making this MD5 from a users e-mail address... which I've slightly modified below...

If {NICK} was an e-mail address (I'm unaware of any supported matterbridge network where this'd be true) then... assuming that e-mail address has a Gravatar account... it'd retrieve their chosen Gravatar, which is a nice side effect. But otherwise, and in most cases, it'll hand out a generated avatar... in the style you've chosen.

So it'd look like this...

[general]
IconURL="https://www.gravatar.com/avatar/{MD5NICK}.png&s=48?d=identicon"

I've only gone with a size of 48x48 (with s=48) as that's what the sample config file says to use for Slack (you can always leave the size option off... or use another size).

Just an idea :)

minecraftchest1 commented 2 years ago

This could also be used with libravatar.