Documentation ¶
Index ¶
- Constants
- Variables
- func AwaitingReplyToPath(awaitingReplyTo string) string
- func AwaitingReplyToQuery(awaitingReplyTo string) string
- func CommandTextNoTrans(title, icon string) string
- func NewChatID(botID, botChatID string) string
- func NotFoundHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
- func PingHandler(w http.ResponseWriter, r *http.Request)
- func SetAccessGranted(whc WebhookContext, value bool) (err error)
- type AnalyticsSettings
- type Attachment
- type AttachmentType
- type BaseHandler
- func (j *BaseHandler) MarshalJSON() ([]byte, error)
- func (j *BaseHandler) MarshalJSONBuf(buf fflib.EncodingBuffer) error
- func (bh *BaseHandler) Register(d WebhookDriver, h BotHost)
- func (j *BaseHandler) UnmarshalJSON(input []byte) error
- func (j *BaseHandler) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
- type BotAPISendMessageChannel
- type BotAPIUser
- type BotAppContext
- type BotAppUser
- type BotAppUserStore
- type BotChat
- type BotChatEntity
- func (e *BotChatEntity) AddClientLanguage(languageCode string) (changed bool)
- func (e *BotChatEntity) AddWizardParam(key, value string)
- func (e *BotChatEntity) GetAwaitingReplyTo() string
- func (e *BotChatEntity) GetBotID() string
- func (e *BotChatEntity) GetGaClientID() uuid.UUID
- func (e *BotChatEntity) GetPreferredLanguage() string
- func (e *BotChatEntity) GetWizardParam(key string) string
- func (e *BotChatEntity) IsAwaitingReplyTo(code string) bool
- func (e *BotChatEntity) IsGroupChat() bool
- func (e *BotChatEntity) PopStepsFromAwaitingReplyUpToSpecificParent(step string)
- func (e *BotChatEntity) PushStepToAwaitingReplyTo(step string)
- func (e *BotChatEntity) SetAwaitingReplyTo(value string)
- func (e *BotChatEntity) SetBotID(botID string)
- func (e *BotChatEntity) SetBotUserID(id interface{})
- func (e *BotChatEntity) SetDtLastInteraction(v time.Time)
- func (e *BotChatEntity) SetDtUpdateToNow()
- func (e *BotChatEntity) SetIsGroupChat(v bool)
- func (e *BotChatEntity) SetPreferredLanguage(value string)
- type BotChatStore
- type BotContext
- type BotCoreStores
- type BotDriver
- type BotEntity
- type BotHost
- type BotInputProvider
- type BotMessage
- type BotMessageType
- type BotPlatform
- type BotSettings
- type BotState
- type BotUser
- type BotUserEntity
- type BotUserStore
- type CallbackAction
- type ChatIntID
- type ChatUID
- type Command
- type CommandAction
- type CommandMatcher
- type EntryInput
- type EntryInputs
- type ErrAuthFailed
- type GaContext
- type GaQueuer
- type InputMessage
- type Keyboard
- type KeyboardType
- type MessageFormat
- type MessageFromBot
- type MessageUID
- type MessengerResponse
- type OnMessageSentResponse
- type SettingsBy
- type SettingsProvider
- type TextMessageFromBot
- func (m TextMessageFromBot) BotMessageType() BotMessageType
- func (j *TextMessageFromBot) MarshalJSON() ([]byte, error)
- func (j *TextMessageFromBot) MarshalJSONBuf(buf fflib.EncodingBuffer) error
- func (j *TextMessageFromBot) UnmarshalJSON(input []byte) error
- func (j *TextMessageFromBot) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
- type TranslatorProvider
- type TypeCommands
- type WebhookActor
- type WebhookAttachment
- type WebhookAudioMessage
- type WebhookCallbackQuery
- type WebhookChat
- type WebhookChosenInlineResult
- type WebhookContactMessage
- type WebhookContext
- type WebhookContextBase
- func (whcb *WebhookContextBase) AppUserEntity() BotAppUser
- func (whcb *WebhookContextBase) AppUserIntID() (appUserIntID int64)
- func (whcb *WebhookContextBase) AppUserStrID() string
- func (whcb *WebhookContextBase) BotAppContext() BotAppContext
- func (whcb *WebhookContextBase) BotChatID() (botChatID string, err error)
- func (whcb *WebhookContextBase) BotContext() BotContext
- func (whcb *WebhookContextBase) BotPlatform() BotPlatform
- func (whcb *WebhookContextBase) Chat() WebhookChat
- func (whcb *WebhookContextBase) ChatEntity() BotChat
- func (whcb *WebhookContextBase) CommandText(title, icon string) string
- func (whcb *WebhookContextBase) Context() context.Context
- func (whcb *WebhookContextBase) Environment() strongo.Environment
- func (whcb *WebhookContextBase) ExecutionContext() strongo.ExecutionContext
- func (whcb *WebhookContextBase) GA() GaContext
- func (whcb *WebhookContextBase) GetAppUser() (BotAppUser, error)
- func (whcb *WebhookContextBase) GetBotCode() string
- func (whcb *WebhookContextBase) GetBotSettings() BotSettings
- func (whcb *WebhookContextBase) GetBotToken() string
- func (whcb *WebhookContextBase) GetOrCreateBotUserEntityBase() (BotUser, error)
- func (whcb *WebhookContextBase) GetRecipient() WebhookRecipient
- func (whcb *WebhookContextBase) GetSender() WebhookSender
- func (whcb *WebhookContextBase) GetTime() time.Time
- func (whcb *WebhookContextBase) HasChatEntity() bool
- func (whcb *WebhookContextBase) Input() WebhookInput
- func (whcb *WebhookContextBase) InputType() WebhookInputType
- func (whcb *WebhookContextBase) IsInGroup() bool
- func (whcb *WebhookContextBase) IsInTransaction(c context.Context) bool
- func (whcb WebhookContextBase) Locale() strongo.Locale
- func (whcb *WebhookContextBase) LogRequest()
- func (whcb *WebhookContextBase) MessageText() string
- func (whcb *WebhookContextBase) MustBotChatID() (chatID string)
- func (whcb *WebhookContextBase) NewMessage(text string) (m MessageFromBot)
- func (whcb *WebhookContextBase) NewMessageByCode(messageCode string, a ...interface{}) (m MessageFromBot)
- func (whcb *WebhookContextBase) NonTransactionalContext(tc context.Context) context.Context
- func (whcb *WebhookContextBase) Request() *http.Request
- func (whcb *WebhookContextBase) RunInTransaction(c context.Context, f func(c context.Context) error, options db.RunOptions) error
- func (whcb *WebhookContextBase) SetChatEntity(chatEntity BotChat)
- func (whcb *WebhookContextBase) SetChatID(v string)
- func (whcb *WebhookContextBase) SetContext(c context.Context)
- func (whcb *WebhookContextBase) SetLocale(code5 string) error
- func (whcb *WebhookContextBase) Translate(key string, args ...interface{}) string
- func (whcb *WebhookContextBase) TranslateNoWarning(key string, args ...interface{}) string
- type WebhookConversationStarted
- type WebhookDelivery
- type WebhookDriver
- type WebhookEntry
- type WebhookHandler
- type WebhookInlineQuery
- type WebhookInlineQueryContext
- type WebhookInput
- type WebhookInputType
- type WebhookLeftChatMembersMessage
- type WebhookMessage
- type WebhookNewChatMembersMessage
- type WebhookNewContext
- type WebhookPhotoMessage
- type WebhookPostback
- type WebhookRecipient
- type WebhookReferralMessage
- type WebhookResponder
- type WebhookSender
- type WebhookStickerMessage
- type WebhookSubscribed
- type WebhookTextMessage
- type WebhookUnsubscribed
- type WebhookUser
- type WebhookVoiceMessage
- type WebhooksRouter
- func (router *WebhooksRouter) AddCommands(commandsType WebhookInputType, commands []Command)
- func (router WebhooksRouter) CommandsCount() int
- func (router *WebhooksRouter) Dispatch(webhookHandler WebhookHandler, responder WebhookResponder, whc WebhookContext)
- func (router *WebhooksRouter) DispatchInlineQuery(responder WebhookResponder)
- func (router *WebhooksRouter) RegisterCommands(commands []Command)
Constants ¶
const ( // MessageTextBotDidNotUnderstandTheCommand is an i18n constant MessageTextBotDidNotUnderstandTheCommand = "MessageTextBotDidNotUnderstandTheCommand" // MessageTextOopsSomethingWentWrong is an i18n constant MessageTextOopsSomethingWentWrong = "MessageTextOopsSomethingWentWrong" )
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 = "&" )
const ( // BotAPISendMessageOverHTTPS indicates message should be sent over HTTPS BotAPISendMessageOverHTTPS = BotAPISendMessageChannel("https") // BotAPISendMessageOverResponse indicates message should be sent in HTTP response BotAPISendMessageOverResponse = BotAPISendMessageChannel("response") )
const DefaultTitle = "" //
DefaultTitle key
const NoMessageToSend = "<NO_MESSAGE_TO_SEND>"
NoMessageToSend returned explicitly if we don't want to reply to user intput
const ShortTitle = "short_title"
ShortTitle key
Variables ¶
var ( // ErrEntityNotFound is returned if entity not found in storage ErrEntityNotFound = errors.New("bots-framework: no such entity") )
var ErrNoCommandsMatched = errors.New("no commands matched")
var ErrNotImplemented = errors.New("Not implemented")
ErrNotImplemented if some feature is not implemented yet
var ErrorIcon = "🚨"
ErrorIcon is used to report errors to user
var IgnoreCommand = Command{ Code: "bots.IgnoreCommand", Action: func(_ WebhookContext) (m MessageFromBot, err error) { return }, CallbackAction: func(_ WebhookContext, _ *url.URL) (m MessageFromBot, err error) { return }, }
IgnoreCommand is a command that does nothing
var WebhookInputTypeNames = map[WebhookInputType]string{ WebhookInputUnknown: "unknown", WebhookInputNotImplemented: "not implemented", WebhookInputReferral: "Referral", WebhookInputText: "Text", WebhookInputContact: "Contact", WebhookInputPostback: "Postback", WebhookInputDelivery: "Delivery", WebhookInputAttachment: "Attachment", WebhookInputInlineQuery: "InlineQuery", WebhookInputCallbackQuery: "CallbackQuery", WebhookInputChosenInlineResult: "ChosenInlineResult", WebhookInputSubscribed: "Subscribed", WebhookInputUnsubscribed: "Unsubscribed", WebhookInputConversationStarted: "ConversationStarted", WebhookInputNewChatMembers: "NewChatMembers", }
WebhookInputTypeNames names for input type
Functions ¶
func AwaitingReplyToPath ¶
AwaitingReplyToPath returns just path part of command state
func AwaitingReplyToQuery ¶
AwaitingReplyToQuery returns just query part of command state
func CommandTextNoTrans ¶
CommandTextNoTrans returns a title for a command (pre-translated)
func NotFoundHandler ¶
func NotFoundHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params)
NotFoundHandler returns HTTP status code 404
func PingHandler ¶
func PingHandler(w http.ResponseWriter, r *http.Request)
PingHandler returns 'Pong' back to user
func SetAccessGranted ¶
func SetAccessGranted(whc WebhookContext, value bool) (err error)
SetAccessGranted marks current context as authenticated
Types ¶
type AnalyticsSettings ¶
type AnalyticsSettings struct { GaTrackingID string // TODO: Refactor to list of analytics providers Enabled func(r *http.Request) bool }
AnalyticsSettings keeps data for Google Analytics
type Attachment ¶
type Attachment interface {
AttachmentType() AttachmentType
}
Attachment to a bot message
type AttachmentType ¶
type AttachmentType int
AttachmentType to a bot message
const ( // AttachmentTypeNone says there is no attachment AttachmentTypeNone AttachmentType = iota // AttachmentTypeAudio is for audio attachments AttachmentTypeAudio // AttachmentTypeFile is for file attachments AttachmentTypeFile // AttachmentTypeImage is for image attachments AttachmentTypeImage // AttachmentTypeVideo is for video attachments AttachmentTypeVideo )
type BaseHandler ¶
type BaseHandler struct { WebhookDriver BotHost BotPlatform TranslatorProvider TranslatorProvider }
BaseHandler provides base implemnetation of a bot handler
func (*BaseHandler) MarshalJSON ¶
func (j *BaseHandler) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*BaseHandler) MarshalJSONBuf ¶
func (j *BaseHandler) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*BaseHandler) Register ¶
func (bh *BaseHandler) Register(d WebhookDriver, h BotHost)
Register driver
func (*BaseHandler) UnmarshalJSON ¶
func (j *BaseHandler) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*BaseHandler) UnmarshalJSONFFLexer ¶
func (j *BaseHandler) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
UnmarshalJSONFFLexer fast json unmarshall - template ffjson
type BotAPISendMessageChannel ¶
type BotAPISendMessageChannel string
BotAPISendMessageChannel specifies messenger channel
type BotAPIUser ¶
type BotAPIUser interface { //IdAsString() string //IdAsInt64() int64 FirstName() string LastName() string }
BotAPIUser provides info about current bot user
type BotAppContext ¶
type BotAppContext interface { strongo.AppContext NewBotAppUserEntity() BotAppUser GetBotChatEntityFactory(platform string) func() BotChat }
BotAppContext is a context for bot app
type BotAppUser ¶
type BotAppUser interface { strongo.AppUser //GetAppUserIntID() int64 SetBotUserID(platform, botID, botUserID string) GetFullName() string }
BotAppUser holds information about bot app user
type BotAppUserStore ¶
type BotAppUserStore interface { GetAppUserByID(c context.Context, appUserID int64, appUser BotAppUser) error CreateAppUser(c context.Context, botID string, actor WebhookActor) (appUserID int64, appUserEntity BotAppUser, err error) }
BotAppUserStore interface for storing user information to persistent store
type BotChat ¶
type BotChat interface { GetBotID() string SetBotID(botID string) GetAppUserIntID() int64 SetAppUserIntID(id int64) AddClientLanguage(languageCode string) (changed bool) //GetBotUserIntID() int //GetBotUserStringID() string SetBotUserID(id interface{}) SetIsGroupChat(bool) IsAccessGranted() bool IsGroupChat() bool SetAccessGranted(value bool) bool GetPreferredLanguage() string SetPreferredLanguage(value string) user.UpdatedTimeSetter SetDtLastInteraction(time time.Time) GetAwaitingReplyTo() string SetAwaitingReplyTo(path string) IsAwaitingReplyTo(code string) bool AddWizardParam(key, value string) GetWizardParam(key string) string PopStepsFromAwaitingReplyUpToSpecificParent(code string) PushStepToAwaitingReplyTo(code string) GetGaClientID() uuid.UUID }
BotChat provides data about bot chat
type BotChatEntity ¶
type BotChatEntity struct { BotEntity AppUserIntIDs []int64 BotID string `datastore:",noindex"` // IsGroup bool `datastore:",noindex,omitempty"` Type string `datastore:",noindex,omitempty"` Title string `datastore:",noindex,omitempty"` // AwaitingReplyTo string `datastore:",noindex,omitempty"` PreferredLanguage string `datastore:",noindex,omitempty"` GaClientID []byte `datastore:",noindex,omitempty"` DtLastInteraction time.Time `datastore:",omitempty"` InteractionsCount int `datastore:",omitempty"` DtForbidden time.Time `datastore:",omitempty"` DtForbiddenLast time.Time `datastore:",noindex,omitempty"` LanguageCodes []string `datastore:",noindex"` // UI languages }
BotChatEntity hold common properties for bot chat entities
func (*BotChatEntity) AddClientLanguage ¶
func (e *BotChatEntity) AddClientLanguage(languageCode string) (changed bool)
AddClientLanguage adds client UI language
func (*BotChatEntity) AddWizardParam ¶
func (e *BotChatEntity) AddWizardParam(key, value string)
AddWizardParam adds context param to state
func (*BotChatEntity) GetAwaitingReplyTo ¶
func (e *BotChatEntity) GetAwaitingReplyTo() string
GetAwaitingReplyTo returns current state
func (*BotChatEntity) GetGaClientID ¶
func (e *BotChatEntity) GetGaClientID() uuid.UUID
GetGaClientID returns Google Analytics client UUID
func (*BotChatEntity) GetPreferredLanguage ¶
func (e *BotChatEntity) GetPreferredLanguage() string
GetPreferredLanguage returns preferred language
func (*BotChatEntity) GetWizardParam ¶
func (e *BotChatEntity) GetWizardParam(key string) string
GetWizardParam returns state param value
func (*BotChatEntity) IsAwaitingReplyTo ¶
func (e *BotChatEntity) IsAwaitingReplyTo(code string) bool
IsAwaitingReplyTo returns true if bot us awaiting reply to a specific command
func (*BotChatEntity) IsGroupChat ¶
func (e *BotChatEntity) IsGroupChat() bool
IsGroupChat indicates if it is a group chat
func (*BotChatEntity) PopStepsFromAwaitingReplyUpToSpecificParent ¶
func (e *BotChatEntity) PopStepsFromAwaitingReplyUpToSpecificParent(step string)
PopStepsFromAwaitingReplyUpToSpecificParent go back in state
func (*BotChatEntity) PushStepToAwaitingReplyTo ¶
func (e *BotChatEntity) PushStepToAwaitingReplyTo(step string)
PushStepToAwaitingReplyTo go down in state
func (*BotChatEntity) SetAwaitingReplyTo ¶
func (e *BotChatEntity) SetAwaitingReplyTo(value string)
SetAwaitingReplyTo sets current state
func (*BotChatEntity) SetBotID ¶
func (e *BotChatEntity) SetBotID(botID string)
SetBotID sets bot ID
func (*BotChatEntity) SetBotUserID ¶
func (e *BotChatEntity) SetBotUserID(id interface{})
SetBotUserID sets bot user ID
func (*BotChatEntity) SetDtLastInteraction ¶
func (e *BotChatEntity) SetDtLastInteraction(v time.Time)
SetDtLastInteraction sets date time of last interaction
func (*BotChatEntity) SetDtUpdateToNow ¶
func (e *BotChatEntity) SetDtUpdateToNow()
SetDtUpdateToNow mark entity updated with now
func (*BotChatEntity) SetIsGroupChat ¶
func (e *BotChatEntity) SetIsGroupChat(v bool)
SetIsGroupChat marks chat as a group one
func (*BotChatEntity) SetPreferredLanguage ¶
func (e *BotChatEntity) SetPreferredLanguage(value string)
SetPreferredLanguage sets preferred language
type BotChatStore ¶
type BotChatStore interface { GetBotChatEntityByID(c context.Context, botID, botChatID string) (BotChat, error) SaveBotChat(c context.Context, botID, botChatID string, chatEntity BotChat) error NewBotChatEntity(c context.Context, botID string, botChat WebhookChat, appUserID int64, botUserID string, isAccessGranted bool) BotChat Close(c context.Context) error // TODO: Was io.Closer, should it? }
BotChatStore is interface for DAL to store bot chat data
type BotContext ¶
type BotContext struct { // TODO: Rename to BotWebhookContext or just WebhookContext (replace old one) BotHost BotHost BotSettings BotSettings }
botContext describes current bot app host & settings
func NewBotContext ¶
func NewBotContext(host BotHost, settings BotSettings) *BotContext
NewBotContext creates current bot host & settings
type BotCoreStores ¶
type BotCoreStores struct { BotChatStore BotUserStore BotAppUserStore }
BotCoreStores provides DI DAL for updating app persistent store
type BotDriver ¶
type BotDriver struct { Analytics AnalyticsSettings // contains filtered or unexported fields }
BotDriver keeps information about bots and map requests to appropriate handlers
func (BotDriver) HandleWebhook ¶
func (d BotDriver) HandleWebhook(w http.ResponseWriter, r *http.Request, webhookHandler WebhookHandler)
HandleWebhook takes and HTTP request and process it
func (BotDriver) RegisterWebhookHandlers ¶
func (d BotDriver) RegisterWebhookHandlers(httpRouter *httprouter.Router, pathPrefix string, webhookHandlers ...WebhookHandler)
RegisterWebhookHandlers adds handlers to a bot driver
type BotEntity ¶
type BotEntity struct { AccessGranted bool user.OwnedByUserWithIntID }
BotEntity holds properties common to al bot entitites
func (*BotEntity) IsAccessGranted ¶
IsAccessGranted indicates if access to the bot has been granted
func (*BotEntity) SetAccessGranted ¶
SetAccessGranted mark that access has been granted
type BotHost ¶
type BotHost interface { Context(r *http.Request) context.Context GetHTTPClient(c context.Context) *http.Client GetBotCoreStores(platform string, appContext BotAppContext, r *http.Request) BotCoreStores DB() db.Database }
BotHost describes current bot app host environment
type BotInputProvider ¶
type BotInputProvider interface {
Input() WebhookInput
}
BotInputProvider provides an input from a specific bot interface (Telegram, FB Messenger, Viber, etc.)
type BotMessage ¶
type BotMessage interface {
BotMessageType() BotMessageType
}
BotMessage is an output message from bot to user
type BotMessageType ¶
type BotMessageType int
BotMessageType defines type of an output message from bot to user
const ( // BotMessageTypeUndefined unknown type BotMessageTypeUndefined BotMessageType = iota // BotMessageTypeCallbackAnswer sends callback answer BotMessageTypeCallbackAnswer // BotMessageTypeInlineResults sends inline results BotMessageTypeInlineResults // BotMessageTypeText sends text reply BotMessageTypeText // BotMessageTypeEditMessage edit previously sent message BotMessageTypeEditMessage // BotMessageTypeLeaveChat commands messenger to kick off bot from a chat BotMessageTypeLeaveChat // BotMessageTypeExportChatInviteLink sends invite link BotMessageTypeExportChatInviteLink )
type BotPlatform ¶
BotPlatform describes current bot platform
type BotSettings ¶
type BotSettings struct { Env strongo.Environment ID string Profile string Code string Token string PaymentToken string PaymentTestToken string VerifyToken string // Used by Facebook Locale strongo.Locale Router WebhooksRouter GAToken string // TODO: Refactor tu support multiple or move out }
BotSettings keeps parameters of a bot
func NewBotSettings ¶
func NewBotSettings(mode strongo.Environment, profile, code, id, token, gaToken string, locale strongo.Locale) BotSettings
NewBotSettings configures bot application
type BotUser ¶
type BotUser interface { GetAppUserIntID() int64 IsAccessGranted() bool SetAccessGranted(value bool) bool SetAppUserIntID(appUserID int64) user.UpdatedTimeSetter }
BotUser interface provides information about bot user
type BotUserEntity ¶
type BotUserEntity struct { BotEntity user.LastLogin FirstName string // required LastName string // optional UserName string // optional }
BotUserEntity hold common properties for bot user entities
type BotUserStore ¶
type BotUserStore interface { GetBotUserByID(c context.Context, botUserID interface{}) (BotUser, error) SaveBotUser(c context.Context, botUserID interface{}, botUserEntity BotUser) error CreateBotUser(c context.Context, botID string, apiUser WebhookActor) (BotUser, error) }
BotUserStore provider to store information about bot user
type CallbackAction ¶
type CallbackAction func(whc WebhookContext, callbackUrl *url.URL) (m MessageFromBot, err error)
CallbackAction defines a callback action bot can perform in response to a callback command
type Command ¶
type Command struct { InputTypes []WebhookInputType // Instant match if != WebhookInputUnknown && == whc.InputTypes() Icon string Replies []Command Code string Title string Titles map[string]string ExactMatch string Commands []string Matcher CommandMatcher Action CommandAction CallbackAction CallbackAction }
Command defines command metadata and action
func NewCallbackCommand ¶
func NewCallbackCommand(code string, action CallbackAction) Command
NewCallbackCommand create a definition of a callback command
func NewInlineQueryCommand ¶
func NewInlineQueryCommand(code string, action CommandAction) Command
func (Command) DefaultTitle ¶
func (c Command) DefaultTitle(whc WebhookContext) string
DefaultTitle returns a default title for a command in current locale
func (Command) TitleByKey ¶
func (c Command) TitleByKey(key string, whc WebhookContext) string
TitleByKey returns a short/long title for a command in current locale
type CommandAction ¶
type CommandAction func(whc WebhookContext) (m MessageFromBot, err error)
CommandAction defines an action bot can perform in response to a command
type CommandMatcher ¶
type CommandMatcher func(Command, WebhookContext) bool
CommandMatcher returns true if action is matched to user input
type EntryInput ¶
type EntryInput struct { Entry WebhookEntry Input WebhookInput }
EntryInput provides information on parsed input from bot API request
func (*EntryInput) MarshalJSON ¶
func (j *EntryInput) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*EntryInput) MarshalJSONBuf ¶
func (j *EntryInput) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*EntryInput) UnmarshalJSON ¶
func (j *EntryInput) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*EntryInput) UnmarshalJSONFFLexer ¶
func (j *EntryInput) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
UnmarshalJSONFFLexer fast json unmarshall - template ffjson
type EntryInputs ¶
type EntryInputs struct { Entry WebhookEntry Inputs []WebhookInput }
EntryInputs provides information on parsed inputs from bot API request
func (*EntryInputs) MarshalJSON ¶
func (j *EntryInputs) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*EntryInputs) MarshalJSONBuf ¶
func (j *EntryInputs) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*EntryInputs) UnmarshalJSON ¶
func (j *EntryInputs) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*EntryInputs) UnmarshalJSONFFLexer ¶
func (j *EntryInputs) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
UnmarshalJSONFFLexer fast json unmarshall - template ffjson
type ErrAuthFailed ¶
type ErrAuthFailed string
ErrAuthFailed raised if authentication failed
func (ErrAuthFailed) Error ¶
func (e ErrAuthFailed) Error() string
type GaContext ¶
type GaContext interface { GaQueuer // Flush() error GaCommon() gamp.Common GaEvent(category, action string) *gamp.Event GaEventWithLabel(category, action, label string) *gamp.Event }
GaContext provides context to Google Analytics
type InputMessage ¶
type InputMessage interface {
Text() string
}
InputMessage represents single input message
type Keyboard ¶
type Keyboard interface { // KeyboardType defines keyboard type KeyboardType() KeyboardType }
Keyboard defines keyboard
type KeyboardType ¶
type KeyboardType int
KeyboardType defines keyboard type
const ( // KeyboardTypeNone for no keyboard KeyboardTypeNone KeyboardType = iota // KeyboardTypeHide commands to hide keyboard KeyboardTypeHide // KeyboardTypeInline for inline keyboard KeyboardTypeInline // KeyboardTypeBottom for bottom keyboard KeyboardTypeBottom // KeyboardTypeForceReply to force reply from a user KeyboardTypeForceReply )
type MessageFormat ¶
type MessageFormat int
MessageFormat specify formatting of a text message to BOT (e.g. Text, HTML, MarkDown)
const ( // MessageFormatText is for text messages MessageFormatText MessageFormat = iota // MessageFormatHTML is for HTML messages MessageFormatHTML // MessageFormatMarkdown is for markdown messages MessageFormatMarkdown )
type MessageFromBot ¶
type MessageFromBot struct { ToChat ChatUID `json:",omitempty"` TextMessageFromBot // This is a shortcut to MessageFromBot{}.BotMessage = TextMessageFromBot{text: "abc"} BotMessage BotMessage `json:",omitempty"` FbmAttachment *fbmbotapi.RequestAttachment `json:",omitempty"` // deprecated }
MessageFromBot keeps all the details of answer from bot to user
func (*MessageFromBot) MarshalJSON ¶
func (j *MessageFromBot) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*MessageFromBot) MarshalJSONBuf ¶
func (j *MessageFromBot) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*MessageFromBot) UnmarshalJSON ¶
func (j *MessageFromBot) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*MessageFromBot) UnmarshalJSONFFLexer ¶
func (j *MessageFromBot) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
UnmarshalJSONFFLexer fast json unmarshall - template ffjson
type MessageUID ¶
type MessageUID interface {
UID() string
}
MessageUID is unique message ID as string
type MessengerResponse ¶
type MessengerResponse interface { }
MessengerResponse represents response from a messenger
type OnMessageSentResponse ¶
type OnMessageSentResponse struct { StatusCode int TelegramMessage MessengerResponse // TODO: change to some interface }
OnMessageSentResponse represents response on message sent event
type SettingsBy ¶
type SettingsBy struct { // TODO: Decide if it should have map[string]*BotSettings instead of map[string]BotSettings ByCode map[string]BotSettings ByAPIToken map[string]BotSettings ByLocale map[string][]BotSettings ByID map[string]BotSettings HasRouter bool }
SettingsBy keeps settings per different keys (ID, code, API token, locale)
func NewBotSettingsBy ¶
func NewBotSettingsBy(router func(profile string) WebhooksRouter, bots ...BotSettings) SettingsBy
NewBotSettingsBy create settings per different keys (ID, code, API token, locale)
type SettingsProvider ¶
type SettingsProvider func(c context.Context) SettingsBy
SettingsProvider returns settings per different keys (ID, code, API token, locale)
type TextMessageFromBot ¶
type TextMessageFromBot struct { Text string `json:",omitempty"` Format MessageFormat `json:",omitempty"` DisableWebPagePreview bool `json:",omitempty"` DisableNotification bool `json:",omitempty"` Keyboard Keyboard `json:",omitempty"` IsEdit bool `json:",omitempty"` EditMessageUID MessageUID `json:",omitempty"` }
TextMessageFromBot is a text output message from bot to user
func (TextMessageFromBot) BotMessageType ¶
func (m TextMessageFromBot) BotMessageType() BotMessageType
BotMessageType returns if we want to send a new message or edit existing one
func (*TextMessageFromBot) MarshalJSON ¶
func (j *TextMessageFromBot) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*TextMessageFromBot) MarshalJSONBuf ¶
func (j *TextMessageFromBot) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*TextMessageFromBot) UnmarshalJSON ¶
func (j *TextMessageFromBot) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*TextMessageFromBot) UnmarshalJSONFFLexer ¶
func (j *TextMessageFromBot) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
UnmarshalJSONFFLexer fast json unmarshall - template ffjson
type TranslatorProvider ¶
TranslatorProvider translates texts
type TypeCommands ¶
type TypeCommands struct {
// contains filtered or unexported fields
}
TypeCommands container for commands
type WebhookActor ¶
type WebhookActor interface { Platform() string GetID() interface{} IsBotUser() bool GetFirstName() string GetLastName() string GetUserName() string GetLanguage() string }
WebhookActor represents sender
type WebhookAttachment ¶
type WebhookAttachment interface { Type() string // Enum(image, video, audio) for Facebook PayloadUrl() string // 'payload.url' for Facebook }
WebhookAttachment represents attachment to a message
type WebhookAudioMessage ¶
type WebhookAudioMessage interface { WebhookMessage }
WebhookAudioMessage represents single audio message
type WebhookCallbackQuery ¶
type WebhookCallbackQuery interface { GetID() string GetInlineMessageID() string // Telegram only? GetFrom() WebhookSender GetMessage() WebhookMessage GetData() string Chat() WebhookChat }
WebhookCallbackQuery represents a single callback query message
type WebhookChat ¶
WebhookChat represents chat of a messenger
type WebhookChosenInlineResult ¶
type WebhookChosenInlineResult interface { GetResultID() string GetInlineMessageID() string // Telegram only? GetFrom() WebhookSender GetQuery() string }
WebhookChosenInlineResult represents a single report message on chosen inline result
type WebhookContactMessage ¶
type WebhookContactMessage interface { PhoneNumber() string FirstName() string LastName() string UserID() interface{} }
WebhookContactMessage represents single contact message
type WebhookContext ¶
type WebhookContext interface { // TODO: Make interface smaller? GA() GaContext db.TransactionCoordinator Environment() strongo.Environment BotInputProvider BotPlatform() BotPlatform Request() *http.Request //Init(w http.ResponseWriter, r *http.Request) error Context() context.Context SetContext(c context.Context) ExecutionContext() strongo.ExecutionContext BotAppContext() BotAppContext BotContext() BotContext MustBotChatID() string GetBotCode() string GetBotToken() string GetBotSettings() BotSettings ChatEntity() BotChat IsInGroup() bool CommandText(title, icon string) string //Locale() strongo.ByLocale SetLocale(code5 string) error NewMessage(text string) MessageFromBot NewMessageByCode(messageCode string, a ...interface{}) MessageFromBot NewEditMessage(text string, format MessageFormat) (MessageFromBot, error) UpdateLastProcessed(chatEntity BotChat) error AppUserIntID() int64 AppUserStrID() string GetAppUser() (BotAppUser, error) BotState BotChatStore // TODO: Migrate to strongo/db BotUserStore // TODO: Migrate to strongo/db WebhookInput // TODO: Should be removed!!! strongo.SingleLocaleTranslator Responder() WebhookResponder }
WebhookContext provides context for current request from user to bot
type WebhookContextBase ¶
type WebhookContextBase struct { BotUserKey *datastore.Key strongo.Translator BotCoreStores // contains filtered or unexported fields }
WebhookContextBase provides base implementation of WebhookContext interface
func NewWebhookContextBase ¶
func NewWebhookContextBase( r *http.Request, botAppContext BotAppContext, botPlatform BotPlatform, botContext BotContext, webhookInput WebhookInput, botCoreStores BotCoreStores, gaMeasurement GaQueuer, isInGroup func() bool, getLocaleAndChatID func(c context.Context) (locale, chatID string, err error), ) *WebhookContextBase
NewWebhookContextBase creates base bot context
func (*WebhookContextBase) AppUserEntity ¶
func (whcb *WebhookContextBase) AppUserEntity() BotAppUser
AppUserEntity current app user entity from data storage
func (*WebhookContextBase) AppUserIntID ¶
func (whcb *WebhookContextBase) AppUserIntID() (appUserIntID int64)
AppUserIntID return current app user ID as integer
func (*WebhookContextBase) AppUserStrID ¶
func (whcb *WebhookContextBase) AppUserStrID() string
AppUserStrID return current app user ID as a string
func (*WebhookContextBase) BotAppContext ¶
func (whcb *WebhookContextBase) BotAppContext() BotAppContext
BotAppContext returns bot app context
func (*WebhookContextBase) BotChatID ¶
func (whcb *WebhookContextBase) BotChatID() (botChatID string, err error)
BotChatID returns bot chat ID
func (*WebhookContextBase) BotContext ¶
func (whcb *WebhookContextBase) BotContext() BotContext
func (*WebhookContextBase) BotPlatform ¶
func (whcb *WebhookContextBase) BotPlatform() BotPlatform
BotPlatform inidates on which bot platform we process message
func (*WebhookContextBase) Chat ¶
func (whcb *WebhookContextBase) Chat() WebhookChat
Chat returns webhook chat
func (*WebhookContextBase) ChatEntity ¶
func (whcb *WebhookContextBase) ChatEntity() BotChat
ChatEntity returns app entity for the context (loaded from DB)
func (*WebhookContextBase) CommandText ¶
func (whcb *WebhookContextBase) CommandText(title, icon string) string
CommandText returns a title for a command
func (*WebhookContextBase) Context ¶
func (whcb *WebhookContextBase) Context() context.Context
Context for current request
func (*WebhookContextBase) Environment ¶
func (whcb *WebhookContextBase) Environment() strongo.Environment
Environment defines current environment (PROD, DEV, LOCAL, etc)
func (*WebhookContextBase) ExecutionContext ¶
func (whcb *WebhookContextBase) ExecutionContext() strongo.ExecutionContext
ExecutionContext returns an execution context for strongo app
func (*WebhookContextBase) GA ¶
func (whcb *WebhookContextBase) GA() GaContext
GA provides interface to Google Analytics
func (*WebhookContextBase) GetAppUser ¶
func (whcb *WebhookContextBase) GetAppUser() (BotAppUser, error)
GetAppUser loads information about current app user from persistent storage
func (*WebhookContextBase) GetBotCode ¶
func (whcb *WebhookContextBase) GetBotCode() string
GetBotCode returns current bot code
func (*WebhookContextBase) GetBotSettings ¶
func (whcb *WebhookContextBase) GetBotSettings() BotSettings
GetBotSettings settings of the current bot
func (*WebhookContextBase) GetBotToken ¶
func (whcb *WebhookContextBase) GetBotToken() string
GetBotToken returns current bot API token
func (*WebhookContextBase) GetOrCreateBotUserEntityBase ¶
func (whcb *WebhookContextBase) GetOrCreateBotUserEntityBase() (BotUser, error)
GetOrCreateBotUserEntityBase to be documented
func (*WebhookContextBase) GetRecipient ¶
func (whcb *WebhookContextBase) GetRecipient() WebhookRecipient
GetRecipient returns receiver of the message
func (*WebhookContextBase) GetSender ¶
func (whcb *WebhookContextBase) GetSender() WebhookSender
GetSender returns sender of the message
func (*WebhookContextBase) GetTime ¶
func (whcb *WebhookContextBase) GetTime() time.Time
GetTime returns time of the message
func (*WebhookContextBase) HasChatEntity ¶
func (whcb *WebhookContextBase) HasChatEntity() bool
HasChatEntity return true if messages is within chat
func (*WebhookContextBase) Input ¶
func (whcb *WebhookContextBase) Input() WebhookInput
Input returns webhook intput
func (*WebhookContextBase) InputType ¶
func (whcb *WebhookContextBase) InputType() WebhookInputType
InputType returns input type
func (*WebhookContextBase) IsInGroup ¶
func (whcb *WebhookContextBase) IsInGroup() bool
IsInGroup signals if the bot request is send within group chat
func (*WebhookContextBase) IsInTransaction ¶
func (whcb *WebhookContextBase) IsInTransaction(c context.Context) bool
IsInTransaction detects if request is within a transaction
func (WebhookContextBase) Locale ¶
func (whcb WebhookContextBase) Locale() strongo.Locale
Locale indicates current language
func (*WebhookContextBase) LogRequest ¶
func (whcb *WebhookContextBase) LogRequest()
LogRequest logs request data to logging system
func (*WebhookContextBase) MessageText ¶
func (whcb *WebhookContextBase) MessageText() string
MessageText returns text of received message
func (*WebhookContextBase) MustBotChatID ¶
func (whcb *WebhookContextBase) MustBotChatID() (chatID string)
MustBotChatID returns bot chat ID and panic if missing it
func (*WebhookContextBase) NewMessage ¶
func (whcb *WebhookContextBase) NewMessage(text string) (m MessageFromBot)
NewMessage creates new message from bot
func (*WebhookContextBase) NewMessageByCode ¶
func (whcb *WebhookContextBase) NewMessageByCode(messageCode string, a ...interface{}) (m MessageFromBot)
NewMessageByCode creates new translated message by i18n code
func (*WebhookContextBase) NonTransactionalContext ¶
func (whcb *WebhookContextBase) NonTransactionalContext(tc context.Context) context.Context
NonTransactionalContext creates a non transaction context for operations that needs to be executed outside of transaction.
func (*WebhookContextBase) Request ¶
func (whcb *WebhookContextBase) Request() *http.Request
Request returns reference to current HTTP request
func (*WebhookContextBase) RunInTransaction ¶
func (whcb *WebhookContextBase) RunInTransaction(c context.Context, f func(c context.Context) error, options db.RunOptions) error
RunInTransaction starts a transaction. This needed to coordinate application & framework changes.
func (*WebhookContextBase) SetChatEntity ¶
func (whcb *WebhookContextBase) SetChatEntity(chatEntity BotChat)
SetChatEntity sets app entity for the context (loaded from DB)
func (*WebhookContextBase) SetChatID ¶
func (whcb *WebhookContextBase) SetChatID(v string)
SetChatID sets chat ID
func (*WebhookContextBase) SetContext ¶
func (whcb *WebhookContextBase) SetContext(c context.Context)
SetContext sets current context // TODO: explain why we need this as probably should be in constructor?
func (*WebhookContextBase) SetLocale ¶
func (whcb *WebhookContextBase) SetLocale(code5 string) error
SetLocale sets current language
func (*WebhookContextBase) Translate ¶
func (whcb *WebhookContextBase) Translate(key string, args ...interface{}) string
Translate translates string
func (*WebhookContextBase) TranslateNoWarning ¶
func (whcb *WebhookContextBase) TranslateNoWarning(key string, args ...interface{}) string
TranslateNoWarning translates string without warnings
type WebhookConversationStarted ¶
type WebhookConversationStarted interface {
ConversationStartedMessage() interface{}
}
WebhookConversationStarted represents a single message about new conversation
type WebhookDelivery ¶
type WebhookDelivery interface {
Payload() string
}
WebhookDelivery represents a single delivery report message
type WebhookDriver ¶
type WebhookDriver interface { RegisterWebhookHandlers(httpRouter *httprouter.Router, pathPrefix string, webhookHandlers ...WebhookHandler) HandleWebhook(w http.ResponseWriter, r *http.Request, webhookHandler WebhookHandler) }
WebhookDriver is doing initial request & final response processing. That includes logging, creating input messages in a general format, sending response.
func NewBotDriver ¶
func NewBotDriver(gaSettings AnalyticsSettings, appContext BotAppContext, host BotHost, panicTextFooter string) WebhookDriver
NewBotDriver registers new bot driver (TODO: describe why we need it)
type WebhookEntry ¶
WebhookEntry represents a single message from a messenger user
type WebhookHandler ¶
type WebhookHandler interface { RegisterHttpHandlers(driver WebhookDriver, botHost BotHost, router *httprouter.Router, pathPrefix string) HandleWebhookRequest(w http.ResponseWriter, r *http.Request, params httprouter.Params) GetBotContextAndInputs(c context.Context, r *http.Request) (botContext *BotContext, entriesWithInputs []EntryInputs, err error) CreateBotCoreStores(appContext BotAppContext, r *http.Request) BotCoreStores CreateWebhookContext(appContext BotAppContext, r *http.Request, botContext BotContext, webhookInput WebhookInput, botCoreStores BotCoreStores, gaMeasurement GaQueuer) WebhookContext //TODO: Can we get rid of http.Request? Needed for botHost.GetHTTPClient() GetResponder(w http.ResponseWriter, whc WebhookContext) WebhookResponder HandleUnmatched(whc WebhookContext) (m MessageFromBot) }
WebhookHandler handles requests from a specific bot API
type WebhookInlineQuery ¶
type WebhookInlineQuery interface { GetID() interface{} GetInlineQueryID() string GetFrom() WebhookSender GetQuery() string GetOffset() string }
WebhookInlineQuery represents a single inline message
type WebhookInlineQueryContext ¶
type WebhookInlineQueryContext interface { }
WebhookInlineQueryContext provides context for inline query (TODO: check & document)
type WebhookInput ¶
type WebhookInput interface { // '/entry/messaging' for Facebook GetSender() WebhookSender GetRecipient() WebhookRecipient GetTime() time.Time InputType() WebhookInputType BotChatID() (string, error) Chat() WebhookChat LogRequest() }
WebhookInput represent a single message
type WebhookInputType ¶
type WebhookInputType int
WebhookInputType is enum of input type
const ( // WebhookInputUnknown is unknown input type WebhookInputUnknown WebhookInputType = iota // WebhookInputNotImplemented is not implemented input type WebhookInputNotImplemented // WebhookInputText is text input type WebhookInputText // Facebook, Telegram, Viber // WebhookInputVoice is voice input type WebhookInputVoice // WebhookInputPhoto is photo input type WebhookInputPhoto // WebhookInputAudio is audio input type WebhookInputAudio // WebhookInputContact is contact input type WebhookInputContact // Facebook, Telegram, Viber // WebhookInputPostback is unknown input type WebhookInputPostback // WebhookInputDelivery is postback input type WebhookInputDelivery // WebhookInputAttachment is delivery report input type WebhookInputAttachment // WebhookInputInlineQuery is attachment input type WebhookInputInlineQuery // Telegram // WebhookInputCallbackQuery is inline input type WebhookInputCallbackQuery // WebhookInputReferral is callback input type WebhookInputReferral // FBM // WebhookInputChosenInlineResult is chosen inline result input type WebhookInputChosenInlineResult // Telegram // WebhookInputSubscribed is subscribed input type WebhookInputSubscribed // Viber // WebhookInputUnsubscribed is unsubscribed input type WebhookInputUnsubscribed // Viber // WebhookInputConversationStarted is converstation started input type WebhookInputConversationStarted // Viber // WebhookInputNewChatMembers is new chat memebers input type WebhookInputNewChatMembers // Telegram groups // WebhookInputLeftChatMembers is left chat members input type WebhookInputLeftChatMembers // WebhookInputSticker is sticker input type WebhookInputSticker // Telegram )
type WebhookLeftChatMembersMessage ¶
type WebhookLeftChatMembersMessage interface { BotChatID() (string, error) LeftChatMembers() []WebhookActor }
WebhookLeftChatMembersMessage represents single message about a member leaving a chat
type WebhookMessage ¶
type WebhookMessage interface { IntID() int64 StringID() string Chat() WebhookChat }
WebhookMessage represents single message
type WebhookNewChatMembersMessage ¶
type WebhookNewChatMembersMessage interface { BotChatID() (string, error) NewChatMembers() []WebhookActor }
WebhookNewChatMembersMessage represents single message about a new member of a chat
type WebhookNewContext ¶
type WebhookNewContext struct { BotContext WebhookInput }
WebhookNewContext TODO: needs to be checked & described
type WebhookPhotoMessage ¶
type WebhookPhotoMessage interface { WebhookMessage }
WebhookPhotoMessage represents single photo message
type WebhookPostback ¶
type WebhookPostback interface { PostbackMessage() interface{} Payload() string }
WebhookPostback represents single postback message
type WebhookRecipient ¶
type WebhookRecipient interface { WebhookActor }
WebhookRecipient represents receiver
type WebhookReferralMessage ¶
type WebhookReferralMessage interface { // https://developers.facebook.com/docs/messenger-platform/webhook-reference/referral Type() string Source() string RefData() string }
WebhookReferralMessage represents single referral message
type WebhookResponder ¶
type WebhookResponder interface {
SendMessage(c context.Context, m MessageFromBot, channel BotAPISendMessageChannel) (OnMessageSentResponse, error)
}
WebhookResponder is an API provider to send messages through a messenger
type WebhookSender ¶
type WebhookSender interface { GetAvatar() string // Extension to support avatar (Viber) WebhookActor }
WebhookSender represents sender with avatar
type WebhookStickerMessage ¶
type WebhookStickerMessage interface { WebhookMessage }
WebhookStickerMessage represents single sticker message
type WebhookSubscribed ¶
type WebhookSubscribed interface {
SubscribedMessage() interface{}
}
WebhookSubscribed represents a subscription message
type WebhookTextMessage ¶
type WebhookTextMessage interface { WebhookMessage Text() string IsEdited() bool }
WebhookTextMessage represents single text message
type WebhookUnsubscribed ¶
type WebhookUnsubscribed interface {
UnsubscribedMessage() interface{}
}
WebhookUnsubscribed represents a message when user unsubscribe
type WebhookUser ¶
type WebhookUser interface { // Extension to support language & country (Viber) GetCountry() string WebhookSender }
WebhookUser represents sender with country
type WebhookVoiceMessage ¶
type WebhookVoiceMessage interface { WebhookMessage }
WebhookVoiceMessage represents single voice message
type WebhooksRouter ¶
type WebhooksRouter struct {
// contains filtered or unexported fields
}
WebhooksRouter maps routes to commands
func NewWebhookRouter ¶
func NewWebhookRouter(commandsByType map[WebhookInputType][]Command, errorFooterText func() string) WebhooksRouter
NewWebhookRouter creates new router
func (*WebhooksRouter) AddCommands ¶
func (router *WebhooksRouter) AddCommands(commandsType WebhookInputType, commands []Command)
AddCommands add commands to a router
func (WebhooksRouter) CommandsCount ¶
func (router WebhooksRouter) CommandsCount() int
func (*WebhooksRouter) Dispatch ¶
func (router *WebhooksRouter) Dispatch(webhookHandler WebhookHandler, responder WebhookResponder, whc WebhookContext)
Dispatch query to commands
func (*WebhooksRouter) DispatchInlineQuery ¶
func (router *WebhooksRouter) DispatchInlineQuery(responder WebhookResponder)
DispatchInlineQuery dispatches inlines query
func (*WebhooksRouter) RegisterCommands ¶
func (router *WebhooksRouter) RegisterCommands(commands []Command)
RegisterCommands is registering commands with router