karma

package
v0.0.0-...-bf34452 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MsgIncrementKarma prints the results of ?++ thing
	MsgIncrementKarma = "%v has been upvoted. %v now has %d karma."
	// MsgDecrementKarma prints the results of ?-- thing
	MsgDecrementKarma = "%v has been downvoted. %v now has %d karma."
)
View Source
const (
	// MsgHelpKarmaIncrement is help text for ?++
	MsgHelpKarmaIncrement = "Type ?++ <target> to add a single unit of karma to a target's karma score"
	// MsgHelpKarmaDecrement is help text for ?--
	MsgHelpKarmaDecrement = "Type ?-- <target> to deduct a single unit of karma from a target's karma score"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

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

Executor increments or decrements karma and prints the results to the user.

func NewExecutor

func NewExecutor(modelHelper *ModelHelper) *Executor

NewExecutor works as advertised.

func (*Executor) Execute

func (e *Executor) Execute(s api.DiscordSession, channelID model.Snowflake, command *model.Command)

Execute attempts to add karma to the total already in memory, or creates a new record if it was not found.

func (*Executor) GetType

func (e *Executor) GetType() int

GetType returns the type of this feature.

func (*Executor) PublicOnly

func (e *Executor) PublicOnly() bool

PublicOnly returns whether the executor should be intercepted in a private channel.

type Feature

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

Feature allows crbot to record changes in karma

func NewFeature

func NewFeature(featureRegistry *feature.Registry, karmaMap stringmap.StringMap) *Feature

NewFeature returns a new Feature.

func (*Feature) CommandInterceptors

func (f *Feature) CommandInterceptors() []feature.CommandInterceptor

CommandInterceptors returns nothing.

func (*Feature) Executors

func (f *Feature) Executors() []feature.Executor

Executors gets the executors.

func (*Feature) FallbackParser

func (f *Feature) FallbackParser() feature.Parser

FallbackParser returns nil

func (*Feature) OnInitialLoad

func (f *Feature) OnInitialLoad(s api.DiscordSession) error

OnInitialLoad does nothing.

func (*Feature) Parsers

func (f *Feature) Parsers() []feature.Parser

Parsers gets the learn feature parsers.

type ModelHelper

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

ModelHelper provides helpers for working with karma storage.

func NewModelHelper

func NewModelHelper(karmaMap stringmap.StringMap) *ModelHelper

NewModelHelper works as advertised.

func (*ModelHelper) Decrement

func (h *ModelHelper) Decrement(target string) (int, error)

Decrement either subtracts 1 from storage in the key, or decrements the key in storage if it exists.

func (*ModelHelper) Increment

func (h *ModelHelper) Increment(target string) (int, error)

Increment either adds 1 to storage in the key, or increments the key in storage if it exists.

type Parser

type Parser struct {
	// The message that the parser looks for.
	Message string
	// Whether this message is incrementing or decrementing karma
	Increment bool
}

Parser parses ?++ and ?-- commands

func NewParser

func NewParser(message string, increment bool) *Parser

NewParser works as advertised.

func (*Parser) GetName

func (p *Parser) GetName() string

GetName returns the named type.

func (*Parser) HelpText

func (p *Parser) HelpText(command string) (string, error)

HelpText returns the help text.

func (*Parser) Parse

func (p *Parser) Parse(splitContent []string, m *discordgo.MessageCreate) (*model.Command, error)

Parse parses the given karma command.

Jump to

Keyboard shortcuts

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