command

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadInput      = errors.New("Empty text")
	ErrNoSuchCommand = errors.New("no such command")
)

errors

View Source
var (
	ErrNoContent = errors.New("no content field in json")
)

errors

Functions

This section is empty.

Types

type Command

type Command interface {
	Answer() (string, error)
}

Command used by bot to answer user. Bot can response to commands of type "/help", or maybe "/calc 2+2".

func ParseCommand

func ParseCommand(msg *models.Message) (Command, error)

ParseCommand gots input of type "/help smth" and returns a command

func ParseCommandForBot

func ParseCommandForBot(botname string, msg *models.Message) (Command, error)

ParseCommandForBot gots input of type "Bot, /help smth" (comma after bot name can be omitted) and returns a command

type CommandFunc

type CommandFunc func() (string, error)

CommandFunc is adapter for Command

func AnecdotCommand

func AnecdotCommand() CommandFunc

AnecdotCommand for string "/help"

func HelpCommand

func HelpCommand() CommandFunc

HelpCommand for string "/help"

func (CommandFunc) Answer

func (cf CommandFunc) Answer() (string, error)

Answer ...

Jump to

Keyboard shortcuts

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