diff options
author | Wim <wim@42.be> | 2016-11-13 23:06:37 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2016-11-13 23:06:37 +0100 |
commit | 99d130d1ed4c389a76d4fe7f5ea8fccb78bad444 (patch) | |
tree | 8799742a6713d28050f5af14ba8d2b1d62cd766a /bridge/gitter | |
parent | 14830d9f1c4e9435ee7a15e0839876ad1f4d1a9f (diff) | |
download | matterbridge-msglm-99d130d1ed4c389a76d4fe7f5ea8fccb78bad444.tar.gz matterbridge-msglm-99d130d1ed4c389a76d4fe7f5ea8fccb78bad444.tar.bz2 matterbridge-msglm-99d130d1ed4c389a76d4fe7f5ea8fccb78bad444.zip |
Refactor
Diffstat (limited to 'bridge/gitter')
-rw-r--r-- | bridge/gitter/gitter.go | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/bridge/gitter/gitter.go b/bridge/gitter/gitter.go index 176b6cef..95375b1f 100644 --- a/bridge/gitter/gitter.go +++ b/bridge/gitter/gitter.go @@ -8,13 +8,12 @@ import ( ) type Bgitter struct { - c *gitter.Gitter - Config *config.Protocol - Remote chan config.Message - protocol string - origin string - Users []gitter.User - Rooms []gitter.Room + c *gitter.Gitter + Config *config.Protocol + Remote chan config.Message + Account string + Users []gitter.User + Rooms []gitter.Room } var flog *log.Entry @@ -24,12 +23,11 @@ func init() { flog = log.WithFields(log.Fields{"module": protocol}) } -func New(cfg config.Protocol, origin string, c chan config.Message) *Bgitter { +func New(cfg config.Protocol, account string, c chan config.Message) *Bgitter { b := &Bgitter{} b.Config = &cfg b.Remote = c - b.protocol = protocol - b.origin = origin + b.Account = account return b } @@ -47,10 +45,6 @@ func (b *Bgitter) Connect() error { return nil } -func (b *Bgitter) FullOrigin() string { - return b.protocol + "." + b.origin -} - func (b *Bgitter) JoinChannel(channel string) error { room := channel roomID := b.getRoomID(room) @@ -77,9 +71,9 @@ func (b *Bgitter) JoinChannel(channel string) error { case *gitter.MessageReceived: // check for ZWSP to see if it's not an echo if !strings.HasSuffix(ev.Message.Text, "") { - flog.Debugf("Sending message from %s on %s to gateway", ev.Message.From.Username, b.FullOrigin()) + flog.Debugf("Sending message from %s on %s to gateway", ev.Message.From.Username, b.Account) b.Remote <- config.Message{Username: ev.Message.From.Username, Text: ev.Message.Text, Channel: room, - Origin: b.origin, Protocol: b.protocol, FullOrigin: b.FullOrigin(), Avatar: b.getAvatar(ev.Message.From.Username)} + Account: b.Account, Avatar: b.getAvatar(ev.Message.From.Username)} } case *gitter.GitterConnectionClosed: flog.Errorf("connection with gitter closed for room %s", room) @@ -89,18 +83,6 @@ func (b *Bgitter) JoinChannel(channel string) error { return nil } -func (b *Bgitter) Name() string { - return b.protocol + "." + b.origin -} - -func (b *Bgitter) Protocol() string { - return b.protocol -} - -func (b *Bgitter) Origin() string { - return b.origin -} - func (b *Bgitter) Send(msg config.Message) error { flog.Debugf("Receiving %#v", msg) roomID := b.getRoomID(msg.Channel) @@ -108,9 +90,8 @@ func (b *Bgitter) Send(msg config.Message) error { flog.Errorf("Could not find roomID for %v", msg.Channel) return nil } - nick := config.GetNick(&msg, b.Config) // add ZWSP because gitter echoes our own messages - return b.c.SendMessage(roomID, nick+msg.Text+" ") + return b.c.SendMessage(roomID, msg.Username+msg.Text+" ") } func (b *Bgitter) getRoomID(channel string) string { |