Documentation ¶
Index ¶
- Constants
- func AddCommand(from, channel string, command CommandEnum, args ...string)
- func AddScheduledCommand(trigger time.Time, from, channel string, command CommandEnum, args ...string)
- func DeliverAnalysis(channel, format string, a ...interface{})
- func GetOffsetForOrdinal(ordinal string) string
- func GetTriggerFromParserResult(result *ParserResult) (bool, time.Time)
- func OnResponse(callback func(channel, response string))
- func ShouldParse(message string) bool
- func Shutdown()
- func StartLoop(context ContextEnum, identifier string)
- type ArgsList
- type Article
- type ArticleAPIResponse
- type CommandEnum
- type CommandMap
- type CommandQueue
- type ContextEnum
- type Feed
- type IncomingCommand
- type Job
- type MoodEnum
- type Parser
- type ParserResult
- type ParserResults
- type PhraseDefinition
- type Post
- type PreparedCommand
- type Response
- type ResponseMap
- type ResponseSet
- type ResponseTypeEnum
- type Scheduler
- type Sequence
- type SimpleParserResult
- type Tag
- type UserRecord
Constants ¶
const ( ResponseTypeEither ResponseTypeEnum = iota ResponseTypeFull = iota ResponseTypeFragment = iota )
Variables ¶
This section is empty.
Functions ¶
func AddCommand ¶
func AddCommand(from, channel string, command CommandEnum, args ...string)
AddCommand adds an IncomingCommand to the command queue.
func AddScheduledCommand ¶
func AddScheduledCommand(trigger time.Time, from, channel string, command CommandEnum, args ...string)
AddScheduledCommand adds a Job to the main Scheduler.
func DeliverAnalysis ¶
func DeliverAnalysis(channel, format string, a ...interface{})
DeliverAnalysis adds an echo command to the queue.
func GetOffsetForOrdinal ¶ added in v0.1.0
GetOffsetForOrdinal gets the offset for a given ordinal number string.
func GetTriggerFromParserResult ¶
func GetTriggerFromParserResult(result *ParserResult) (bool, time.Time)
GetTriggerFromParserResult does what it says.
func OnResponse ¶
func OnResponse(callback func(channel, response string))
OnResponse sets a response callback.
func ShouldParse ¶ added in v0.0.3
ShouldParse returns whether the message should be NLP parsed.
func StartLoop ¶
func StartLoop(context ContextEnum, identifier string)
StartLoop starts the main execution loop.
Types ¶
type Article ¶ added in v0.2.1
type Article struct { ID int `json:"id"` URL string `json:"url"` RelatedURL string `json:"relatedUrl,omitempty"` SourceURL string `json:"sourceUrl,omitempty"` SourceTitle string `json:"sourceTitle,omitempty"` SourceImageURL string `json:"sourceImageUrl,omitempty"` Title string `json:"title"` Description string `json:"description,omitempty"` Published int64 `json:"published"` Updated int64 `json:"updated,omitempty"` Created int64 `json:"created"` Feed *Feed `json:"feed"` }
type ArticleAPIResponse ¶ added in v0.3.0
type ArticleAPIResponse struct {
Items []*Article `json:"items"`
}
ArticleAPIResponse represents an article API response.
type CommandEnum ¶
type CommandEnum int
CommandEnum represents a Command type.
const ( CommandHelp CommandEnum = iota CommandUptime CommandAbout CommandSocial CommandTrack CommandLatestPost CommandLatestArticle CommandWeather CommandRain CommandSnow CommandRandomNumber CommandCoinFlip CommandWinner CommandGif CommandTime CommandDate CommandEcho CommandChangeMood CommandIgnoreUser CommandTrustUser CommandForgetUser CommandToggleAnalysis CommandSchedule )
type CommandMap ¶
type CommandMap map[string][]*IncomingCommand
CommandMap is a map of string to list of IncomingCommand structs.
func (CommandMap) Add ¶
func (m CommandMap) Add(key string, command *IncomingCommand)
Add adds a IncomingCommand to the list found at the given key.
type CommandQueue ¶
type CommandQueue struct {
// contains filtered or unexported fields
}
CommandQueue is an array of IncomingCommand structs and a Mutex.
func (*CommandQueue) Add ¶
func (q *CommandQueue) Add(command *IncomingCommand)
Add adds an IncomingCommand to the queue.
func (*CommandQueue) Execute ¶
func (q *CommandQueue) Execute() []*Sequence
Execute returns a list of Sequences from the command queue and clears it.
type ContextEnum ¶
type ContextEnum int
ContextEnum represents the execution context (IRC, Twitch)
const ( ContextIRC ContextEnum = iota ContextTwitch ContextWeb )
func (ContextEnum) String ¶
func (c ContextEnum) String() string
type IncomingCommand ¶
type IncomingCommand struct { Command CommandEnum Args ArgsList From string Channel string }
IncomingCommand represents a command from a user.
func (*IncomingCommand) Hash ¶
func (c *IncomingCommand) Hash() string
Hash returns a hash value for the command and arguments.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser represents a map of Commands to PhraseDefinition objects.
func (*Parser) LoadPhrase ¶
func (p *Parser) LoadPhrase(phrase string, command CommandEnum, args ...string)
LoadPhrase adds a phrase as a PhraseDefinition object to memory.
func (*Parser) LoadPhraseWithPrepositions ¶
func (p *Parser) LoadPhraseWithPrepositions(command CommandEnum, phrase string)
LoadPhraseWithPrepositions adds prepositional phrases for a given phrase.
func (*Parser) LoadPhrases ¶
func (p *Parser) LoadPhrases(command CommandEnum, phrases ...string)
LoadPhrases adds a list of phrases as PhraseDefinition objects to memory.
func (*Parser) Parse ¶
func (p *Parser) Parse(message string) ParserResults
Parse converts a string to a list of ParserResult objects.
type ParserResult ¶
type ParserResult struct { Command CommandEnum Args ArgsList ParsedArgs map[string]string Index int }
ParserResult represents a discovered command and it's arguments.
func (*ParserResult) GetParsedArg ¶ added in v0.2.1
func (r *ParserResult) GetParsedArg(key string) string
GetParsedArg returns a trimmed parsed argument.
type ParserResults ¶
type ParserResults []*ParserResult
ParserResults represents a list of ParserResult objects.
func (ParserResults) Len ¶
func (r ParserResults) Len() int
func (ParserResults) Less ¶
func (r ParserResults) Less(i, j int) bool
func (ParserResults) Swap ¶
func (r ParserResults) Swap(i, j int)
type PhraseDefinition ¶
type PhraseDefinition struct { Command CommandEnum Args ArgsList RE *regexp.Regexp ParsedArgs ArgsList }
PhraseDefinition represents a regular expression and a list of matches.
type Post ¶ added in v0.2.1
type PreparedCommand ¶
type PreparedCommand struct { Command CommandEnum Args ArgsList Users []string Mood MoodEnum Context ContextEnum }
PreparedCommand represents a command with execution state.
func (*PreparedCommand) Execute ¶
func (c *PreparedCommand) Execute() *ResponseMap
Execute returns a ResponseMap from a command.
func (*PreparedCommand) UserString ¶
func (c *PreparedCommand) UserString() string
UserString returns a concatenated list of users.
type ResponseMap ¶
type ResponseMap struct {
// contains filtered or unexported fields
}
ResponseMap represents a tree of responses.
func (*ResponseMap) Get ¶
func (t *ResponseMap) Get(rt ResponseTypeEnum) ResponseSet
Get a ResponseSet.
func (*ResponseMap) Set ¶
func (t *ResponseMap) Set(rt ResponseTypeEnum, responses ResponseSet)
Set a ResponseSet.
func (*ResponseMap) SetEither ¶
func (t *ResponseMap) SetEither(text string, delay int)
SetEither sets a single Response.
func (*ResponseMap) SetFragment ¶
func (t *ResponseMap) SetFragment(text string)
SetFragment sets a single Response.
func (*ResponseMap) SetSentence ¶
func (t *ResponseMap) SetSentence(text string, delay int)
SetSentence sets a single Response.
type ResponseSet ¶
type ResponseSet []*Response
ResponseSet is a list of Response objects.
func CombineResponseMaps ¶
func CombineResponseMaps(user string, responses []*ResponseMap) ResponseSet
CombineResponseMaps combines an array of ResponseMaps into one ResponseSet
type ResponseTypeEnum ¶
type ResponseTypeEnum int
ResponseTypeEnum respresents a the type of Response.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages a list of Jobs.
type Sequence ¶
type Sequence struct { Channel string Responses ResponseSet }
Sequence represents a ResponseSet and the channel to send to.
type SimpleParserResult ¶
SimpleParserResult represents a discovered command and it's arguments.
func SimpleParse ¶
func SimpleParse(text, d string) *SimpleParserResult
SimpleParse looks for a basic command in a message.