Documentation
¶
Index ¶
- func HTTPError(w http.ResponseWriter, logMsg string, err string, errCode int)
- func IsValidRequest(w http.ResponseWriter, r *http.Request) bool
- type Application
- type Bot
- func (this *Bot) AddDefaultEventListener(fn func(bot *Bot, request interface{}))
- func (this *Bot) AddEventListener(eventName string, fn func(bot *Bot, request interface{}))
- func (this *Bot) AddIntentHandler(intentName string, fn func(bot *Bot, request *model.IntentRequest))
- func (this *Bot) Handler(request string) string
- func (this *Bot) OnAudioPlaybackFinished(fn func(bot *Bot, request *model.AudioPlayerEventRequest))
- func (this *Bot) OnAudioPlaybackNearlyFinished(fn func(bot *Bot, request *model.AudioPlayerEventRequest))
- func (this *Bot) OnAudioPlaybackStarted(fn func(bot *Bot, request *model.AudioPlayerEventRequest))
- func (this *Bot) OnAudioPlaybackStopped(fn func(bot *Bot, request *model.AudioPlayerEventRequest))
- func (this *Bot) OnAudioRrogressReportIntevalElapsed(fn func(bot *Bot, request *model.AudioPlayerEventRequest))
- func (this *Bot) OnDisplayElementSelected(fn func(bot *Bot, request *model.EventRequest))
- func (this *Bot) OnLaunchRequest(fn func(bot *Bot, request *model.LaunchRequest))
- func (this *Bot) OnLinkAccountSuccessed(fn func(bot *Bot, request *model.EventRequest))
- func (this *Bot) OnScreenLinkClicked(fn func(bot *Bot, request *model.EventRequest))
- func (this *Bot) OnSessionEndedRequest(fn func(bot *Bot, request *model.SessionEndedRequest))
- func (this *Bot) OnVideoPlaybackFinished(fn func(bot *Bot, request *model.VideoPlayerEventRequest))
- func (this *Bot) OnVideoPlaybackNearlyFinished(fn func(bot *Bot, request *model.VideoPlayerEventRequest))
- func (this *Bot) OnVideoPlaybackStarted(fn func(bot *Bot, request *model.VideoPlayerEventRequest))
- func (this *Bot) OnVideoPlaybackStopped(fn func(bot *Bot, request *model.VideoPlayerEventRequest))
- func (this *Bot) OnVideoPlayerScheduledStopReached(fn func(bot *Bot, request *model.VideoPlayerEventRequest))
- func (this *Bot) OnVideoRrogressReportIntevalElapsed(fn func(bot *Bot, request *model.VideoPlayerEventRequest))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidRequest ¶
func IsValidRequest(w http.ResponseWriter, r *http.Request) bool
IsValidRequest handles all the necessary steps to validate that an incoming http.Request has actually come from the DuerOS service. If an error occurs during the validation process, an http.Error will be written to the provided http.ResponseWriter. The required steps for request validation can be found on this page: https://dueros.baidu.com/didp/doc/dueros-bot-platform/dbp-deploy/authentication_markdown
Types ¶
type Application ¶
type Application struct { AppId string DisableCertificate bool DisableVerifyJson bool Handler func(rawRequest string) string }
func (*Application) ServeHTTP ¶
func (this *Application) ServeHTTP(w http.ResponseWriter, r *http.Request)
创建一个HTTP服务
func (*Application) Verify ¶
func (this *Application) Verify(w http.ResponseWriter, r *http.Request) bool
验证请求是否合法
type Bot ¶
type Bot struct { Request interface{} // 对当前request的封装,需要在使用时断言,判断当前的类型 Session *model.Session // 对session的封装 Response *model.Response // 对技能返回的封装 // contains filtered or unexported fields }
技能基础类
func (*Bot) AddDefaultEventListener ¶
添加事件默认处理函数 比如,在播放视频时,技能会收到各种事件的上报,如果不想一一处理可以使用这个来添加处理
func (*Bot) AddEventListener ¶
添加对事件的处理函数
func (*Bot) AddIntentHandler ¶
func (this *Bot) AddIntentHandler(intentName string, fn func(bot *Bot, request *model.IntentRequest))
添加对intent的处理函数
func (*Bot) OnAudioPlaybackFinished ¶
func (this *Bot) OnAudioPlaybackFinished(fn func(bot *Bot, request *model.AudioPlayerEventRequest))
音频播放完成事件
func (*Bot) OnAudioPlaybackNearlyFinished ¶
func (this *Bot) OnAudioPlaybackNearlyFinished(fn func(bot *Bot, request *model.AudioPlayerEventRequest))
音频快要播放结束上报的事件
func (*Bot) OnAudioPlaybackStarted ¶
func (this *Bot) OnAudioPlaybackStarted(fn func(bot *Bot, request *model.AudioPlayerEventRequest))
音频开始播放事件
func (*Bot) OnAudioPlaybackStopped ¶
func (this *Bot) OnAudioPlaybackStopped(fn func(bot *Bot, request *model.AudioPlayerEventRequest))
音频停止播放事件
func (*Bot) OnAudioRrogressReportIntevalElapsed ¶
func (this *Bot) OnAudioRrogressReportIntevalElapsed(fn func(bot *Bot, request *model.AudioPlayerEventRequest))
音频周期上报播放进度
func (*Bot) OnDisplayElementSelected ¶
func (this *Bot) OnDisplayElementSelected(fn func(bot *Bot, request *model.EventRequest))
ListTemplate 列表选择事件 Display.ButtonClicked 事件 https://dueros.baidu.com/didp/doc/dueros-bot-platform/dbp-custom/display-template_markdown#Display.ElementSelected%E4%BA%8B%E4%BB%B6
func (*Bot) OnLaunchRequest ¶
func (this *Bot) OnLaunchRequest(fn func(bot *Bot, request *model.LaunchRequest))
打开技能时的处理
func (*Bot) OnLinkAccountSuccessed ¶
func (this *Bot) OnLinkAccountSuccessed(fn func(bot *Bot, request *model.EventRequest))
LinkAccountSucceeded 事件 ```javascript
{ "type": "Connections.Response", "name": "LinkAccountSucceeded", "requestId": "{{STRING}}", "timestamp": {{INT32}}, "token": "{{STRING}}" }
```
func (*Bot) OnScreenLinkClicked ¶
func (this *Bot) OnScreenLinkClicked(fn func(bot *Bot, request *model.EventRequest))
Screen.LinkClicked事件 https://dueros.baidu.com/didp/doc/dueros-bot-platform/dbp-custom/cards_markdown#Screen.LinkClicked%E4%BA%8B%E4%BB%B6
{ "type": "Screen.LinkClicked", "url": "{{STRING}}", "requestId": "{{STRING}}", "timestamp": {{INT32}} "token": "{{STRING}}" }
func (*Bot) OnSessionEndedRequest ¶
func (this *Bot) OnSessionEndedRequest(fn func(bot *Bot, request *model.SessionEndedRequest))
技能关闭的处理,比如可以做一些清理的工作 TIP: 根据协议,技能关闭返回的结果,DuerOS不会返回给用户。
func (*Bot) OnVideoPlaybackFinished ¶
func (this *Bot) OnVideoPlaybackFinished(fn func(bot *Bot, request *model.VideoPlayerEventRequest))
视频播放完成事件
func (*Bot) OnVideoPlaybackNearlyFinished ¶
func (this *Bot) OnVideoPlaybackNearlyFinished(fn func(bot *Bot, request *model.VideoPlayerEventRequest))
视频快要播放结束上报的事件
func (*Bot) OnVideoPlaybackStarted ¶
func (this *Bot) OnVideoPlaybackStarted(fn func(bot *Bot, request *model.VideoPlayerEventRequest))
视频开始播放事件
func (*Bot) OnVideoPlaybackStopped ¶
func (this *Bot) OnVideoPlaybackStopped(fn func(bot *Bot, request *model.VideoPlayerEventRequest))
视频停止播放事件
func (*Bot) OnVideoPlayerScheduledStopReached ¶
func (this *Bot) OnVideoPlayerScheduledStopReached(fn func(bot *Bot, request *model.VideoPlayerEventRequest))
视频自动暂停后上报
func (*Bot) OnVideoRrogressReportIntevalElapsed ¶
func (this *Bot) OnVideoRrogressReportIntevalElapsed(fn func(bot *Bot, request *model.VideoPlayerEventRequest))
视频周期上报播放进度