summaryrefslogtreecommitdiffstats
path: root/bridge/mattermost
diff options
context:
space:
mode:
authorWim <wim@42.be>2016-11-13 23:06:37 +0100
committerWim <wim@42.be>2016-11-13 23:06:37 +0100
commit99d130d1ed4c389a76d4fe7f5ea8fccb78bad444 (patch)
tree8799742a6713d28050f5af14ba8d2b1d62cd766a /bridge/mattermost
parent14830d9f1c4e9435ee7a15e0839876ad1f4d1a9f (diff)
downloadmatterbridge-msglm-99d130d1ed4c389a76d4fe7f5ea8fccb78bad444.tar.gz
matterbridge-msglm-99d130d1ed4c389a76d4fe7f5ea8fccb78bad444.tar.bz2
matterbridge-msglm-99d130d1ed4c389a76d4fe7f5ea8fccb78bad444.zip
Refactor
Diffstat (limited to 'bridge/mattermost')
-rw-r--r--bridge/mattermost/mattermost.go39
1 files changed, 10 insertions, 29 deletions
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go
index 7f7340b6..51d8f208 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}
}
}