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/mattermost | |
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/mattermost')
-rw-r--r-- | bridge/mattermost/mattermost.go | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 8328f0b0..c365784c 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -26,12 +26,11 @@ type MMMessage struct { type Bmattermost struct { MMhook MMapi - Config *config.Protocol - Remote chan config.Message - name string - origin string - protocol string - TeamId string + Config *config.Protocol + Remote chan config.Message + name string + TeamId string + Account string } var flog *log.Entry @@ -41,13 +40,11 @@ func init() { flog = log.WithFields(log.Fields{"module": protocol}) } -func New(cfg config.Protocol, origin string, c chan config.Message) *Bmattermost { +func New(cfg config.Protocol, account string, c chan config.Message) *Bmattermost { b := &Bmattermost{} b.Config = &cfg - b.origin = origin b.Remote = c - b.protocol = "mattermost" - b.name = cfg.Name + b.Account = account b.mmMap = make(map[string]string) return b } @@ -80,10 +77,6 @@ func (b *Bmattermost) Connect() error { return nil } -func (b *Bmattermost) FullOrigin() string { - return b.protocol + "." + b.origin -} - func (b *Bmattermost) JoinChannel(channel string) error { // we can only join channels using the API if b.Config.UseAPI { @@ -92,21 +85,9 @@ func (b *Bmattermost) JoinChannel(channel string) error { return nil } -func (b *Bmattermost) Name() string { - return b.protocol + "." + b.origin -} - -func (b *Bmattermost) Origin() string { - return b.origin -} - -func (b *Bmattermost) Protocol() string { - return b.protocol -} - func (b *Bmattermost) Send(msg config.Message) error { flog.Debugf("Receiving %#v", msg) - nick := config.GetNick(&msg, b.Config) + nick := msg.Username message := msg.Text channel := msg.Channel @@ -144,8 +125,8 @@ func (b *Bmattermost) handleMatter() { go b.handleMatterHook(mchan) } for message := range mchan { - flog.Debugf("Sending message from %s on %s to gateway", message.Username, b.FullOrigin()) - b.Remote <- config.Message{Text: message.Text, Username: message.Username, Channel: message.Channel, Origin: b.origin, Protocol: b.protocol, FullOrigin: b.FullOrigin()} + flog.Debugf("Sending message from %s on %s to gateway", message.Username, b.Account) + b.Remote <- config.Message{Text: message.Text, Username: message.Username, Channel: message.Channel, Account: b.Account} } } |