parent
e10fef8b9d
commit
cf7efb6cc9
@ -34,7 +34,10 @@ func CreateAppContext(flgConfig string) (*AppContext, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create Service
|
// Create Service
|
||||||
svc := service.NewSlackService(config.SlackToken)
|
svc, err := service.NewSlackService(config.SlackToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// Create ChatView
|
// Create ChatView
|
||||||
view := views.CreateChatView(svc)
|
view := views.CreateChatView(svc)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -38,7 +39,7 @@ type Channel struct {
|
|||||||
|
|
||||||
// NewSlackService is the constructor for the SlackService and will initialize
|
// NewSlackService is the constructor for the SlackService and will initialize
|
||||||
// the RTM and a Client
|
// the RTM and a Client
|
||||||
func NewSlackService(token string) *SlackService {
|
func NewSlackService(token string) (*SlackService, error) {
|
||||||
svc := &SlackService{
|
svc := &SlackService{
|
||||||
Client: slack.New(token),
|
Client: slack.New(token),
|
||||||
UserCache: make(map[string]string),
|
UserCache: make(map[string]string),
|
||||||
@ -49,7 +50,7 @@ func NewSlackService(token string) *SlackService {
|
|||||||
// arrives
|
// arrives
|
||||||
authTest, err := svc.Client.AuthTest()
|
authTest, err := svc.Client.AuthTest()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("ERROR: not able to authorize client, check your connection and/or slack-token")
|
return nil, errors.New("not able to authorize client, check your connection and or slack-token")
|
||||||
}
|
}
|
||||||
svc.CurrentUserID = authTest.UserID
|
svc.CurrentUserID = authTest.UserID
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ func NewSlackService(token string) *SlackService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return svc
|
return svc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetChannels will retrieve all available channels, groups, and im channels.
|
// GetChannels will retrieve all available channels, groups, and im channels.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user