karmalist

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: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MsgGistAddress is a user-visible string announcing the url of the hastebin
	MsgGistAddress = "The list of karma is here"
	// MsgListKarma is a user-visible header for the list of Karma'd things
	MsgListKarma = "Karma targets listed by Magnitude:"
)
View Source
const (
	// MsgKarmaMapFailed is an error string for when the Karma map fails
	MsgKarmaMapFailed = "error reading karma map"
	// MsgNoKarma is an error string for when karma hasn't been stored yet.
	MsgNoKarma = "nothing has accumulated karma"
)
View Source
const (
	// MsgHelpKarmaList is the help text for ?karmalist
	MsgHelpKarmaList = "Type `?karmalist` to get the URL of a hastebin with all them karma"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

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

Executor uploads sorted karma list to hastebin and returns the url to the user

func NewExecutor

func NewExecutor(featureRegistry *feature.Registry, karmaMap stringmap.StringMap, modelHelper *ModelHelper, gist api.Gist) *Executor

NewExecutor works as advertised

func (*Executor) Execute

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

Execute uploads the sorted karma list to the gist API and pings the gist link in chat.

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 is a Feature that lists karma on the crbot instance

func NewFeature

func NewFeature(featureRegistry *feature.Registry, karmaMap stringmap.StringMap, gist api.Gist) *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 returns the karmalist 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 returns the parsers.

type ModelHelper

type ModelHelper struct {
	KarmaMap stringmap.StringMap
}

ModelHelper adds functions that abstract transformations to the Karma before it is sent to the Gist api. Currently the only transformation is sorting by magnitude. Future enhancements could be only showing hated or loved things. Karma would need an overhaul to list users vs other since users are stored by plain text Discord username with no differentiation

func NewModelHelper

func NewModelHelper(stringMap stringmap.StringMap) *ModelHelper

NewModelHelper works as advertised.

func (*ModelHelper) GenerateList

func (h *ModelHelper) GenerateList() string

GenerateList returns a string of all the user:karma pairs in the map sorted by magnitude. If there is no karma, it returns an error string.

type Parser

type Parser struct{}

Parser parses ?karmalist commands.

func NewParser

func NewParser() *Parser

NewParser works as advertised.

func (*Parser) GetName

func (p *Parser) GetName() string

GetName returns the named type of this feature.

func (*Parser) HelpText

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

HelpText explains how to use ?list.

func (*Parser) Parse

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

Parse parses the given list command.

Jump to

Keyboard shortcuts

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