joke

package
v0.0.0-...-eab8e8a Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count() (int, error)

Count returns the number of jokes saved in the database

func FetchIfNeeded

func FetchIfNeeded()

FetchIfNeeded fetches jokes once per day

func ForceFetch

func ForceFetch()

ForceFetch allows users to fetch new jokes on demand

func LastJokeID

func LastJokeID() int

LastJokeID returns id of the last joke

func LastNJokeIDs

func LastNJokeIDs(count int) []int

LastNJokeIDs returns id of the last n jokes

func Tell

func Tell(count int)

Tell tells n jokes

Types

type Data

type Data struct {
	ID              int    `json:"-"`
	Setup           string `json:"title"`
	Punchline       string `json:"selftext"`
	WhitelistStatus string `json:"whitelist_status"`
	Score           int    `json:"ups"`
	AdultsOnly      bool   `json:"over_18"`
	IsVideo         bool   `json:"is_video"`
}

Data holds the data of a joke, not all fields will necessarily be saved to the database

func GetJokeByID

func GetJokeByID(id int) *Data

GetJokeByID gets a joke by its ID

func New

func New() *Data

New creates a new joke

func (*Data) Save

func (j *Data) Save() error

Save saves a joke to the db

Jump to

Keyboard shortcuts

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