Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made the connections to the slack App/Bot public #20

Merged
merged 1 commit into from
Sep 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions wrapper/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ type SlackWrapper interface {

// Slack is a wrapper around the Slack App and RTM APIs
type Slack struct {
app *slack.Client
bot *slackbot.Bot
App *slack.Client
Bot *slackbot.Bot
}

// New takes an app and bot token, verifies the connection and
Expand All @@ -34,21 +34,21 @@ func New(appToken, botToken string) (*Slack, error) {
if _, err = slackBot.Client.AuthTest(); err != nil {
return nil, err
}
return &Slack{app: slackApp, bot: slackBot}, nil
return &Slack{App: slackApp, Bot: slackBot}, nil
}

// OpenDialog opens a Dialog inside Slack
func (s *Slack) OpenDialog(triggerID string, dialog slack.Dialog) error {
err := s.app.OpenDialog(triggerID, dialog)
err := s.App.OpenDialog(triggerID, dialog)
if err != nil {
fmt.Errorf("error opening dialog. %s", err)
fmt.Printf("error opening dialog. %s\n", err)
return err
}
return err
}

// SendMessage posts a message to Slack that is visible to everyone in the channel
func (s *Slack) SendMessage(message, channel string) {
msg := s.bot.RTM.NewOutgoingMessage(message, fmt.Sprintf("#%s", channel))
s.bot.RTM.SendMessage(msg)
msg := s.Bot.RTM.NewOutgoingMessage(message, fmt.Sprintf("#%s", channel))
s.Bot.RTM.SendMessage(msg)
}