usecase

package
v0.0.0-...-8314da0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Config

type Config struct {
	Topics          map[entity.Topic]string `env:"TOPICS"`
	DiscordWebhooks map[entity.Topic]string `env:"DISCORD_WEBHOOKS"`
}

type DiscordClient

type DiscordClient interface {
	AddMessageCreateHandler(handler MessageCreateHandler)
	ExecuteWebhook(ctx context.Context, id, token string, params *discordgo.WebhookParams) error
	FindGuild(ctx context.Context, id string) (*discordgo.Guild, error)
	FindChannel(ctx context.Context, id string) (*discordgo.Channel, error)
	FindGuildMember(ctx context.Context, guildID string, userID string) (*discordgo.Member, error)
}

type MessageCreateHandler

type MessageCreateHandler func(event *discordgo.MessageCreate) error

type MessageStore

type MessageStore interface {
	PublishMessage(ctx context.Context, message *entity.Message) error
	SubscribeMessage(ctx context.Context, channel chan<- *entity.Message)
}

type Service

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

func NewService

func NewService(ctx context.Context, config *Config, store MessageStore, discord DiscordClient) *Service

func (*Service) DetectMessageTopics

func (s *Service) DetectMessageTopics(message *entity.Message) mapset.Set[entity.Topic]

func (*Service) ListTopics

func (s *Service) ListTopics() map[entity.Topic][]string

func (*Service) SubscribeEvent

func (s *Service) SubscribeEvent(ctx context.Context, topics mapset.Set[entity.Topic], channel chan<- *entity.EventFrame)

type Usecase

type Usecase interface {
	SubscribeEvent(ctx context.Context, topics mapset.Set[entity.Topic], channel chan<- *entity.EventFrame)
}

Jump to

Keyboard shortcuts

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