olivia: github.com/olivia-ai/olivia/modules Index | Files | Directories

package modules

import "github.com/olivia-ai/olivia/modules"

Index

Package Files

advices.go area.go capital.go currency.go jokes.go math.go modules.go movies.go name.go random.go reminder.go spotify.go

Variables

var (
    // CapitalTag is the intent tag for its module
    CapitalTag = "capital"
    // ArticleCountries is the map of functions to find the article in front of a country
    // in different languages
    ArticleCountries = map[string]func(string) string{}
)
var (
    // GenresTag is the intent tag for its module
    GenresTag = "movies genres"
    // MoviesTag is the intent tag for its module
    MoviesTag = "movies search"
    // MoviesAlreadyTag is the intent tag for its module
    MoviesAlreadyTag = "already seen movie"
    // MoviesDataTag is the intent tag for its module
    MoviesDataTag = "movies search from data"
)
var (
    // NameGetterTag is the intent tag for its module
    NameGetterTag = "name getter"
    // NameSetterTag is the intent tag for its module
    NameSetterTag = "name setter"
)
var (
    // ReminderSetterTag is the intent tag for its module
    ReminderSetterTag = "reminder setter"
    // ReminderGetterTag is the intent tag for its module
    ReminderGetterTag = "reminder getter"
)
var (
    // SpotifySetterTag is the intent tag for its module
    SpotifySetterTag = "spotify setter"
    // SpotifyPlayerTag is the intent tag for its module
    SpotifyPlayerTag = "spotify player"
)
var AdvicesTag = "advices"

AdvicesTag is the intent tag for its module

var AreaTag = "area"

AreaTag is the intent tag for its module

var CurrencyTag = "currency"

CurrencyTag is the intent tag for its module

var JokesTag = "jokes"

JokesTag is the intent tag for its module

var MathTag = "math"

MathTag is the intent tag for its module

var RandomTag = "random number"

RandomTag is the intent tag for its module

func AdvicesReplacer Uses

func AdvicesReplacer(locale, entry, response, _ string) (string, string)

AdvicesReplacer replaces the pattern contained inside the response by a random advice from the api specified by the adviceURL. See modules/modules.go#Module.Replacer() for more details.

func AreaReplacer Uses

func AreaReplacer(locale, entry, response, _ string) (string, string)

AreaReplacer replaces the pattern contained inside the response by the area of the country specified in the message. See modules/modules.go#Module.Replacer() for more details.

func CapitalReplacer Uses

func CapitalReplacer(locale, entry, response, _ string) (string, string)

CapitalReplacer replaces the pattern contained inside the response by the capital of the country specified in the message. See modules/modules.go#Module.Replacer() for more details.

func CurrencyReplacer Uses

func CurrencyReplacer(locale, entry, response, _ string) (string, string)

CurrencyReplacer replaces the pattern contained inside the response by the currency of the country specified in the message. See modules/modules.go#Module.Replacer() for more details.

func GenresReplacer Uses

func GenresReplacer(locale, entry, response, token string) (string, string)

GenresReplacer gets the genre specified in the message and adds it to the user information. See modules/modules.go#Module.Replacer() for more details.

func JokesReplacer Uses

func JokesReplacer(locale, entry, response, _ string) (string, string)

JokesReplacer replaces the pattern contained inside the response by a random joke from the api specified in jokeURL. See modules/modules.go#Module.Replacer() for more details.

func MathReplacer Uses

func MathReplacer(locale, entry, response, _ string) (string, string)

MathReplacer replaces the pattern contained inside the response by the answer of the math expression specified in the message. See modules/modules.go#Module.Replacer() for more details.

func MovieSearchFromInformationReplacer Uses

func MovieSearchFromInformationReplacer(locale, _, response, token string) (string, string)

MovieSearchFromInformationReplacer replaces the patterns contained inside the response by the movie's name and rating from the genre in the user's information. See modules/modules.go#Module.Replacer() for more details.

func MovieSearchReplacer Uses

func MovieSearchReplacer(locale, entry, response, token string) (string, string)

MovieSearchReplacer replaces the patterns contained inside the response by the movie's name and rating from the genre specified in the message. See modules/modules.go#Module.Replacer() for more details.

func NameGetterReplacer Uses

func NameGetterReplacer(locale, _, response, token string) (string, string)

NameGetterReplacer replaces the pattern contained inside the response by the user's name. See modules/modules.go#Module.Replacer() for more details.

func NameSetterReplacer Uses

func NameSetterReplacer(locale, entry, response, token string) (string, string)

NameSetterReplacer gets the name specified in the message and save it in the user's information. See modules/modules.go#Module.Replacer() for more details.

func RandomNumberReplacer Uses

func RandomNumberReplacer(locale, entry, response, _ string) (string, string)

RandomNumberReplacer replaces the pattern contained inside the response by a random number. See modules/modules.go#Module.Replacer() for more details.

func RegisterModule Uses

func RegisterModule(locale string, module Module)

RegisterModule registers a module into the map

func RegisterModules Uses

func RegisterModules(locale string, _modules []Module)

RegisterModules registers an array of modules into the map

func ReminderGetterReplacer Uses

func ReminderGetterReplacer(locale, _, response, token string) (string, string)

ReminderGetterReplacer gets the reminders in the user's information and replaces the pattern in the response patterns by the current reminders See modules/modules.go#Module.Replacer() for more details.

func ReminderSetterReplacer Uses

func ReminderSetterReplacer(locale, entry, response, token string) (string, string)

ReminderSetterReplacer replaces the pattern contained inside the response by the date of the reminder and its reason. See modules/modules.go#Module.Replacer() for more details.

func ReplaceContent Uses

func ReplaceContent(locale, tag, entry, response, token string) (string, string)

ReplaceContent apply the Replacer of the matching module to the response and returns it

func SearchDevice Uses

func SearchDevice(client spotify.Client, content string) spotify.PlayerDevice

SearchDevice searches for a device name inside the given sentence and returns it

func SearchTrack Uses

func SearchTrack(client spotify.Client, content string) (spotify.FullTrack, error)

SearchTrack searches for a given track name and returns the found track and the error

func SpotifyPlayerReplacer Uses

func SpotifyPlayerReplacer(locale, entry, response, token string) (string, string)

SpotifyPlayerReplacer plays a specified music on the user's spotify See modules/modules.go#Module.Replacer() for more details.

func SpotifySetterReplacer Uses

func SpotifySetterReplacer(locale, entry, _, token string) (string, string)

SpotifySetterReplacer gets the tokens in the user entry and save them into the client's information. See modules/modules.go#Module.Replacer() for more details.

type Joke Uses

type Joke struct {
    ID        int64  `json:"id"`
    Type      string `json:"type"`
    Setup     string `json:"setup"`
    Punchline string `json:"punchline"`
}

Joke represents the response from the joke api

type Module Uses

type Module struct {
    Tag       string
    Patterns  []string
    Responses []string
    Replacer  func(string, string, string, string) (string, string)
    Context   string
}

Module is a structure for dynamic intents with a Tag, some Patterns and Responses and a Replacer function to execute the dynamic changes.

func GetModuleByTag Uses

func GetModuleByTag(tag, locale string) Module

GetModuleByTag returns a module found by the given tag and locale

func GetModules Uses

func GetModules(locale string) []Module

GetModules returns all the registered modules

Directories

PathSynopsis
spotify
start

Package modules imports 15 packages (graph) and is imported by 9 packages. Updated 2020-07-11. Refresh now. Tools for package owners.