From a3dd0f1345fae3d7828ed0c82d6a7c4b610d0983 Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 6 Nov 2016 00:46:32 +0100 Subject: Add support for using avatars from discord,slack and gitter in slack --- bridge/gitter/gitter.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'bridge/gitter') 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 +} -- cgit v1.2.3