joke

package
v0.0.0-...-3913db3 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GuildIDKey = "guildID"
)

Variables

View Source
var DevServiceLimitExceededErr = errors.New("jokedev: current limit exceeded")
View Source
var HumorAPILimitExceededErr = errors.New("humorAPI: daily limit of jokes was exceeded")

Functions

This section is empty.

Types

type ActiveChecker

type ActiveChecker interface {
	Active(ctx context.Context) bool
}

type AddService

type AddService interface {
	Add(ctx context.Context, joke Joke) (string, error)
}

type Category

type Category string
const (
	PROGRAMMING Category = "Programming"
	MISC        Category = "Misc"
	DARK        Category = "Dark"
	YOMAMA      Category = "YoMama"
	Any         Category = "Any"
)

type DatabaseService

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

func NewDatabaseJokeService

func NewDatabaseJokeService(database db.MongodbService) DatabaseService

func (DatabaseService) Active

func (d DatabaseService) Active(ctx context.Context) bool

func (DatabaseService) Add

func (d DatabaseService) Add(ctx context.Context, joke Joke) (string, error)

func (DatabaseService) Joke

func (d DatabaseService) Joke(ctx context.Context, search SearchParams) (Joke, error)

Joke Try to find Joke from Mongodb database. If SearchParams is empty, then function will find 1 random joke

type DevService

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

func (DevService) Active

func (d DevService) Active(ctx context.Context) (active bool)

func (*DevService) Joke

func (d *DevService) Joke(ctx context.Context, params SearchParams) (Joke, error)

type HumorAPIService

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

func (HumorAPIService) Active

func (h HumorAPIService) Active(ctx context.Context) (active bool)

func (*HumorAPIService) Joke

func (h *HumorAPIService) Joke(ctx context.Context, search SearchParams) (Joke, error)

type Joke

type Joke struct {
	ID       primitive.ObjectID `bson:"_id"`
	Question string             `bson:"question"`
	Answer   string             `bson:"answer"`
	Type     Type               `bson:"type"`
	Category Category           `bson:"category"`
	GuildID  string             `bson:"guild_id"`
}

type SearchParams

type SearchParams struct {
	Type     Type
	Category Category
	ID       primitive.ObjectID
}

type SearchService

type SearchService interface {
	Joke(ctx context.Context, search SearchParams) (Joke, error)
	ActiveChecker
}

func NewHumorAPIService

func NewHumorAPIService(globalCtx context.Context) SearchService

func NewJokeDevService

func NewJokeDevService(globalCtx context.Context) SearchService

type Type

type Type string
const (
	Single  Type = "single"
	TwoPart Type = "twopart"
)

Jump to

Keyboard shortcuts

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