Documentation
¶
Overview ¶
Package conversation synchronises email addresses with a Slack conversation.
Requirements ¶
In order to synchronise with Slack, you'll need to create a Slack app with the following OAuth Bot Token permissions:
- users:read
- users:read.email
- channels:manage
- channels:read
- groups:read
- groups:write
- im:write
- mpim:write
Examples ¶
See [New] and Init.
Index ¶
Examples ¶
Constants ¶
const MuteRestrictedErrOnKickFromPublic gosync.ConfigKey = "mute_restricted_err_kick_from_public"
MuteRestrictedErrOnKickFromPublic mutes an error that occurs when Slack is configured to prevent kicking users from public conversations. Set this to true to mute this error and continue syncing.
const Name gosync.ConfigKey = "name"
Name is the Slack conversation name.
const SlackAPIKey gosync.ConfigKey = "slack_api_key" //nolint:gosec
SlackAPIKey is an API key for authenticating with Slack.
Variables ¶
This section is empty.
Functions ¶
func WithClient ¶ added in v0.14.0
func WithClient(client *slack.Client) gosync.ConfigFn[*Conversation]
WithClient passes a custom Slack client to the adapter.
Example ¶
package main
import (
"context"
"log"
"github.com/slack-go/slack"
gosync "github.com/ovotech/go-sync"
"github.com/ovotech/go-sync/adapters/slack/conversation"
)
func main() {
ctx := context.Background()
client := slack.New("my-slack-token")
adapter, err := conversation.Init(ctx, map[gosync.ConfigKey]string{
conversation.Name: "C0123ABC456",
}, conversation.WithClient(client))
if err != nil {
log.Fatal(err)
}
gosync.New(adapter)
}
Output:
func WithLogger ¶
func WithLogger(logger *log.Logger) gosync.ConfigFn[*Conversation]
WithLogger passes a custom logger to the adapter.
Example ¶
package main
import (
"context"
"log"
"os"
gosync "github.com/ovotech/go-sync"
"github.com/ovotech/go-sync/adapters/slack/conversation"
)
func main() {
ctx := context.Background()
logger := log.New(os.Stdout, "", log.LstdFlags)
adapter, err := conversation.Init(ctx, map[gosync.ConfigKey]string{
conversation.SlackAPIKey: "my-slack-token",
conversation.Name: "C0123ABC456",
}, conversation.WithLogger(logger))
if err != nil {
log.Fatal(err)
}
gosync.New(adapter)
}
Output:
Types ¶
type Conversation ¶
type Conversation struct {
MuteRestrictedErrOnKickFromPublic bool // See [conversation.MuteRestrictedErrOnKickFromPublic]
Logger *log.Logger
// contains filtered or unexported fields
}
func Init ¶ added in v0.7.0
func Init( _ context.Context, config map[gosync.ConfigKey]string, configFns ...gosync.ConfigFn[*Conversation], ) (*Conversation, error)
Init a new Slack Conversation gosync.Adapter.
Required config:
Example ¶
package main
import (
"context"
"log"
gosync "github.com/ovotech/go-sync"
"github.com/ovotech/go-sync/adapters/slack/conversation"
)
func main() {
ctx := context.Background()
adapter, err := conversation.Init(ctx, map[gosync.ConfigKey]string{
conversation.SlackAPIKey: "my-slack-token",
conversation.Name: "C0123ABC456",
})
if err != nil {
log.Fatal(err)
}
gosync.New(adapter)
}
Output:
func (*Conversation) Add ¶
func (c *Conversation) Add(_ context.Context, emails []string) error
Add email addresses to a Slack Conversation.