modules

package
v0.0.0-...-c4bfc47 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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{}
)
View Source
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"
)
View Source
var (
	// NameGetterTag is the intent tag for its module
	NameGetterTag = "name getter"
	// NameSetterTag is the intent tag for its module
	NameSetterTag = "name setter"
)
View Source
var (
	// ReminderSetterTag is the intent tag for its module
	ReminderSetterTag = "reminder setter"
	// ReminderGetterTag is the intent tag for its module
	ReminderGetterTag = "reminder getter"
)
View Source
var (
	// SpotifySetterTag is the intent tag for its module
	SpotifySetterTag = "spotify setter"
	// SpotifyPlayerTag is the intent tag for its module
	SpotifyPlayerTag = "spotify player"
)
View Source
var AdvicesTag = "advices"

AdvicesTag is the intent tag for its module

View Source
var AreaTag = "area"

AreaTag is the intent tag for its module

View Source
var CurrencyTag = "currency"

CurrencyTag is the intent tag for its module

View Source
var JokesTag = "jokes"

JokesTag is the intent tag for its module

View Source
var MathTag = "math"

MathTag is the intent tag for its module

View Source
var RandomTag = "random number"

RandomTag is the intent tag for its module

Functions

func AdvicesReplacer

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

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

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

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

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

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

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

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

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

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

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

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

func RegisterModule(locale string, module Module)

RegisterModule registers a module into the map

func RegisterModules

func RegisterModules(locale string, _modules []Module)

RegisterModules registers an array of modules into the map

func ReminderGetterReplacer

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

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

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

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

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

func SearchTrack

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

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

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.

Types

type Joke

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

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

func GetModuleByTag(tag, locale string) Module

GetModuleByTag returns a module found by the given tag and locale

func GetModules

func GetModules(locale string) []Module

GetModules returns all the registered modules

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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