Documentation
¶
Index ¶
- func BuildChatMsg(lst []*chatbotpb.ChatMsgStream) (*chatbotpb.ChatMsg, error)
- func BuildChatMsgList(lst []*chatbotpb.ChatMsgStream) ([]*chatbotpb.ChatMsg, error)
- func BuildChatMsgStream(chat *chatbotpb.ChatMsg) ([]*chatbotpb.ChatMsgStream, error)
- func BuildErrorChatMsg(err error, uai *chatbotpb.UserAppInfo, token string, sessionid string) *chatbotpb.ChatMsg
- func BuildFileChatMsg(msg string, fd *chatbotpb.FileData, uai *chatbotpb.UserAppInfo, token string, ...) *chatbotpb.ChatMsg
- func BuildGroupAppInfo(appType chatbotpb.ChatAppType, usernameAppServ string, groupid string, ...) *chatbotpb.GroupAppInfo
- func BuildTextChatMsg(msg string, uai *chatbotpb.UserAppInfo, token string, sessionid string) *chatbotpb.ChatMsg
- func BuildUserAppInfo(appType chatbotpb.ChatAppType, usernameAppServ string, appuid string, ...) *chatbotpb.UserAppInfo
- func NewChatMsgWithText(l *i18n.Localizer, msgid string, tempParams map[string]interface{}, ...) (*chatbotpb.ChatMsg, error)
- func NewLocalUserMgr(dbpath string, httpAddr string, engine string, core ServiceCore) (*chatbotusermgr.UserMgr, error)
- func RegPlugin(plugin Plugin) error
- func RegisterCommand(cmd string, c Command)
- func SplitCommandString(str string) []string
- func SplitMultiCommandString(str string) []string
- type Client
- type Command
- type CommandData
- type CommandsMgr
- type CommondsList
- func (cmds *CommondsList) AddCommand(cmd string) error
- func (cmds *CommondsList) HasCommand(cmd string) bool
- func (cmds *CommondsList) MultiParseInChat(chat *chatbotpb.ChatMsg) ([]*CommandData, error)
- func (cmds *CommondsList) OnMessage(ctx context.Context, cmd string, serv *Serv, chat *chatbotpb.ChatMsg, ...) (bool, []*chatbotpb.ChatMsg, error)
- func (cmds *CommondsList) ParseInChat(chat *chatbotpb.ChatMsg) (string, interface{}, error)
- func (cmds *CommondsList) RunInChat(ctx context.Context, cmd string, serv *Serv, params interface{}, ...) (bool, []*chatbotpb.ChatMsg, error)
- type Config
- type EmptyServiceCore
- func (core *EmptyServiceCore) NewAppData() (proto.Message, error)
- func (core *EmptyServiceCore) NewUserData(ui *chatbotpb.UserInfo) (proto.Message, error)
- func (core *EmptyServiceCore) OnDebug(ctx context.Context, serv *Serv, chat *chatbotpb.ChatMsg, ...) ([]*chatbotpb.ChatMsg, error)
- func (core *EmptyServiceCore) UnmarshalAppData(buf []byte) (proto.Message, error)
- func (core *EmptyServiceCore) UnmarshalUserData(buf []byte) (proto.Message, error)
- type FileProcessor
- type FileProcessorMgr
- type FuncOnChatMsgs
- type FuncOnTimer
- type Plugin
- type PluginsList
- func (lst *PluginsList) AddPlugin(name string) error
- func (lst *PluginsList) FindPlugin(name string) Plugin
- func (lst *PluginsList) OnMessage(ctx context.Context, serv *Serv, chat *chatbotpb.ChatMsg, ...) ([]*chatbotpb.ChatMsg, error)
- func (lst *PluginsList) OnMessageEx(ctx context.Context, serv *Serv, chat *chatbotpb.ChatMsg, ...) ([]*chatbotpb.ChatMsg, error)
- func (lst *PluginsList) OnStart(ctx context.Context) error
- type Serv
- func (serv *Serv) BuildBasicParamsMap(chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, lang string) (map[string]interface{}, error)
- func (serv *Serv) BuildChatMsgWithLang(chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, prefix string, ...) ([]*chatbotpb.ChatMsg, error)
- func (serv *Serv) BuildChatMsgWithLangEx(chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, lst []string, ...) ([]*chatbotpb.ChatMsg, error)
- func (serv *Serv) GetChatMsgLang(chat *chatbotpb.ChatMsg) string
- func (serv *Serv) Init(ctx context.Context) error
- func (serv *Serv) PushChatMsgs(token string, lst []*chatbotpb.ChatMsg)
- func (serv *Serv) RegisterAppService(ctx context.Context, ras *chatbotpb.RegisterAppService) (*chatbotpb.ReplyRegisterAppService, error)
- func (serv *Serv) RequestChat(req *chatbotpb.RequestChatData, ecs chatbotpb.ChatBotService_RequestChatServer) error
- func (serv *Serv) RequestCtrl(ctx context.Context, msg *chatbotpb.RequestCtrlData) (*chatbotpb.AppCtrlData, error)
- func (serv *Serv) SendChat(scs chatbotpb.ChatBotService_SendChatServer) error
- func (serv *Serv) SendCtrlResult(ctx context.Context, msg *chatbotpb.AppCtrlResult) (*chatbotpb.SCRResult, error)
- func (serv *Serv) Start(ctx context.Context) error
- func (serv *Serv) Stop()
- type ServiceCore
- type TelegramConfig
- type TextMgr
- type Timer
- type UserMgr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildChatMsg ¶
func BuildChatMsg(lst []*chatbotpb.ChatMsgStream) (*chatbotpb.ChatMsg, error)
BuildChatMsg - []ChatMsgStream => ChatMsg
func BuildChatMsgList ¶
func BuildChatMsgList(lst []*chatbotpb.ChatMsgStream) ([]*chatbotpb.ChatMsg, error)
BuildChatMsgList - []ChatMsgStream => []ChatMsg
func BuildChatMsgStream ¶
func BuildChatMsgStream(chat *chatbotpb.ChatMsg) ([]*chatbotpb.ChatMsgStream, error)
BuildChatMsgStream - ChatMsg -> ChatMsgStream
func BuildErrorChatMsg ¶
func BuildErrorChatMsg(err error, uai *chatbotpb.UserAppInfo, token string, sessionid string) *chatbotpb.ChatMsg
BuildErrorChatMsg - build ChatMsg
func BuildFileChatMsg ¶ added in v0.2.10
func BuildFileChatMsg(msg string, fd *chatbotpb.FileData, uai *chatbotpb.UserAppInfo, token string, sessionid string) *chatbotpb.ChatMsg
BuildFileChatMsg - build ChatMsg
func BuildGroupAppInfo ¶ added in v0.5.42
func BuildGroupAppInfo(appType chatbotpb.ChatAppType, usernameAppServ string, groupid string, groupname string) *chatbotpb.GroupAppInfo
BuildGroupAppInfo - build GroupAppInfo
func BuildTextChatMsg ¶
func BuildTextChatMsg(msg string, uai *chatbotpb.UserAppInfo, token string, sessionid string) *chatbotpb.ChatMsg
BuildTextChatMsg - build ChatMsg
func BuildUserAppInfo ¶
func BuildUserAppInfo(appType chatbotpb.ChatAppType, usernameAppServ string, appuid string, appuname string, lang string) *chatbotpb.UserAppInfo
BuildUserAppInfo - build UserAppInfo
func NewChatMsgWithText ¶
func NewChatMsgWithText(l *i18n.Localizer, msgid string, tempParams map[string]interface{}, uai *chatbotpb.UserAppInfo) ( *chatbotpb.ChatMsg, error)
NewChatMsgWithText - new ChatMsg with TextMgr
func NewLocalUserMgr ¶ added in v0.2.13
func NewLocalUserMgr(dbpath string, httpAddr string, engine string, core ServiceCore) ( *chatbotusermgr.UserMgr, error)
NewLocalUserMgr - new local UserMgr
func RegisterCommand ¶
RegisterCommand - add command with cmd
func SplitCommandString ¶
SplitCommandString - split command string
func SplitMultiCommandString ¶ added in v0.5.43
SplitMultiCommandString - split multi command string
Types ¶
type Client ¶
type Client struct { SessionID string // contains filtered or unexported fields }
Client - ChatBotServiceClient
func NewClient ¶
func NewClient(servAddr string, apptype chatbotpb.ChatAppType, token string, username string) *Client
NewClient - new ChatBotServiceClient
func (*Client) RegisterAppService ¶
RegisterAppService - RegisterAppService
func (*Client) RequestChat ¶ added in v0.3.10
RequestChat - RequestChat
type Command ¶
type Command interface { // RunCommand - run command RunCommand(ctx context.Context, serv *Serv, params interface{}, chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, ud proto.Message, scs chatbotpb.ChatBotService_SendChatServer) (bool, []*chatbotpb.ChatMsg, error) // ParseCommandLine - parse command line ParseCommandLine(cmdline []string, chat *chatbotpb.ChatMsg) (interface{}, error) // OnMessage - get message OnMessage(ctx context.Context, serv *Serv, chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, ud proto.Message, scs chatbotpb.ChatBotService_SendChatServer) (bool, []*chatbotpb.ChatMsg, error) }
Command - command
type CommandData ¶ added in v0.5.43
type CommandData struct { Cmd string Params interface{} }
CommandData - command data
type CommandsMgr ¶
type CommandsMgr struct {
// contains filtered or unexported fields
}
CommandsMgr - command manager
func (*CommandsMgr) GetCommand ¶
func (m *CommandsMgr) GetCommand(cmd string) Command
GetCommand - get command
func (*CommandsMgr) RegisterCommand ¶
func (m *CommandsMgr) RegisterCommand(cmd string, c Command)
RegisterCommand - add command with cmd
type CommondsList ¶
type CommondsList struct {
// contains filtered or unexported fields
}
CommondsList - command list
func (*CommondsList) AddCommand ¶
func (cmds *CommondsList) AddCommand(cmd string) error
AddCommand - add command
func (*CommondsList) HasCommand ¶
func (cmds *CommondsList) HasCommand(cmd string) bool
HasCommand - has command
func (*CommondsList) MultiParseInChat ¶ added in v0.5.43
func (cmds *CommondsList) MultiParseInChat(chat *chatbotpb.ChatMsg) ([]*CommandData, error)
MultiParseInChat - parse in chat
func (*CommondsList) OnMessage ¶ added in v0.5.42
func (cmds *CommondsList) OnMessage(ctx context.Context, cmd string, serv *Serv, chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, ud proto.Message, scs chatbotpb.ChatBotService_SendChatServer) (bool, []*chatbotpb.ChatMsg, error)
OnMessage - get message
func (*CommondsList) ParseInChat ¶
func (cmds *CommondsList) ParseInChat(chat *chatbotpb.ChatMsg) (string, interface{}, error)
ParseInChat - parse in chat
func (*CommondsList) RunInChat ¶
func (cmds *CommondsList) RunInChat(ctx context.Context, cmd string, serv *Serv, params interface{}, chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, ud proto.Message, scs chatbotpb.ChatBotService_SendChatServer) (bool, []*chatbotpb.ChatMsg, error)
RunInChat - run func with cmd
type Config ¶
type Config struct { AppServ []chatbotbase.AppServConfig BindAddr string DBPath string DBEngine string PluginsPreprocess []string Plugins []string PluginsSecondLine []string Commands []string Language string LangPath string StartText []string HelpText []string ChatBotNameText string Preprocessor string NoteKeyword string Telegram *TelegramConfig }
Config - config
type EmptyServiceCore ¶ added in v0.2.10
type EmptyServiceCore struct { }
EmptyServiceCore - chatbot service core
func (*EmptyServiceCore) NewAppData ¶ added in v0.2.10
func (core *EmptyServiceCore) NewAppData() (proto.Message, error)
NewAppData - new a app data
func (*EmptyServiceCore) NewUserData ¶ added in v0.2.10
NewUserData - new a userdata
func (*EmptyServiceCore) OnDebug ¶ added in v0.2.13
func (core *EmptyServiceCore) OnDebug(ctx context.Context, serv *Serv, chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, ud proto.Message) ([]*chatbotpb.ChatMsg, error)
OnDebug - call in plugin.debug
func (*EmptyServiceCore) UnmarshalAppData ¶ added in v0.2.10
func (core *EmptyServiceCore) UnmarshalAppData(buf []byte) (proto.Message, error)
UnmarshalAppData - unmarshal
func (*EmptyServiceCore) UnmarshalUserData ¶ added in v0.2.10
func (core *EmptyServiceCore) UnmarshalUserData(buf []byte) (proto.Message, error)
UnmarshalUserData - unmarshal
type FileProcessor ¶ added in v0.2.10
type FileProcessor interface { // Proc - process Proc(ctx context.Context, serv *Serv, chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, ud proto.Message) ([]*chatbotpb.ChatMsg, error) // IsMyFile - is my file IsMyFile(chat *chatbotpb.ChatMsg) bool }
FileProcessor - file processor
type FileProcessorMgr ¶ added in v0.2.10
type FileProcessorMgr struct {
// contains filtered or unexported fields
}
FileProcessorMgr - file processor manager
func (*FileProcessorMgr) ProcFile ¶ added in v0.2.10
func (m *FileProcessorMgr) ProcFile(ctx context.Context, serv *Serv, chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, ud proto.Message) ([]*chatbotpb.ChatMsg, error)
ProcFile - process a file
func (*FileProcessorMgr) RegisterFileProcessor ¶ added in v0.2.10
func (m *FileProcessorMgr) RegisterFileProcessor(fp FileProcessor)
RegisterFileProcessor - register file processor
type FuncOnChatMsgs ¶ added in v0.3.10
FuncOnChatMsgs - function
type Plugin ¶
type Plugin interface { // OnMessage - get message OnMessage(ctx context.Context, serv *Serv, chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, ud proto.Message, scs chatbotpb.ChatBotService_SendChatServer) ([]*chatbotpb.ChatMsg, error) // OnStart - on start OnStart(ctx context.Context) error // GetPluginName - get plugin name GetPluginName() string }
Plugin - chat bot plugin interface
type PluginsList ¶
type PluginsList struct {
// contains filtered or unexported fields
}
PluginsList - plugins list
func (*PluginsList) AddPlugin ¶
func (lst *PluginsList) AddPlugin(name string) error
AddPlugin - add plugin
func (*PluginsList) FindPlugin ¶
func (lst *PluginsList) FindPlugin(name string) Plugin
FindPlugin -
func (*PluginsList) OnMessage ¶
func (lst *PluginsList) OnMessage(ctx context.Context, serv *Serv, chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, ud proto.Message, scs chatbotpb.ChatBotService_SendChatServer) ([]*chatbotpb.ChatMsg, error)
OnMessage - get message
type Serv ¶
type Serv struct { Cfg *Config MgrUser UserMgr MgrText *TextMgr Cmds *CommondsList Core ServiceCore MgrFile *FileProcessorMgr // contains filtered or unexported fields }
Serv - service
func NewChatBotServ ¶
func NewChatBotServ(cfg *Config, mgr UserMgr, core ServiceCore) (*Serv, error)
NewChatBotServ -
func NewSimpleChatBotServ ¶ added in v0.2.13
func NewSimpleChatBotServ(cfg *Config, core ServiceCore) (*Serv, error)
NewSimpleChatBotServ - new a simple chatbot service with local user manager
func (*Serv) BuildBasicParamsMap ¶
func (serv *Serv) BuildBasicParamsMap(chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, lang string) ( map[string]interface{}, error)
BuildBasicParamsMap - build basic params map
func (*Serv) BuildChatMsgWithLang ¶ added in v0.5.42
func (serv *Serv) BuildChatMsgWithLang(chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, prefix string, params map[string]interface{}) ([]*chatbotpb.ChatMsg, error)
BuildChatMsgWithLang -
func (*Serv) BuildChatMsgWithLangEx ¶ added in v0.5.42
func (serv *Serv) BuildChatMsgWithLangEx(chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, lst []string, params map[string]interface{}) ([]*chatbotpb.ChatMsg, error)
BuildChatMsgWithLangEx -
func (*Serv) GetChatMsgLang ¶
GetChatMsgLang - get chat message language
func (*Serv) PushChatMsgs ¶ added in v0.3.10
PushChatMsgs - send ChatMsg List
func (*Serv) RegisterAppService ¶
func (serv *Serv) RegisterAppService(ctx context.Context, ras *chatbotpb.RegisterAppService) ( *chatbotpb.ReplyRegisterAppService, error)
RegisterAppService - register app service
func (*Serv) RequestChat ¶
func (serv *Serv) RequestChat(req *chatbotpb.RequestChatData, ecs chatbotpb.ChatBotService_RequestChatServer) error
RequestChat - request chat
func (*Serv) RequestCtrl ¶ added in v0.3.2
func (serv *Serv) RequestCtrl(ctx context.Context, msg *chatbotpb.RequestCtrlData) ( *chatbotpb.AppCtrlData, error)
RequestCtrl - request control
func (*Serv) SendChat ¶
func (serv *Serv) SendChat(scs chatbotpb.ChatBotService_SendChatServer) error
SendChat - send chat
func (*Serv) SendCtrlResult ¶ added in v0.3.2
func (serv *Serv) SendCtrlResult(ctx context.Context, msg *chatbotpb.AppCtrlResult) ( *chatbotpb.SCRResult, error)
SendCtrlResult - send control result
type ServiceCore ¶
type ServiceCore interface { // UnmarshalAppData - unmarshal UnmarshalAppData(buf []byte) (proto.Message, error) // NewAppData - new a app data NewAppData() (proto.Message, error) // UnmarshalUserData - unmarshal UnmarshalUserData(buf []byte) (proto.Message, error) // NewUserData - new a userdata NewUserData(ui *chatbotpb.UserInfo) (proto.Message, error) // OnDebug - call in plugin.debug OnDebug(ctx context.Context, serv *Serv, chat *chatbotpb.ChatMsg, ui *chatbotpb.UserInfo, ud proto.Message) ([]*chatbotpb.ChatMsg, error) }
ServiceCore - chatbot service core
type TelegramConfig ¶ added in v0.3.2
type TelegramConfig struct {
Channels []string
}
TelegramConfig - config for telegram
type TextMgr ¶
type TextMgr struct {
// contains filtered or unexported fields
}
TextMgr - text manager
type Timer ¶ added in v0.3.10
type Timer struct { OnTimer FuncOnTimer // contains filtered or unexported fields }
Timer - timer
type UserMgr ¶
type UserMgr interface { // GetAppUserInfo - get user infomation GetAppUserInfo(ctx context.Context, appToken string, uai *chatbotpb.UserAppInfo) ( *chatbotpb.UserInfo, proto.Message, error) // GetNoteInfo - get note infomation GetNoteInfo(ctx context.Context, name string) ( *chatbotpb.NoteInfo, error) // UpdNoteInfo - update note infomation UpdNoteInfo(ctx context.Context, ni *chatbotpb.NoteInfo) error // UpdNoteNode - update note node UpdNoteNode(ctx context.Context, nn *chatbotpb.NoteNode) error // GetNoteNode - get note node GetNoteNode(ctx context.Context, nameNote string, noteIndex int64) ( *chatbotpb.NoteNode, error) // DelNoteNode - delete note node DelNoteNode(ctx context.Context, nameNote string, noteIndex int64) error }
UserMgr - user maqnager
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
app
|
|
Package chatbotbase is a generated GoMock package.
|
Package chatbotbase is a generated GoMock package. |
commands
|
|
plugins
|
|
samples
|
|