conversation

package
v0.14.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

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:

Examples

See [New] and Init.

Index

Examples

Constants

View Source
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.

View Source
const Name gosync.ConfigKey = "name"

Name is the Slack conversation name.

View Source
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)
}

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)
}

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)
}

func (*Conversation) Add

func (c *Conversation) Add(_ context.Context, emails []string) error

Add email addresses to a Slack Conversation.

func (*Conversation) Get

func (c *Conversation) Get(_ context.Context) ([]string, error)

Get email addresses in a Slack Conversation.

func (*Conversation) Remove

func (c *Conversation) Remove(_ context.Context, emails []string) error

Remove email addresses from a Slack Conversation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL