diff options
author | Wim <wim@42.be> | 2016-11-06 00:46:32 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2016-11-06 00:46:32 +0100 |
commit | a3dd0f1345fae3d7828ed0c82d6a7c4b610d0983 (patch) | |
tree | 7db0a8d15e4390b9c2bb0581cad8d2e551a29b23 /bridge/gitter | |
parent | 37873acfcd328e7c9eaf2e69148de05b8d00a428 (diff) | |
download | matterbridge-msglm-a3dd0f1345fae3d7828ed0c82d6a7c4b610d0983.tar.gz matterbridge-msglm-a3dd0f1345fae3d7828ed0c82d6a7c4b610d0983.tar.bz2 matterbridge-msglm-a3dd0f1345fae3d7828ed0c82d6a7c4b610d0983.zip |
Add support for using avatars from discord,slack and gitter in slack
Diffstat (limited to 'bridge/gitter')
-rw-r--r-- | bridge/gitter/gitter.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/bridge/gitter/gitter.go b/bridge/gitter/gitter.go index 5daf7773..176b6cef 100644 --- a/bridge/gitter/gitter.go +++ b/bridge/gitter/gitter.go @@ -13,6 +13,7 @@ type Bgitter struct { Remote chan config.Message protocol string origin string + Users []gitter.User Rooms []gitter.Room } @@ -64,6 +65,8 @@ func (b *Bgitter) JoinChannel(channel string) error { if err != nil { return err } + users, _ := b.c.GetUsersInRoom(roomID) + b.Users = append(b.Users, users...) stream := b.c.Stream(roomID) go b.c.Listen(stream) @@ -76,7 +79,7 @@ func (b *Bgitter) JoinChannel(channel string) error { if !strings.HasSuffix(ev.Message.Text, "") { flog.Debugf("Sending message from %s on %s to gateway", ev.Message.From.Username, b.FullOrigin()) b.Remote <- config.Message{Username: ev.Message.From.Username, Text: ev.Message.Text, Channel: room, - Origin: b.origin, Protocol: b.protocol, FullOrigin: b.FullOrigin()} + Origin: b.origin, Protocol: b.protocol, FullOrigin: b.FullOrigin(), Avatar: b.getAvatar(ev.Message.From.Username)} } case *gitter.GitterConnectionClosed: flog.Errorf("connection with gitter closed for room %s", room) @@ -118,3 +121,15 @@ func (b *Bgitter) getRoomID(channel string) string { } return "" } + +func (b *Bgitter) getAvatar(user string) string { + var avatar string + if b.Users != nil { + for _, u := range b.Users { + if user == u.Username { + return u.AvatarURLSmall + } + } + } + return avatar +} |