chatbot

package
v0.0.0-...-63bff7e Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2018 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidChatbotName 代表无效的聊天机器人名称的错误。
	ErrInvalidChatbotName = errors.New("Invalid chatbot name")
	// ErrInvalidChatbot 代表无效的聊天机器人的错误。
	ErrInvalidChatbot = errors.New("Invalid chatbot")
	// ErrExistingChatbot 代表对同名的聊天机器人进行重复注册的错误。
	ErrExistingChatbot = errors.New("Existing chatbot")
)

Functions

func Register

func Register(chatbot Chatbot) error

Register 用于注册聊天机器人。 若结果值为nil则表示注册成功。

Types

type Chatbot

type Chatbot interface {
	Name() string
	Begin() (string, error)
	Talk
	ReportError(err error) string
	End() error
}

Chatbot 定义了聊天机器人的接口类型。

func Get

func Get(name string) Chatbot

Get 用于获取指定名称的聊天机器人。

func NewSimpleCN

func NewSimpleCN(name string, talk Talk) Chatbot

NewSimpleCN 用于创建针对中文的演示级聊天机器人。

func NewSimpleEN

func NewSimpleEN(name string, talk Talk) Chatbot

NewSimpleEN 用于创建针对英文的演示级聊天机器人。

type Talk

type Talk interface {
	Hello(userName string) string
	Talk(heard string) (saying string, end bool, err error)
}

Talk 定义了聊天的接口类型。

Jump to

Keyboard shortcuts

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