mommy

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: ISC Imports: 11 Imported by: 0

README

go-mommy

Mommy's here to support you when using Go~ ❤️

Go library to read cargo-mommy's JSON file and generate similar prompts.

Library

See pkg.go.dev documentation.

CLI

To install the CLI, run:

go install libdb.so/go-mommy/cmd/mommy@latest # assumes $GOBIN in $PATH
ln -s $(which mommy) $(which daddy) # optional

Usage (mommy --help):

Usage:
  mommy [options] <response-type>
  daddy [options] <response-type>

  <response-type> := <positive> | <negative>
  <positive>      := positive | + | 0
  <negative>      := negative | - | 1

Examples:
  mommy --mommys-little girl positive
  daddy --daddys-little boy --daddys-pronouns his -

Flags:
      --mommys-emotes strings     what emotes mommy will have~
      --mommys-little strings     what to call you~
      --mommys-pronouns strings   what pronouns mommy will use for themself~
      --mommys-roles strings      what role mommy will have~
  -n, --nsfw                      show NSFW flags and include NSFW responses
  -f, --responses-file string     responses.json file (default: bundled responses.json)
  -S, --seed int                  seed for the random number generator (default 1699884773843756301)
  -s, --stylize                   stylize the output using ANSI escape codes

Example:

―❤―▶ mommy -
oops~! mommy loves you anyways~

―❤―▶ mommy -
oh no did mommy's little girl make a big mess~?

―❤―▶ mommy -
mommy thinks her little girl is getting close~

Irrelevant Tidbits

Benchmarks!! These numbers are useless, please don't compare them at all!

goos: linux
goarch: amd64
pkg: libdb.so/go-mommy
cpu: 12th Gen Intel(R) Core(TM) i5-1240P
BenchmarkGenerate/string-16         	3006885	      388.4 ns/op	    410 B/op	      4 allocs/op
BenchmarkGenerate/discard-16        	3472392	      340.1 ns/op	    336 B/op	      2 allocs/op
PASS
ok  	libdb.so/go-mommy	3.113s

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNSFW

func IsNSFW(s Spiciness) bool

IsNSFW returns true if the given spiciness is NSFW.

Types

type Generator

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

Generator is a mommy response generator. It is safe for concurrent use.

func NewGenerator

func NewGenerator(config Responses) (*Generator, error)

NewGenerator creates a new mommy response generator with a new automatically seeded random number generator.

func NewGeneratorWithRandom

func NewGeneratorWithRandom(config Responses, rng *rand.Rand) (*Generator, error)

NewGeneratorWithRandom creates a new mommy response generator with the given random number generator.

func (*Generator) Generate

func (g *Generator) Generate(response ResponseType, overrides Overrides) (string, error)

Generate generates a response from the given response type with an optional set of overrides. If a variable is present in the overrides map, then it will use that value. If a variable is not present in the overrides map, then it will use a random default value. If a variable has no default values, then it will return an error

Example
random := rand.New(rand.NewSource(0)) // deterministic for example
gen, _ := mommy.NewGeneratorWithRandom(mommy.DefaultResponses, random)

positive, _ := gen.Generate(mommy.PositiveResponse, nil)

fmt.Println("when you did a good job:")
fmt.Println(positive)
fmt.Println()

negative, _ := gen.Generate(mommy.NegativeResponse, mommy.Overrides{
	mommy.VariableMood:             mommy.Thirsty,
	mommy.VariableAffectionateTerm: "boy",
})

fmt.Println("when you did a bad job:")
fmt.Println(negative)
fmt.Println()
Output:

when you did a good job:
good girl~
mommy's so proud of you~

when you did a bad job:
you need to work harder to please mommy~

func (*Generator) GenerateTo added in v0.1.1

func (g *Generator) GenerateTo(w io.Writer, response ResponseType, overrides Overrides) error

type Mood

type Mood struct {
	Positive  []Template `json:"positive"`
	Negative  []Template `json:"negative"`
	Spiciness Spiciness  `json:"spiciness,omitempty"` // NSFW
}

Mood contains the responses for a given mood. It is represented as a list of positive and negative responses, and optionally a spiciness level.

type Overrides

type Overrides map[VariableKey]string

Overrides is a map of variable keys to values that can be used to override the default values. If a variable is not present in this map, then a random default value will be used.

type ResponseType

type ResponseType string

ResponseType is the type of response that mommy will generate.

const (
	PositiveResponse ResponseType = "positive"
	NegativeResponse ResponseType = "negative"
)

type Responses

type Responses struct {
	// Moods is a map of moods that mommy has. This map contains the responses
	// that mommy will use when they are in that mood.
	Moods map[Spiciness]Mood `json:"moods"`
	// Vars is a map of variables that can be used in the responses.
	// It is used in tandem with the template strings.
	Vars map[VariableKey]Variable `json:"vars"`
}

Responses is the JSON representation of the responses.json file. It is used to unmarshal the responses.json file.

var DefaultResponses Responses

DefaultResponses is the default responses.json file. It is embedded into the binary.

func UnmarshalResponses

func UnmarshalResponses(data []byte) (Responses, error)

UnmarshalResponses unmarshals the responses.json file.

func (Responses) WithVariable

func (r Responses) WithVariable(k VariableKey, v []string) Responses

WithVariable sets a variable to a new responses object.

func (Responses) WithVariables

func (r Responses) WithVariables(vars map[VariableKey][]string) Responses

WithVariables sets variables to a new responses object.

type Spiciness

type Spiciness = string

Spiciness is a measure of how NSFW a response is.

const (
	Chill   Spiciness = "chill"
	Thirsty Spiciness = "thirsty" // NSFW
	Yikes   Spiciness = "yikes"   // NSFW
)

type Template

type Template string

Template describes a string that contains templating variables. It expects the syntax "{variable_name}".

type Variable

type Variable struct {
	// Spiciness is a measure of how NSFW this variable is.
	Spiciness Spiciness `json:"spiciness,omitempty"` // NSFW
	// Defaults is a list of default values for this variable.
	Defaults []string `json:"defaults"`
	// EnvKey is the environment variable key that can be used to override the
	// default values. This field is not used by this package.
	EnvKey string `json:"env_key,omitempty"`
}

Variable is a variable that is used in the string templates.

type VariableKey

type VariableKey string

VariableKey is the key for a response variable.

const (
	// VariableMood determines the spiciness of the response.
	// It is any of the Spiciness constants.
	VariableMood VariableKey = "mood"
	// VariableEmote is an emoji that may be used in the response.
	VariableEmote VariableKey = "emote"
	// VariablePronoun is the possessive pronoun that mommy will use.
	VariablePronoun VariableKey = "pronoun"
	// VariableRole is the role that mommy will use, e.g. "mommy".
	VariableRole VariableKey = "role"
	// VariableAffectionateTerm is an affectionate term that mommy will use to
	// refer to you.
	VariableAffectionateTerm VariableKey = "affectionate_term"
	// VariableDenigratingTerm is a denigrating term that mommy will use to
	// refer to you.
	VariableDenigratingTerm VariableKey = "denigrating_term" // NSFW
	// VariablePart is a part of mommy's body that they will refer to.
	VariablePart VariableKey = "part" // NSFW
)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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