Documentation
¶
Index ¶
- Variables
- func AddCustomInteraction(custom CustomInteraction)
- func SetMessenger(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 Command
- type CommandResponder
- type CustomInteraction
- type Initializer
- type Interact
- func (it *Interact) AddCustomInteraction(custom CustomInteraction)
- func (it *Interact) Command(command string, desc string, f interface{}) *Command
- func (it *Interact) PrivateCommand(command, desc string, f interface{}) *Command
- func (it *Interact) SetMessenger(messenger Messenger)
- func (it *Interact) Start(ctx context.Context) error
- type Messenger
- type Reply
- type Responder
- type Session
- 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) SetTextMessageResponder(textMessageResponder Responder)
- func (tm *Telegram) Start(context.Context)
- type TelegramReply
- type TelegramSession
- type TelegramSessionMap
- 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 SetMessenger ¶ added in v1.26.0
func SetMessenger(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 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 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) PrivateCommand ¶
func (*Interact) SetMessenger ¶
type Messenger ¶
type Messenger interface { TextMessageResponder CommandResponder Start(ctx context.Context) }
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 (*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) SetTextMessageResponder ¶
type TelegramReply ¶
type TelegramReply struct {
// contains filtered or unexported fields
}
func (*TelegramReply) AddButton ¶
func (r *TelegramReply) AddButton(text 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.