pkg

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChannelNotFoundError = stderrors.New("channel not found")
View Source
var MultipleChannelFoundError = stderrors.New("found multiple channels")

Functions

This section is empty.

Types

type Channel

type Channel struct {
	ID   ChannelID
	Name discord.ChannelName
}

func ChannelFromDiscordChannel

func ChannelFromDiscordChannel(channel discordgo.Channel) Channel

func (Channel) Ptr

func (c Channel) Ptr() *Channel

func (Channel) Validate

func (c Channel) Validate(ctx context.Context) error

type ChannelByName

type ChannelByName Channels

func (ChannelByName) Len

func (p ChannelByName) Len() int

func (ChannelByName) Less

func (p ChannelByName) Less(i, j int) bool

func (ChannelByName) Swap

func (p ChannelByName) Swap(i, j int)

type ChannelCreator

type ChannelCreator interface {
	CreateChannel(ctx context.Context, name discord.ChannelName) (*Channel, error)
}

func NewChannelCreator

func NewChannelCreator(
	session *discordgo.Session,
	serverID ServerID,
) ChannelCreator

type ChannelExistsChecker

type ChannelExistsChecker interface {
	Exists(ctx context.Context, channelID ChannelID) (bool, error)
}

func NewChannelExistsChecker

func NewChannelExistsChecker(discordSession *discordgo.Session) ChannelExistsChecker

type ChannelID

type ChannelID string

func (ChannelID) Bytes

func (c ChannelID) Bytes() []byte

func (ChannelID) Ptr

func (c ChannelID) Ptr() *ChannelID

func (ChannelID) String

func (c ChannelID) String() string

func (ChannelID) Validate

func (c ChannelID) Validate(ctx context.Context) error

type ChannelIDFinder

type ChannelIDFinder interface {
	FindByName(ctx context.Context, name discord.ChannelName) (Channels, error)
}

func NewChannelIDFinder

func NewChannelIDFinder(
	channelStreamer ChannelStreamer,
) ChannelIDFinder

type ChannelIDProvider

type ChannelIDProvider interface {
	FindOrCreate(ctx context.Context, name discord.ChannelName) (*ChannelID, error)
}

func NewChannelIDProvider

func NewChannelIDProvider(
	channelIDFinder ChannelIDFinder,
	channelCreator ChannelCreator,
) ChannelIDProvider

func NewChannelIDProviderCache

func NewChannelIDProviderCache(
	channelIDProvider ChannelIDProvider,
) ChannelIDProvider

func NewChannelIDProviderStore

func NewChannelIDProviderStore(
	channelStore ChannelStore,
	channelIDProvider ChannelIDProvider,
	channelExistsChecker ChannelExistsChecker,
) ChannelIDProvider

type ChannelIDProviderFunc

type ChannelIDProviderFunc func(ctx context.Context, name discord.ChannelName) (*ChannelID, error)

func (ChannelIDProviderFunc) FindOrCreate

func (c ChannelIDProviderFunc) FindOrCreate(
	ctx context.Context,
	name discord.ChannelName,
) (*ChannelID, error)

type ChannelIDProviderTx

type ChannelIDProviderTx interface {
	FindOrCreate(ctx context.Context, tx libkv.Tx, name discord.ChannelName) (*ChannelID, error)
}

ChannelIDProviderTx is a transaction-aware version of ChannelIDProvider that accepts an existing transaction instead of opening a new one.

func NewChannelIDProviderStoreTx

func NewChannelIDProviderStoreTx(
	channelStoreTx ChannelStoreTx,
	channelIDProvider ChannelIDProvider,
	channelExistsChecker ChannelExistsChecker,
) ChannelIDProviderTx

NewChannelIDProviderStoreTx creates a transaction-aware channel ID provider that uses the existing transaction instead of opening a new one.

type ChannelIDProviderTxFunc

type ChannelIDProviderTxFunc func(ctx context.Context, tx libkv.Tx, name discord.ChannelName) (*ChannelID, error)

ChannelIDProviderTxFunc is a function adapter for ChannelIDProviderTx

func (ChannelIDProviderTxFunc) FindOrCreate

func (c ChannelIDProviderTxFunc) FindOrCreate(
	ctx context.Context,
	tx libkv.Tx,
	name discord.ChannelName,
) (*ChannelID, error)

type ChannelIDs

type ChannelIDs []ChannelID

func (ChannelIDs) Contains

func (c ChannelIDs) Contains(channelID ChannelID) bool

type ChannelStore

type ChannelStore interface {
	Add(ctx context.Context, name discord.ChannelName, channelID ChannelID) error
	Get(ctx context.Context, name discord.ChannelName) (*ChannelID, error)
	Stream(ctx context.Context, ch chan<- Channel) error
	Purge(ctx context.Context) error
	Delete(ctx context.Context, name discord.ChannelName) error
}

func NewChannelStore

func NewChannelStore(db libkv.DB) ChannelStore

type ChannelStoreTx

type ChannelStoreTx interface {
	Add(ctx context.Context, tx libkv.Tx, name discord.ChannelName, channelID ChannelID) error
	Get(ctx context.Context, tx libkv.Tx, name discord.ChannelName) (*ChannelID, error)
	Stream(ctx context.Context, tx libkv.Tx, ch chan<- Channel) error
	Purge(ctx context.Context, tx libkv.Tx) error
	Delete(ctx context.Context, tx libkv.Tx, name discord.ChannelName) error
}

func NewChannelStoreTx

func NewChannelStoreTx() ChannelStoreTx

type ChannelStreamer

type ChannelStreamer interface {
	Stream(ctx context.Context, ch chan<- Channel) error
}

func NewChannelStreamer

func NewChannelStreamer(
	session *discordgo.Session,
	serverID ServerID,
) ChannelStreamer

type Channels

type Channels []Channel

type MessageSender

type MessageSender interface {
	Send(ctx context.Context, channelID ChannelID, message discord.Message) error
}

func NewMessageSender

func NewMessageSender(session *discordgo.Session) MessageSender

type MessageSenderFunc

type MessageSenderFunc func(ctx context.Context, channelID ChannelID, message discord.Message) error

func (MessageSenderFunc) Send

func (m MessageSenderFunc) Send(
	ctx context.Context,
	channelID ChannelID,
	message discord.Message,
) error

type ServerID

type ServerID string

func (ServerID) String

func (s ServerID) String() string

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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