learn

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

Documentation

Index

Constants

View Source
const (
	// MsgCustomNeedsArgs is a user-visible string asking the user for command args.
	MsgCustomNeedsArgs = "This command takes args. Please type `?command <more text>` instead of `?command`"
	// MsgHelpLearn is the help text for ?learn
	MsgHelpLearn = "" /* 299-byte string literal not displayed */
	// MsgHelpUnlearn is the help text for ?unlearn
	MsgHelpUnlearn = "Type `?unlearn <call>` to forget a user-defined command."
	// MsgLearnFail indicates that the user tried to overwrite a learned command
	MsgLearnFail = "I already know ?%s"
	// MsgLearnSuccess indicates that the bot learned the command
	MsgLearnSuccess = "Learned about %s"
	// MsgUnlearnFail indicates that the user attempted to unlearn an unlearnable command
	MsgUnlearnFail = "I can't unlearn `?%s`"
	// MsgUnlearnMustBePublic indicates that the user tried to unlearn in a private channel
	MsgUnlearnMustBePublic = "I can't unlearn in a private message."
	// MsgUnlearnSuccess indicates the bot deleted the given learn
	MsgUnlearnSuccess = "Forgot about %s"
)
View Source
const (
	// MsgGiphyLink is the URL format for direct links to images given the key.
	MsgGiphyLink = "https://i.giphy.com/%s.gif"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomExecutor

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

CustomExecutor executes user-learned commands.

func NewCustomExecutor

func NewCustomExecutor(commandMap stringmap.StringMap) *CustomExecutor

NewCustomExecutor works as advertised.

func (*CustomExecutor) Execute

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

Execute returns the response if possible.

func (*CustomExecutor) GetType

func (e *CustomExecutor) GetType() int

GetType returns the type of this feature.

func (*CustomExecutor) PublicOnly

func (e *CustomExecutor) PublicOnly() bool

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

type CustomLearnExecutor

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

CustomLearnExecutor learns a user-generated command.

func NewCustomLearnExecutor

func NewCustomLearnExecutor(commandMap stringmap.StringMap) *CustomLearnExecutor

NewCustomLearnExecutor works as advertised.

func (*CustomLearnExecutor) Execute

func (f *CustomLearnExecutor) Execute(s api.DiscordSession, channel model.Snowflake, command *model.Command)

Execute replies over the given channel with a help message.

func (*CustomLearnExecutor) GetType

func (f *CustomLearnExecutor) GetType() int

GetType returns the type of this feature.

func (*CustomLearnExecutor) PublicOnly

func (f *CustomLearnExecutor) PublicOnly() bool

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

type CustomLearnParser

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

CustomLearnParser parses ?learn commands.

func NewCustomLearnParser

func NewCustomLearnParser(featureRegistry *feature.Registry, commandMap stringmap.StringMap) *CustomLearnParser

NewCustomLearnParser works as advertised.

func (*CustomLearnParser) GetName

func (p *CustomLearnParser) GetName() string

GetName returns the named type of this feature.

func (*CustomLearnParser) HelpText

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

HelpText explains how to use ?learn.

func (*CustomLearnParser) Parse

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

Parse parses the given learn command.

type CustomParser

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

CustomParser parses all fallthrough commands.

func NewCustomParser

func NewCustomParser(commandMap stringmap.StringMap) *CustomParser

NewCustomParser works as advertised.

func (*CustomParser) GetName

func (p *CustomParser) GetName() string

GetName returns nothing, since it doesn't have a user-invokable name.

func (*CustomParser) HelpText

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

HelpText returns help text for the given custom command.

func (*CustomParser) Parse

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

Parse parses the given custom command.

type Feature

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

Feature allows crbot to learn new calls and responses

func NewFeature

func NewFeature(featureRegistry *feature.Registry, commandMap 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 returns the executors for the ?learn feature.

func (*Feature) FallbackParser

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

FallbackParser returns the custom parser, to recognize custom ? commands. It should be the only fallback parser in the project.

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 UnlearnExecutor

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

UnlearnExecutor attempts to unlearn a custom command and returns the result to the user.

func NewUnlearnExecutor

func NewUnlearnExecutor(commandMap stringmap.StringMap) *UnlearnExecutor

NewUnlearnExecutor works as advertised.

func (*UnlearnExecutor) Execute

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

Execute replies over the given channel indicating successful unlearning, or failure to unlearn.

func (*UnlearnExecutor) GetType

func (e *UnlearnExecutor) GetType() int

GetType returns the type of this feature.

func (*UnlearnExecutor) PublicOnly

func (e *UnlearnExecutor) PublicOnly() bool

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

type UnlearnParser

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

UnlearnParser parses ?unlearn commands.

func NewUnlearnParser

func NewUnlearnParser(featureRegistry *feature.Registry, commandMap stringmap.StringMap) *UnlearnParser

NewUnlearnParser works as advertised.

func (*UnlearnParser) GetName

func (p *UnlearnParser) GetName() string

GetName returns the named type of this feature.

func (*UnlearnParser) HelpText

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

HelpText returns the help text for ?unlearn.

func (*UnlearnParser) Parse

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

Parse parses the given unlearn command.

Jump to

Keyboard shortcuts

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