import "github.com/dueros/bot-sdk-go/bot"
- type Bot
- func NewBot(rawRequest string) *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) 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))
- func (this *Bot) Run() string
application.go audio_player.go bot.go event_handler.go video_player.go
type Bot struct {
Request interface{} // 对当前request的封装,需要在使用时断言,判断当前的类型
Session *model.Session // 对session的封装
Response *model.Response // 对技能返回的封装
// contains filtered or unexported fields
}
技能基础类
func NewBot(rawRequest string) *Bot
func (*Bot) AddDefaultEventListener
func (this *Bot) AddDefaultEventListener(fn func(bot *Bot, request interface{}))
添加事件默认处理函数 比如,在播放视频时,技能会收到各种事件的上报,如果不想一一处理可以使用这个来添加处理
func (*Bot) AddEventListener
func (this *Bot) AddEventListener(eventName string, fn func(bot *Bot, request interface{}))
添加对事件的处理函数
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 (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 (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 事件
{
"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 (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 (this *Bot) OnVideoPlayerScheduledStopReached(fn func(bot *Bot, request *model.VideoPlayerEventRequest))
视频自动暂停后上报
func (this *Bot) OnVideoRrogressReportIntevalElapsed(fn func(bot *Bot, request *model.VideoPlayerEventRequest))
视频周期上报播放进度
func (this *Bot) Run() string
Generated by godoc2md