github.com/456vv/valexa@v1.0.2-0.20200706152242-1fb922d71ce5/README.md (about) 1 # valexa [![Build Status](https://travis-ci.org/456vv/valexa.svg?branch=master)](https://travis-ci.org/456vv/valexa) 2 golang valexa,亚马逊 Echo Alexa 自定义版本 3 4 # **列表:** 5 ```go 6 type Alexa struct{ // Alexa服务 7 AppIdAttr string // 程序的名称,如:appid 8 } 9 func (T *Alexa) SetEchoApp(alexaAppId string, app *EchoApplication) // 设置echoApp 10 func (T *Alexa) ServeHTTP(w http.ResponseWriter, r *http.Request) // 服务器启用 11 func NewEchoResponse() *EchoResponse // Echo响应 12 func (T *EchoResponse) SetEndSession(ok bool) // 结束对话 13 func (T *EchoResponse) OutputSpeech(text string) *EchoResponse // 输出语音 14 func (T *EchoResponse) OutputSpeechSSML(text string) *EchoResponse // 输出语音(有语气) 15 func (T *EchoResponse) SimpleCard(title string, content string) *EchoResponse // 纯文本卡片 16 func (T *EchoResponse) StandardCard(title string, text string, smallImg string, largeImg string) *EchoResponse // 带图文本卡片 17 func (T *EchoResponse) LinkAccountCard() *EchoResponse // 登录卡片 18 func (T *EchoResponse) RepromptText(text string) *EchoResponse // 回应 19 func (T *EchoResponse) RepromptSSML(text string) *EchoResponse // 回应(有语气) 20 func (T *EchoResponse) String() string // 字符串 21 type EchoRequest struct { // Echo请求 22 Context EchoRequestContext // 上下文 23 Request EchoRequestRequest // 请求 24 Session EchoRequestSession // 会话 25 Version string // 版本 26 } 27 func (T *EchoRequest) VerifyTimestamp(second int) bool // 验证请求时间 28 func (T *EchoRequest) GetLocale() string // 语言类型 29 func (T *EchoRequest) GetApplicationID() string // 程序ID 30 func (T *EchoRequest) GetSessionID() string // 会话ID 31 func (T *EchoRequest) GetUserID() string // 用户ID 32 func (T *EchoRequest) GetAccessToken() string // 用户Token 33 func (T *EchoRequest) GetRequestType() string // 请求类型 34 func (T *EchoRequest) GetIntentName() string // 意图名称 35 func (T *EchoRequest) GetSlots() (slots map[string]*EchoRequestRequestIntentSlot, err error) // 所有类型意图对象(含空值) 36 func (T *EchoRequest) GetValueSlots() (slots map[string]*EchoRequestRequestIntentSlot, err error) // 所有类型意图对象(不含空值) 37 func (T *EchoRequest) GetSlotNames() (names []string) // 所有意图名称 38 func (T *EchoRequest) GetSlotValue(slotName string) (val string, err error) // 意图值 39 func (T *EchoRequest) GetSlot(slotName string) (slot *EchoRequestRequestIntentSlot, err error) // 意图对象 40 type EchoIntent struct{ // Echo意图 41 Request *EchoRequest // Echo请求 42 Response *EchoResponse // Echo响应 43 App *EchoApplication // Echo配置 44 } 45 func (T *EchoIntent) ServeHTTP(w http.ResponseWriter, r *http.Request) 46 type EchoApplication struct { // Echo程序的配置 47 Version []string // 支持的版本号 48 IsDevelop bool // 调试 49 ValidReqTimestamp int // 有效时间,秒为单位 50 CertFolder string // 证书保存目录 51 HandleFunc http.HandlerFunc // 原生处理函数 52 } 53 ```