Documentation
¶
Index ¶
- Variables
- func AddCustomInteraction(custom CustomInteraction)
- func SetMessenger(messenger Messenger)
- func Start(ctx context.Context) error
- type AuthInteract
- type AuthMode
- type Authorizer
- 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) SetOriginState(s State)
- func (it *Interact) SetState(s State)
- func (it *Interact) Start(ctx context.Context) error
- type Messenger
- type Reply
- type Responder
- type State
- type Telegram
- func (tm *Telegram) AddCommand(cmd *Command, responder Responder)
- func (tm *Telegram) EmitAuthorized(a *TelegramAuthorizer)
- func (tm *Telegram) OnAuthorized(cb func(a *TelegramAuthorizer))
- func (tm *Telegram) RestoreSession(session *TelegramSession)
- func (tm *Telegram) SetTextMessageResponder(textMessageResponder Responder)
- func (tm *Telegram) Start(context.Context)
- type TelegramAuthorizer
- type TelegramReply
- type TelegramSession
- 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 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 ¶
func (*Interact) SetOriginState ¶
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"`
// Owner is the authorized bot owner
// This field is exported in order to be stored in file
Owner *telebot.User `json:"owner,omitempty"`
// OwnerChat is the chat of the authorized bot owner
// This field is exported in order to be stored in file
OwnerChat *telebot.Chat `json:"chat,omitempty"`
// contains filtered or unexported fields
}
func (*Telegram) AddCommand ¶
func (*Telegram) EmitAuthorized ¶ added in v1.26.0
func (tm *Telegram) EmitAuthorized(a *TelegramAuthorizer)
func (*Telegram) OnAuthorized ¶ added in v1.26.0
func (tm *Telegram) OnAuthorized(cb func(a *TelegramAuthorizer))
func (*Telegram) RestoreSession ¶ added in v1.26.0
func (tm *Telegram) RestoreSession(session *TelegramSession)
func (*Telegram) SetTextMessageResponder ¶
type TelegramAuthorizer ¶
func (*TelegramAuthorizer) Authorize ¶
func (a *TelegramAuthorizer) Authorize() error
func (*TelegramAuthorizer) StartAuthorizing ¶
func (a *TelegramAuthorizer) StartAuthorizing()
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 {
Owner *telebot.User `json:"owner"`
OwnerChat *telebot.Chat `json:"chat"`
// Subscribers stores the Chat objects
Subscribers map[int64]time.Time `json:"chats"`
}
func NewTelegramSession ¶ added in v1.26.0
func NewTelegramSession() *TelegramSession
type TextMessageResponder ¶
type TextMessageResponder interface {
SetTextMessageResponder(responder Responder)
}
Click to show internal directories.
Click to hide internal directories.