Documentation
¶
Index ¶
- Constants
- func AwaitingReplyToPath(awaitingReplyTo string) string
- func AwaitingReplyToQuery(awaitingReplyTo string) string
- func NewChatID(botID, botChatID string) string
- type AppUserAdapter
- type AppUserData
- type BotBaseData
- type BotChatData
- type ChatBaseData
- func (e *ChatBaseData) AddClientLanguage(languageCode string) (changed bool)
- func (e *ChatBaseData) AddWizardParam(key, value string)
- func (e *ChatBaseData) Base() *ChatBaseData
- func (v *ChatBaseData) DelVar(key string)
- func (e *ChatBaseData) GetAwaitingReplyTo() string
- func (e *ChatBaseData) GetPreferredLanguage() string
- func (v *ChatBaseData) GetVar(key string) string
- func (e *ChatBaseData) GetWizardParam(key string) string
- func (v *ChatBaseData) HasChangedVars() bool
- func (e *ChatBaseData) IsAwaitingReplyTo(code string) bool
- func (e *ChatBaseData) IsChanged() bool
- func (e *ChatBaseData) IsGroupChat() bool
- func (e *ChatBaseData) PopStepsFromAwaitingReplyUpToSpecificParent(step string)
- func (e *ChatBaseData) PushStepToAwaitingReplyTo(step string)
- func (e *ChatBaseData) SetAwaitingReplyTo(value string)
- func (e *ChatBaseData) SetBotUserID(id interface{})
- func (e *ChatBaseData) SetDtLastInteraction(v time.Time)
- func (e *ChatBaseData) SetDtUpdateToNow()
- func (e *ChatBaseData) SetIsGroupChat(v bool)
- func (e *ChatBaseData) SetPreferredLanguage(value string)
- func (v *ChatBaseData) SetVar(key, value string)
- func (e *ChatBaseData) Validate() error
- type ChatKey
- type PlatformUserBaseDbo
- type PlatformUserData
- type PreferredLocaleHolder
- type UserNamesHolder
- type WithAccessGrantedFlag
- type WithBotIDs
- type WithBotUserIDs
- type WithRequiredBotIDs
Constants ¶
const ( // AwaitingReplyToPathSeparator separates parts of the command state AwaitingReplyToPathSeparator = "/" // AwaitingReplyToPath2QuerySeparator separates path and query parts of state AwaitingReplyToPath2QuerySeparator = "?" // AwaitingReplyToParamsSeparator separates params of command state AwaitingReplyToParamsSeparator = "&" )
Variables ¶
This section is empty.
Functions ¶
func AwaitingReplyToPath ¶
AwaitingReplyToPath returns just path part of command state
func AwaitingReplyToQuery ¶
AwaitingReplyToQuery returns just query part of command state
Types ¶
type AppUserAdapter ¶ added in v0.4.0
type AppUserAdapter interface { // SetBotUserID associates bot user ID with an app user record SetBotUserID(platform, botID, botUserID string) // UserNamesHolder is an interface to set and get user's names. UserNamesHolder // PreferredLocaleHolder is an interface to set and get preferred locale PreferredLocaleHolder }
type AppUserData ¶ added in v0.0.5
type AppUserData interface { // BotsFwAdapter returns to bots framework an adapter to app user data record. // Using an adapter ensures there is no clashes between bots framework interfaces and app user struct. BotsFwAdapter() AppUserAdapter }
AppUserData is a record where information about app user is stored. Bots can use it to store information about a user like names, preferred locale.
type BotBaseData ¶
type BotBaseData struct { //user.OwnedByUserWithID AppUserID string `json:"appUserID" firestore:"appUserID"` // intentionally indexed & do NOT omitempty (so we can find records with empty AppUserID) DtCreated time.Time `json:"dtCreated" datastore:"dtCreated" firestore:"dtCreated"` DtUpdated time.Time `json:"dtUpdated" datastore:"dtUpdated" firestore:"dtUpdated"` // AccessGranted indicates if access to the bot has been granted AccessGranted bool `json:"isAccessGranted" dalgo:"isAccessGranted" datastore:"isAccessGranted" firestore:"isAccessGranted"` }
BotBaseData holds properties common to all bot entities
func (*BotBaseData) GetAppUserID ¶ added in v0.0.5
func (e *BotBaseData) GetAppUserID() string
GetAppUserID returns app user ID
func (*BotBaseData) IsAccessGranted ¶
func (e *BotBaseData) IsAccessGranted() bool
IsAccessGranted indicates if access to the bot has been granted
func (*BotBaseData) SetAccessGranted ¶
func (e *BotBaseData) SetAccessGranted(value bool) bool
SetAccessGranted mark that access has been granted
func (*BotBaseData) SetAppUserID ¶ added in v0.0.5
func (e *BotBaseData) SetAppUserID(s string)
SetAppUserID sets app user ID
func (*BotBaseData) SetUpdatedTime ¶ added in v0.0.5
func (e *BotBaseData) SetUpdatedTime(v time.Time)
SetUpdatedTime sets updated time
func (*BotBaseData) Validate ¶ added in v0.0.5
func (e *BotBaseData) Validate() error
Validate returns error if data is invalid
type BotChatData ¶ added in v0.1.0
type BotChatData interface { // Base returns a base struct that should be included in all structs that implement BotChatData. Base() *ChatBaseData // TODO: Document why this is needed or remove // IsChanged returns true if data has been changed IsChanged() bool // GetAppUserID returns app user ID GetAppUserID() (appUserID string) // SetAppUserID sets app user ID SetAppUserID(appUserID string) // AddClientLanguage adds client language AddClientLanguage(languageCode string) (changed bool) // SetBotUserID sets bot user ID SetBotUserID(id interface{}) // SetIsGroupChat marks current chat as a group chat SetIsGroupChat(bool) // IsAccessGranted returns true if access is granted IsAccessGranted() bool // IsGroupChat returns true if current chat is a group chat IsGroupChat() bool // SetAccessGranted sets access granted flag SetAccessGranted(value bool) bool // GetPreferredLanguage returns preferred language for the chat GetPreferredLanguage() string // SetPreferredLanguage sets preferred language for the chat SetPreferredLanguage(value string) // SetUpdatedTime sets updated time SetUpdatedTime(time.Time) // github.com/strongo/user.UpdatedTimeSetter // SetDtLastInteraction sets last interaction time SetDtLastInteraction(time time.Time) // GetAwaitingReplyTo returns path of the step that is awaiting reply to GetAwaitingReplyTo() string // SetAwaitingReplyTo sets path of the step that is awaiting reply to SetAwaitingReplyTo(path string) // IsAwaitingReplyTo returns true if awaiting reply to specific step IsAwaitingReplyTo(code string) bool // AddWizardParam adds a parameter to wizard with a given key & value AddWizardParam(key, value string) // GetWizardParam returns a parameter from wizard for a given key GetWizardParam(key string) string // PopStepsFromAwaitingReplyUpToSpecificParent pops steps from awaiting reply up to specific parent PopStepsFromAwaitingReplyUpToSpecificParent(code string) // PushStepToAwaitingReplyTo pushes step to awaiting reply to PushStepToAwaitingReplyTo(code string) SetVar(key string, value string) GetVar(key string) string DelVar(key string) HasChangedVars() bool }
BotChatData provides data about bot chat
type ChatBaseData ¶ added in v0.0.5
type ChatBaseData struct { // BotUserIDs keeps ids of bot users who are members of a group chat or a single user ID if it's a chat with bot BotUserIDs []string `firestore:"botUserIDs,omitempty"` BotBaseData // IsGroup indicates if bot is added/used in a group chat IsGroup bool `firestore:"isGroup,omitempty"` Type string `firestore:"type,omitempty"` // TODO: document what is it & why needed or remove // Title stores a title of a chat if bot platforms supports named chats Title string `firestore:"title,omitempty"` // AnalyticsClientIDs stores IDs of analytics clients. For example {"GA": "1234567890.1234567890"} AnalyticsClientIDs map[string]string `firestore:"analyticsClientIDs,omitempty"` // DtLastInteraction must be set through SetDtLastInteraction() as it also increments InteractionsCount DtLastInteraction time.Time `firestore:"dtLastInteraction"` // InteractionsCount is a number of interactions with a bot in this chat InteractionsCount int `firestore:"interactionsCount,omitempty"` // DtForbidden is a time when bot was forbidden to interact with a chat DtForbidden time.Time `firestore:"dtForbidden,omitempty"` // DtForbiddenLast needs documentation on intended usage. TODO: Consider removing DtForbiddenLast time.Time `dalgo:",omitempty" datastore:",omitempty" firestore:",omitempty"` // contains filtered or unexported fields }
ChatBaseData hold common properties for bot chat entities not specific to any platform
func (*ChatBaseData) AddClientLanguage ¶ added in v0.0.5
AddClientLanguage adds client UI language
func (*ChatBaseData) AddWizardParam ¶ added in v0.0.5
func (e *ChatBaseData) AddWizardParam(key, value string)
AddWizardParam adds context param to state
func (*ChatBaseData) Base ¶ added in v0.0.5
func (e *ChatBaseData) Base() *ChatBaseData
func (*ChatBaseData) DelVar ¶ added in v0.10.0
func (v *ChatBaseData) DelVar(key string)
DelVar deletes a chat variable
func (*ChatBaseData) GetAwaitingReplyTo ¶ added in v0.0.5
func (e *ChatBaseData) GetAwaitingReplyTo() string
GetAwaitingReplyTo returns current state
func (*ChatBaseData) GetPreferredLanguage ¶ added in v0.0.5
func (e *ChatBaseData) GetPreferredLanguage() string
GetPreferredLanguage returns preferred language
func (*ChatBaseData) GetWizardParam ¶ added in v0.0.5
GetWizardParam returns state param value
func (*ChatBaseData) HasChangedVars ¶ added in v0.10.0
func (v *ChatBaseData) HasChangedVars() bool
HasChangedVars returns true if vars have been changed
func (*ChatBaseData) IsAwaitingReplyTo ¶ added in v0.0.5
IsAwaitingReplyTo returns true if bot us awaiting reply to a specific command
func (*ChatBaseData) IsChanged ¶ added in v0.0.5
func (e *ChatBaseData) IsChanged() bool
IsChanged indicates that chat data has been changed and record needs to be saved
func (*ChatBaseData) IsGroupChat ¶ added in v0.0.5
func (e *ChatBaseData) IsGroupChat() bool
IsGroupChat indicates if it is a group chat
func (*ChatBaseData) PopStepsFromAwaitingReplyUpToSpecificParent ¶ added in v0.0.5
func (e *ChatBaseData) PopStepsFromAwaitingReplyUpToSpecificParent(step string)
PopStepsFromAwaitingReplyUpToSpecificParent go back in state
func (*ChatBaseData) PushStepToAwaitingReplyTo ¶ added in v0.0.5
func (e *ChatBaseData) PushStepToAwaitingReplyTo(step string)
PushStepToAwaitingReplyTo go down in state
func (*ChatBaseData) SetAwaitingReplyTo ¶ added in v0.0.5
func (e *ChatBaseData) SetAwaitingReplyTo(value string)
SetAwaitingReplyTo sets current state
func (*ChatBaseData) SetBotUserID ¶ added in v0.0.5
func (e *ChatBaseData) SetBotUserID(id interface{})
SetBotUserID sets bot user ID
func (*ChatBaseData) SetDtLastInteraction ¶ added in v0.0.5
func (e *ChatBaseData) SetDtLastInteraction(v time.Time)
SetDtLastInteraction sets date time of last interaction
func (*ChatBaseData) SetDtUpdateToNow ¶ added in v0.0.5
func (e *ChatBaseData) SetDtUpdateToNow()
SetDtUpdateToNow mark entity updated with now
func (*ChatBaseData) SetIsGroupChat ¶ added in v0.0.5
func (e *ChatBaseData) SetIsGroupChat(v bool)
SetIsGroupChat marks chat as a group one
func (*ChatBaseData) SetPreferredLanguage ¶ added in v0.0.5
func (e *ChatBaseData) SetPreferredLanguage(value string)
SetPreferredLanguage sets preferred language
func (*ChatBaseData) SetVar ¶ added in v0.10.0
func (v *ChatBaseData) SetVar(key, value string)
SetVar sets a chat variable
func (*ChatBaseData) Validate ¶ added in v0.0.5
func (e *ChatBaseData) Validate() error
type ChatKey ¶ added in v0.0.5
type ChatKey struct { // BotID an id of a bot that owns this chat BotID string // ChatID is an id of a chat as was provided by a bot platform. Might be an integer converted to a string. // It's different from ChatInstanceID of Telegram - TODO: document what is the difference an why ChatInstanceID is needed. ChatID string }
ChatKey is a key for a chat that consists of bot ID and chat ID.
func NewChatKey ¶ added in v0.0.5
NewChatKey creates a new chat key
type PlatformUserBaseDbo ¶ added in v0.7.0
type PlatformUserBaseDbo struct { BotBaseData WithRequiredBotIDs // FirstName is the first name of a user FirstName string `json:"firstName,omitempty" dalgo:"firstName,omitempty,noindex" firestore:"firstName,omitempty"` // LastName is the last name of a user LastName string `json:"lastName,omitempty" dalgo:"lastName,omitempty,noindex" firestore:"lastName,omitempty"` // UserName is login ID of a user UserName string `json:"userName,omitempty" dalgo:"userName,omitempty,noindex" firestore:"userName,omitempty"` }
PlatformUserBaseDbo hold common properties for bot user entities
func (*PlatformUserBaseDbo) BaseData ¶ added in v0.7.0
func (v *PlatformUserBaseDbo) BaseData() *PlatformUserBaseDbo
BaseData returns base data of a user that should be included in all structs that implement PlatformUserData
func (*PlatformUserBaseDbo) Validate ¶ added in v0.9.0
func (v *PlatformUserBaseDbo) Validate() error
type PlatformUserData ¶ added in v0.7.0
type PlatformUserData interface { // BaseData returns base data that should be implemented by all bot user structs BaseData() *PlatformUserBaseDbo // GetAppUserID returns app user ID if available GetAppUserID() string // SetAppUserID sets app user ID to associate bot user record with app user SetAppUserID(appUserID string) WithAccessGrantedFlag // SetUpdatedTime sets last updated time // TODO: document intended usage SetUpdatedTime(time.Time) //to satisfy github.com/strongo/app/user.UpdatedTimeSetter }
PlatformUserData interface provides information about bot user This should be implemented by bot user record struct.
type PreferredLocaleHolder ¶ added in v0.3.0
type UserNamesHolder ¶ added in v0.3.0
type WithAccessGrantedFlag ¶
type WithBotIDs ¶ added in v0.9.0
type WithBotIDs struct {
BotIDs []string `json:"botIDs,omitempty" dalgo:"botIDs,omitempty,noindex" firestore:"botIDs,omitempty"`
}
func (WithBotIDs) Validate ¶ added in v0.9.0
func (v WithBotIDs) Validate() error
type WithBotUserIDs ¶ added in v0.1.1
type WithBotUserIDs struct {
BotUserIDs []string `json:"botUserIDs,omitempty" firestore:"botUserIDs,omitempty" dalgo:"botUserIDs,omitempty"`
}
func (*WithBotUserIDs) SetBotUserID ¶ added in v0.1.1
func (v *WithBotUserIDs) SetBotUserID(platform, bot, userID string)
func (*WithBotUserIDs) Validate ¶ added in v0.9.0
func (v *WithBotUserIDs) Validate() error
type WithRequiredBotIDs ¶ added in v0.9.0
type WithRequiredBotIDs WithBotIDs
func (WithRequiredBotIDs) Validate ¶ added in v0.9.0
func (v WithRequiredBotIDs) Validate() error