diff options
author | Wim <wim@42.be> | 2016-11-13 23:09:06 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2016-11-13 23:09:06 +0100 |
commit | 497633867759601d658233257447b5b86aa1b01e (patch) | |
tree | bc732d5333ddcd0343e1c2d7fd0a025c23822196 /bridge/gitter/gitter.go | |
parent | 4fb0544b0e25bf6409811fc3e574bf45efea369d (diff) | |
parent | 99d130d1ed4c389a76d4fe7f5ea8fccb78bad444 (diff) | |
download | matterbridge-msglm-497633867759601d658233257447b5b86aa1b01e.tar.gz matterbridge-msglm-497633867759601d658233257447b5b86aa1b01e.tar.bz2 matterbridge-msglm-497633867759601d658233257447b5b86aa1b01e.zip |
Merge branch 'refactor'
Diffstat (limited to 'bridge/gitter/gitter.go')
-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 { |