mirror of
https://github.com/cwinfo/matterbridge.git
synced 2024-11-26 00:51:36 +00:00
Make gocritic linter happier
This commit is contained in:
parent
59994da176
commit
1e0bb3da95
@ -34,24 +34,25 @@ func (b *Bmattermost) Command(cmd string) string {
|
|||||||
|
|
||||||
func (b *Bmattermost) Connect() error {
|
func (b *Bmattermost) Connect() error {
|
||||||
if b.GetString("WebhookBindAddress") != "" {
|
if b.GetString("WebhookBindAddress") != "" {
|
||||||
if b.GetString("WebhookURL") != "" {
|
switch {
|
||||||
|
case b.GetString("WebhookURL") != "":
|
||||||
b.Log.Info("Connecting using webhookurl (sending) and webhookbindaddress (receiving)")
|
b.Log.Info("Connecting using webhookurl (sending) and webhookbindaddress (receiving)")
|
||||||
b.mh = matterhook.New(b.GetString("WebhookURL"),
|
b.mh = matterhook.New(b.GetString("WebhookURL"),
|
||||||
matterhook.Config{InsecureSkipVerify: b.GetBool("SkipTLSVerify"),
|
matterhook.Config{InsecureSkipVerify: b.GetBool("SkipTLSVerify"),
|
||||||
BindAddress: b.GetString("WebhookBindAddress")})
|
BindAddress: b.GetString("WebhookBindAddress")})
|
||||||
} else if b.GetString("Token") != "" {
|
case b.GetString("Token") != "":
|
||||||
b.Log.Info("Connecting using token (sending)")
|
b.Log.Info("Connecting using token (sending)")
|
||||||
err := b.apiLogin()
|
err := b.apiLogin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if b.GetString("Login") != "" {
|
case b.GetString("Login") != "":
|
||||||
b.Log.Info("Connecting using login/password (sending)")
|
b.Log.Info("Connecting using login/password (sending)")
|
||||||
err := b.apiLogin()
|
err := b.apiLogin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
default:
|
||||||
b.Log.Info("Connecting using webhookbindaddress (receiving)")
|
b.Log.Info("Connecting using webhookbindaddress (receiving)")
|
||||||
b.mh = matterhook.New(b.GetString("WebhookURL"),
|
b.mh = matterhook.New(b.GetString("WebhookURL"),
|
||||||
matterhook.Config{InsecureSkipVerify: b.GetBool("SkipTLSVerify"),
|
matterhook.Config{InsecureSkipVerify: b.GetBool("SkipTLSVerify"),
|
||||||
@ -60,7 +61,8 @@ func (b *Bmattermost) Connect() error {
|
|||||||
go b.handleMatter()
|
go b.handleMatter()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if b.GetString("WebhookURL") != "" {
|
switch {
|
||||||
|
case b.GetString("WebhookURL") != "":
|
||||||
b.Log.Info("Connecting using webhookurl (sending)")
|
b.Log.Info("Connecting using webhookurl (sending)")
|
||||||
b.mh = matterhook.New(b.GetString("WebhookURL"),
|
b.mh = matterhook.New(b.GetString("WebhookURL"),
|
||||||
matterhook.Config{InsecureSkipVerify: b.GetBool("SkipTLSVerify"),
|
matterhook.Config{InsecureSkipVerify: b.GetBool("SkipTLSVerify"),
|
||||||
@ -81,14 +83,14 @@ func (b *Bmattermost) Connect() error {
|
|||||||
go b.handleMatter()
|
go b.handleMatter()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
} else if b.GetString("Token") != "" {
|
case b.GetString("Token") != "":
|
||||||
b.Log.Info("Connecting using token (sending and receiving)")
|
b.Log.Info("Connecting using token (sending and receiving)")
|
||||||
err := b.apiLogin()
|
err := b.apiLogin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
go b.handleMatter()
|
go b.handleMatter()
|
||||||
} else if b.GetString("Login") != "" {
|
case b.GetString("Login") != "":
|
||||||
b.Log.Info("Connecting using login/password (sending and receiving)")
|
b.Log.Info("Connecting using login/password (sending and receiving)")
|
||||||
err := b.apiLogin()
|
err := b.apiLogin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -205,11 +205,12 @@ func (b *Bslack) populateMessageWithUserInfo(ev *slack.MessageEvent, rmsg *confi
|
|||||||
|
|
||||||
// Second, deal with "real" users if we have the necessary information.
|
// Second, deal with "real" users if we have the necessary information.
|
||||||
var userID string
|
var userID string
|
||||||
if ev.User != "" {
|
switch {
|
||||||
|
case ev.User != "":
|
||||||
userID = ev.User
|
userID = ev.User
|
||||||
} else if ev.SubMessage != nil && ev.SubMessage.User != "" {
|
case ev.SubMessage != nil && ev.SubMessage.User != "":
|
||||||
userID = ev.SubMessage.User
|
userID = ev.SubMessage.User
|
||||||
} else {
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,13 +98,14 @@ func (b *Bslack) Connect() error {
|
|||||||
b.RLock()
|
b.RLock()
|
||||||
defer b.RUnlock()
|
defer b.RUnlock()
|
||||||
if b.GetString(incomingWebhookConfig) != "" {
|
if b.GetString(incomingWebhookConfig) != "" {
|
||||||
if b.GetString(outgoingWebhookConfig) != "" {
|
switch {
|
||||||
|
case b.GetString(outgoingWebhookConfig) != "":
|
||||||
b.Log.Info("Connecting using webhookurl (sending) and webhookbindaddress (receiving)")
|
b.Log.Info("Connecting using webhookurl (sending) and webhookbindaddress (receiving)")
|
||||||
b.mh = matterhook.New(b.GetString(outgoingWebhookConfig), matterhook.Config{
|
b.mh = matterhook.New(b.GetString(outgoingWebhookConfig), matterhook.Config{
|
||||||
InsecureSkipVerify: b.GetBool(skipTLSConfig),
|
InsecureSkipVerify: b.GetBool(skipTLSConfig),
|
||||||
BindAddress: b.GetString(incomingWebhookConfig),
|
BindAddress: b.GetString(incomingWebhookConfig),
|
||||||
})
|
})
|
||||||
} else if b.GetString(tokenConfig) != "" {
|
case b.GetString(tokenConfig) != "":
|
||||||
b.Log.Info("Connecting using token (sending)")
|
b.Log.Info("Connecting using token (sending)")
|
||||||
b.sc = slack.New(b.GetString(tokenConfig))
|
b.sc = slack.New(b.GetString(tokenConfig))
|
||||||
b.rtm = b.sc.NewRTM()
|
b.rtm = b.sc.NewRTM()
|
||||||
@ -114,7 +115,7 @@ func (b *Bslack) Connect() error {
|
|||||||
InsecureSkipVerify: b.GetBool(skipTLSConfig),
|
InsecureSkipVerify: b.GetBool(skipTLSConfig),
|
||||||
BindAddress: b.GetString(incomingWebhookConfig),
|
BindAddress: b.GetString(incomingWebhookConfig),
|
||||||
})
|
})
|
||||||
} else {
|
default:
|
||||||
b.Log.Info("Connecting using webhookbindaddress (receiving)")
|
b.Log.Info("Connecting using webhookbindaddress (receiving)")
|
||||||
b.mh = matterhook.New(b.GetString(outgoingWebhookConfig), matterhook.Config{
|
b.mh = matterhook.New(b.GetString(outgoingWebhookConfig), matterhook.Config{
|
||||||
InsecureSkipVerify: b.GetBool(skipTLSConfig),
|
InsecureSkipVerify: b.GetBool(skipTLSConfig),
|
||||||
|
@ -174,8 +174,6 @@ func (b *Bsteam) handleEvents() {
|
|||||||
b.c.Connect()
|
b.c.Connect()
|
||||||
case steam.FatalErrorEvent:
|
case steam.FatalErrorEvent:
|
||||||
b.Log.Error(e)
|
b.Log.Error(e)
|
||||||
case error:
|
|
||||||
b.Log.Error(e)
|
|
||||||
default:
|
default:
|
||||||
b.Log.Debugf("unknown event %#v", e)
|
b.Log.Debugf("unknown event %#v", e)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user