Documentation ¶
Index ¶
- Constants
- Variables
- func Decrypt(value string) (response string)
- func DetectLanguage(text string) (langCode string)
- func Download(url string) (data []byte, err error)
- func Encrypt(value string) string
- func GetChatUserUID(driver, userId string) (uid string)
- func GetChatbotRoot(botUID string) string
- func GetFilenameChatbotSettings(mode string) string
- func GetFilenameSettings(pattern, mode string) string
- func Hashtags(keywords []string) string
- func IsQuoted(text string) bool
- func MD5(value string) string
- func Quote(text string) string
- func RemoveFromString(text string, cut []string, n int) string
- func SplitKeywords(text string) (response []string)
- func SplitRows(text string) (response []string)
- func SummarizeText(text string, numSentences int) (response string, err error)
- func SummarizeTextFile(filename string, numSentences int) (response string, err error)
- func ToArrayOfMap(value interface{}) (response []map[string]interface{}, err error)
- func ToMap(value interface{}) (response map[string]interface{}, err error)
- func Trim(text string) string
- func Unquote(text string) string
- func WriteFile(filename, content string) (err error)
- type BotMessage
- type IBot
- type IPublisher
- type Keyword
- type MessageHandler
- type SettingsBot
- type SettingsBotInfo
- type SettingsExternal
Constants ¶
View Source
const ( LibName = "xapp-chatbot" LibVersion = "0.1.1" DbName = "chatbot" DbDriver = "sqlite" DbFile = "chatbot.db" ChatbotSettingsFilepattern = "chatbot.%s.json" ExternalsSettingsFilepattern = "externals.%s.json" )
View Source
const ( DriverChatGPT = "chatgpt" DriverDALLE = "dalle" DriverUnsplash = "unsplash" DriverWordpress = "wordpress" )
View Source
const ( EventOnIncomingMessage = "on_incoming_message" EventOnOutgoingMessage = "on_outgoing_message" )
View Source
const ( EventOnScheduled = "on_scheduler_new" // emitted from scheduler EventOnArticleToPublish = "on_copywriter_new" // emitted from copywriter EventOnArticlePublished = "on_publisher_new" // emitted from publisher )
View Source
const (
DriverTelegram = "telegram"
)
Variables ¶
View Source
var ( ErrorDriverNotSupported = errors.New("driver_not_supported") ErrorMissingToken = errors.New("missing_token") ErrorMissingConnection = errors.New("missing_connection") )
View Source
var (
BotoloDbCryptoKey = ""
)
Functions ¶
func DetectLanguage ¶
func GetChatUserUID ¶
func GetChatbotRoot ¶
func GetFilenameSettings ¶
func SplitKeywords ¶
func SummarizeTextFile ¶
func ToArrayOfMap ¶
Types ¶
type BotMessage ¶
type BotMessage struct { UserID uint // internal user id UserLang string // internal user lang Driver string FromID string MessageID string ReplyToMessageID string // set only if a replyTo is required ChatID string // id of the chat where message live Text string Date time.Time }
func (*BotMessage) CreateReplyTo ¶
func (instance *BotMessage) CreateReplyTo() *BotMessage
func (*BotMessage) CreateResponse ¶
func (instance *BotMessage) CreateResponse() *BotMessage
type IBot ¶
type IBot interface { Uid() string Name() string String() string Start() (err error) Stop() (err error) IsDebug() bool ClearHandlers() SetHandlers(handlers []MessageHandler) AddHandler(handler MessageHandler) }
type IPublisher ¶
type MessageHandler ¶
type MessageHandler func(bot IBot, message *BotMessage) (handled bool, response *BotMessage)
type SettingsBot ¶
type SettingsBot struct { Bots []*SettingsBotInfo `json:"bots"` Externals []*SettingsExternal `json:"externals"` }
func (*SettingsBot) HasExternal ¶
func (instance *SettingsBot) HasExternal(uid string) (response bool, item *SettingsExternal)
func (*SettingsBot) Map ¶
func (instance *SettingsBot) Map() map[string]interface{}
func (*SettingsBot) String ¶
func (instance *SettingsBot) String() string
type SettingsBotInfo ¶
type SettingsBotInfo struct { Uid string `json:"uid"` DbDriver string `json:"db-driver"` DbDsn string `json:"db-dsn"` Driver string `json:"driver"` Name string `json:"name"` Username string `json:"username"` Token string `json:"token"` Fallback string `json:"fallback"` // file or external Externals []*SettingsExternal `json:"externals"` }
SettingsBotInfo
{ "bots": [ { "uid": "telegram-botolo", "driver": "telegram", "name": "botolo", "username": "mybotolo_bot", "token": "-" } ] }
func (*SettingsBotInfo) GetDbDsn ¶
func (instance *SettingsBotInfo) GetDbDsn() string
func (*SettingsBotInfo) HasExternal ¶
func (instance *SettingsBotInfo) HasExternal(uid string) (response bool, item *SettingsExternal)
type SettingsExternal ¶
type SettingsExternal struct { Uid string `json:"uid"` Driver string `json:"driver"` User string `json:"user"` Password string `json:"password"` Token string `json:"token"` Payload map[string]interface{} `json:"payload"` }
{ "uid": "openai_chatgpt", "driver": "chatgpt", "user": "", "password": "", "token": "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" }
Click to show internal directories.
Click to hide internal directories.