discord

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

An Adapter implementation for Discord.

Documentation

Index

Constants

View Source
const ZeroWidthSpace = "\u200b"

Variables

This section is empty.

Functions

func NewAdapter

func NewAdapter(provider data.DiscordProvider) (adapter.Adapter, error)

NewAdapter will construct a DiscordAdapter instance for a given provider configuration.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter is the Discord provider implementation of a relay, which knows how to receive events from the Discord API, translate them into Gort events, and forward them along.

func (*Adapter) GetChannelInfo

func (s *Adapter) GetChannelInfo(channelID string) (*adapter.ChannelInfo, error)

GetChannelInfo provides info on a specific provider channel accessible to the adapter.

func (*Adapter) GetName

func (s *Adapter) GetName() string

GetName provides the name of this adapter as per the configuration.

func (*Adapter) GetPresentChannels

func (s *Adapter) GetPresentChannels() ([]*adapter.ChannelInfo, error)

GetPresentChannels returns a slice of channels that a user is present in.

func (*Adapter) GetUserInfo

func (s *Adapter) GetUserInfo(userID string) (*adapter.UserInfo, error)

GetUserInfo provides info on a specific provider user accessible to the adapter.

func (*Adapter) Listen

func (s *Adapter) Listen(ctx context.Context) <-chan *adapter.ProviderEvent

Listen causes the Adapter to initiate a connection to its provider and begin relaying back events (including errors) via the returned channel.

func (*Adapter) Send added in v0.9.0

func (s *Adapter) Send(ctx context.Context, channelID string, elements templates.OutputElements) error

Send the contents of a response envelope to a specified channel. If channelID is empty the value of envelope.Request.ChannelID will be used.

func (*Adapter) SendError added in v0.9.0

func (s *Adapter) SendError(ctx context.Context, channelID string, title string, err error) error

SendError is a break-glass error message function that's used when the templating function fails somehow. Obviously, it does not utilize the templating engine.

func (*Adapter) SendText added in v0.9.0

func (s *Adapter) SendText(ctx context.Context, channelID string, message string) error

SendText sends a simple text message to the specified channel.

Jump to

Keyboard shortcuts

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