Documentation ¶
Index ¶
- Variables
- func AddCustomInteraction(custom CustomInteraction)
- func AddMessenger(messenger Messenger)
- func Start(ctx context.Context) error
- type AuthInteract
- type AuthMode
- type Authorizer
- type BaseSession
- func (s *BaseSession) GetOriginState() State
- func (s *BaseSession) GetState() State
- func (s *BaseSession) IsAuthorized() bool
- func (s *BaseSession) SetAuthorized()
- func (s *BaseSession) SetAuthorizing(b bool)
- func (s *BaseSession) SetOriginState(state State)
- func (s *BaseSession) SetState(state State)
- type Button
- type ButtonReply
- type CallbackResponder
- type Command
- type CommandResponder
- type CustomInteraction
- type DialogReply
- type Initializer
- type Interact
- func (it *Interact) AddCustomInteraction(custom CustomInteraction)
- func (it *Interact) AddMessenger(messenger Messenger)
- func (it *Interact) Command(command string, desc string, f interface{}) *Command
- func (it *Interact) PrivateCommand(command, desc string, f interface{}) *Command
- func (it *Interact) Start(ctx context.Context) error
- type KeyboardController
- type Messenger
- type Option
- type Reply
- type Responder
- type Session
- type Slack
- func (s *Slack) AddCommand(command *Command, responder Responder)
- func (s *Slack) EmitAuthorized(userSession *SlackSession)
- func (s *Slack) EmitEventsApi(evt slackevents.EventsAPIEvent)
- func (s *Slack) OnAuthorized(cb func(userSession *SlackSession))
- func (s *Slack) OnEventsApi(cb func(evt slackevents.EventsAPIEvent))
- func (s *Slack) SetTextMessageResponder(responder Responder)
- func (s *Slack) Start(ctx context.Context)
- type SlackReply
- func (reply *SlackReply) AddButton(text string, name string, value string)
- func (reply *SlackReply) AddMultipleButtons(buttonsForm [][3]string)
- func (reply *SlackReply) Choose(prompt string, options ...Option)
- func (reply *SlackReply) InputText(prompt string, textFields ...TextField)
- func (reply *SlackReply) Message(message string)
- func (reply *SlackReply) RemoveKeyboard()
- func (reply *SlackReply) Send(message string)
- type SlackSession
- type SlackSessionMap
- type State
- type Telegram
- func (tm *Telegram) AddCommand(cmd *Command, responder Responder)
- func (tm *Telegram) EmitAuthorized(s *TelegramSession)
- func (tm *Telegram) OnAuthorized(cb func(s *TelegramSession))
- func (tm *Telegram) RestoreSessions(sessions TelegramSessionMap)
- func (tm *Telegram) Sessions() TelegramSessionMap
- func (tm *Telegram) SetCallbackResponder(responder CallbackResponder)
- func (tm *Telegram) SetTextMessageResponder(responder Responder)
- func (tm *Telegram) Start(ctx context.Context)
- type TelegramReply
- type TelegramSession
- type TelegramSessionMap
- type TextField
- type TextMessageResponder
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrAuthenticationFailed = errors.New("authentication failed")
Functions ¶
func AddCustomInteraction ¶ added in v1.26.0
func AddCustomInteraction(custom CustomInteraction)
func AddMessenger ¶ added in v1.27.0
func AddMessenger(messenger Messenger)
Types ¶
type AuthInteract ¶
type AuthInteract struct { Strict bool `json:"strict,omitempty"` Mode AuthMode `json:"authMode"` Token string `json:"authToken,omitempty"` OneTimePasswordKey *otp.Key `json:"otpKey,omitempty"` }
func (*AuthInteract) Commands ¶
func (it *AuthInteract) Commands(interact *Interact)
type Authorizer ¶
type Authorizer interface { StartAuthorizing() Authorize() error }
type BaseSession ¶ added in v1.26.1
type BaseSession struct { OriginState State `json:"originState,omitempty"` CurrentState State `json:"currentState,omitempty"` Authorized bool `json:"authorized,omitempty"` StartedTime time.Time `json:"startedTime,omitempty"` // contains filtered or unexported fields }
func (*BaseSession) GetOriginState ¶ added in v1.26.1
func (s *BaseSession) GetOriginState() State
func (*BaseSession) GetState ¶ added in v1.26.1
func (s *BaseSession) GetState() State
func (*BaseSession) IsAuthorized ¶ added in v1.26.1
func (s *BaseSession) IsAuthorized() bool
func (*BaseSession) SetAuthorized ¶ added in v1.26.1
func (s *BaseSession) SetAuthorized()
func (*BaseSession) SetAuthorizing ¶ added in v1.26.1
func (s *BaseSession) SetAuthorizing(b bool)
func (*BaseSession) SetOriginState ¶ added in v1.26.1
func (s *BaseSession) SetOriginState(state State)
func (*BaseSession) SetState ¶ added in v1.26.1
func (s *BaseSession) SetState(state State)
type ButtonReply ¶ added in v1.27.0
type ButtonReply interface { // AddButton adds the button to the reply AddButton(text string) }
ButtonReply can be used if your reply needs button user interface.
type CallbackResponder ¶ added in v1.27.0
type CallbackResponder interface {
SetCallbackResponder(responder Responder)
}
type Command ¶
type Command struct { // Name is the command name Name string // Desc is the command description Desc string // StateF is the command handler function F interface{} // contains filtered or unexported fields }
Command is a domain specific language syntax helper It's used for helping developer define the state and transition function
func NewCommand ¶
type CommandResponder ¶
type CustomInteraction ¶
type CustomInteraction interface {
Commands(interact *Interact)
}
type DialogReply ¶ added in v1.27.0
type DialogReply interface { // AddButton adds the button to the reply Dialog(title, text string, buttons []string) }
DialogReply can be used if your reply needs Dialog user interface
type Initializer ¶ added in v1.26.0
type Initializer interface {
Initialize() error
}
type Interact ¶
type Interact struct {
// contains filtered or unexported fields
}
Interact implements the interaction between bot and message software.
func (*Interact) AddCustomInteraction ¶
func (it *Interact) AddCustomInteraction(custom CustomInteraction)
func (*Interact) AddMessenger ¶ added in v1.27.0
func (*Interact) PrivateCommand ¶
type KeyboardController ¶ added in v1.27.0
type KeyboardController interface {
// RemoveKeyboard hides the keyboard from the client user interface
RemoveKeyboard()
}
KeyboardController is used when messenger supports keyboard controls
type Messenger ¶
type Messenger interface { TextMessageResponder CommandResponder Start(ctx context.Context) }
type Reply ¶
type Reply interface { // Send sends the message directly to the client's session Send(message string) // Message sets the message to the reply Message(message string) // AddButton adds the button to the reply AddButton(text string, name, value string) // AddMultipleButtons adds multiple buttons to the reply AddMultipleButtons(buttonsForm [][3]string) }
type Slack ¶ added in v1.27.0
type Slack struct {
// contains filtered or unexported fields
}
func (*Slack) AddCommand ¶ added in v1.27.0
func (*Slack) EmitAuthorized ¶ added in v1.27.0
func (s *Slack) EmitAuthorized(userSession *SlackSession)
func (*Slack) EmitEventsApi ¶ added in v1.27.0
func (s *Slack) EmitEventsApi(evt slackevents.EventsAPIEvent)
func (*Slack) OnAuthorized ¶ added in v1.27.0
func (s *Slack) OnAuthorized(cb func(userSession *SlackSession))
func (*Slack) OnEventsApi ¶ added in v1.27.0
func (s *Slack) OnEventsApi(cb func(evt slackevents.EventsAPIEvent))
func (*Slack) SetTextMessageResponder ¶ added in v1.27.0
type SlackReply ¶ added in v1.27.0
type SlackReply struct {
// contains filtered or unexported fields
}
func (*SlackReply) AddButton ¶ added in v1.27.0
func (reply *SlackReply) AddButton(text string, name string, value string)
func (*SlackReply) AddMultipleButtons ¶ added in v1.29.0
func (reply *SlackReply) AddMultipleButtons(buttonsForm [][3]string)
func (*SlackReply) Choose ¶ added in v1.27.0
func (reply *SlackReply) Choose(prompt string, options ...Option)
func (*SlackReply) InputText ¶ added in v1.27.0
func (reply *SlackReply) InputText(prompt string, textFields ...TextField)
func (*SlackReply) Message ¶ added in v1.27.0
func (reply *SlackReply) Message(message string)
func (*SlackReply) RemoveKeyboard ¶ added in v1.27.0
func (reply *SlackReply) RemoveKeyboard()
RemoveKeyboard is not supported by Slack
func (*SlackReply) Send ¶ added in v1.27.0
func (reply *SlackReply) Send(message string)
type SlackSession ¶ added in v1.27.0
type SlackSession struct { BaseSession ChannelID string UserID string // contains filtered or unexported fields }
func NewSlackSession ¶ added in v1.27.0
func NewSlackSession(slack *Slack, userID, channelID string) *SlackSession
func (*SlackSession) ID ¶ added in v1.27.0
func (s *SlackSession) ID() string
func (*SlackSession) SetAuthorized ¶ added in v1.27.0
func (s *SlackSession) SetAuthorized()
type SlackSessionMap ¶ added in v1.27.0
type SlackSessionMap map[string]*SlackSession
type Telegram ¶
type Telegram struct { Bot *telebot.Bot `json:"-"` // Private is used to protect the telegram bot, users not authenticated can not see messages or sending commands Private bool `json:"private,omitempty"` // contains filtered or unexported fields }
func NewTelegram ¶ added in v1.27.0
func NewTelegram(bot *telebot.Bot) *Telegram
func (*Telegram) AddCommand ¶
func (*Telegram) EmitAuthorized ¶ added in v1.26.0
func (tm *Telegram) EmitAuthorized(s *TelegramSession)
func (*Telegram) OnAuthorized ¶ added in v1.26.0
func (tm *Telegram) OnAuthorized(cb func(s *TelegramSession))
func (*Telegram) RestoreSessions ¶ added in v1.26.1
func (tm *Telegram) RestoreSessions(sessions TelegramSessionMap)
func (*Telegram) Sessions ¶ added in v1.26.1
func (tm *Telegram) Sessions() TelegramSessionMap
func (*Telegram) SetCallbackResponder ¶ added in v1.27.0
func (tm *Telegram) SetCallbackResponder(responder CallbackResponder)
func (*Telegram) SetTextMessageResponder ¶
type TelegramReply ¶
type TelegramReply struct {
// contains filtered or unexported fields
}
func (*TelegramReply) AddButton ¶
func (r *TelegramReply) AddButton(text string, name string, value string)
func (*TelegramReply) AddMultipleButtons ¶ added in v1.29.0
func (r *TelegramReply) AddMultipleButtons(buttonsForm [][3]string)
func (*TelegramReply) Message ¶
func (r *TelegramReply) Message(message string)
func (*TelegramReply) RemoveKeyboard ¶
func (r *TelegramReply) RemoveKeyboard()
func (*TelegramReply) Send ¶ added in v1.26.0
func (r *TelegramReply) Send(message string)
type TelegramSession ¶ added in v1.26.0
type TelegramSession struct { BaseSession User *telebot.User `json:"user"` Chat *telebot.Chat `json:"chat"` // contains filtered or unexported fields }
func NewTelegramSession ¶ added in v1.26.0
func NewTelegramSession(telegram *Telegram, message *telebot.Message) *TelegramSession
func (*TelegramSession) ID ¶ added in v1.26.1
func (s *TelegramSession) ID() string
func (*TelegramSession) SetAuthorized ¶ added in v1.26.1
func (s *TelegramSession) SetAuthorized()
type TelegramSessionMap ¶ added in v1.26.1
type TelegramSessionMap map[int64]*TelegramSession
type TextMessageResponder ¶
type TextMessageResponder interface {
SetTextMessageResponder(responder Responder)
}
Click to show internal directories.
Click to hide internal directories.