Documentation ¶
Index ¶
- func BotListenerAction(ctx context.Context, runner *runners.Runner) error
- func BotPublisherAction(ctx context.Context, runner *runners.Runner) error
- func BotWorkerRunnerAction(ctx context.Context, runner *runners.Runner) error
- func CreateBotContext(svc *GoTGBotService) (ctx context.Context, cancel context.CancelFunc)
- func Has(b, flag SetupLevel) bool
- type BotListener
- func (lst *BotListener) AddCallbackHandler(title string, filter func(update tgbotapi.Update) bool, ...)
- func (lst *BotListener) AddCommandHandler(title string, command string, handler ListenerHandlerFunc)
- func (lst *BotListener) AddHandler(title string, filter func(update tgbotapi.Update) bool, ...)
- func (lst *BotListener) SetupCommandsMessage() (msg tgbotapi.SetMyCommandsConfig, err error)
- type BotPublisher
- func (pbx *BotPublisher) Publish(message tgbotapi.Chattable)
- func (pbx *BotPublisher) ReplyToMessage(update tgbotapi.Update, text string)
- func (pbx *BotPublisher) SendHTMLMessage(chatID int64, htmlMessage string)
- func (pbx *BotPublisher) SendInlineKeyboard(chatID int64, text string, keyboardOptions ...string)
- func (pbx *BotPublisher) SendMenuKeyboard(chatID int64, caption string, baseCommand string, keyboardOptions ...string)
- func (pbx *BotPublisher) SendTextMessage(chatID int64, text string)
- type BotRunner
- type BotWorker
- type BotWorkerAction
- type GoTGBotService
- func (svc *GoTGBotService) AddCallbackHandlers(handlers ...*ListenerCallbackHandler) *GoTGBotService
- func (svc *GoTGBotService) AddCommandHandlers(handlers ...*ListenerCommandHandler) *GoTGBotService
- func (svc *GoTGBotService) AddHandlers(handlers ...*ListenerFilteredHandler) *GoTGBotService
- func (svc *GoTGBotService) Configuration() *config.Configuration
- func (svc *GoTGBotService) InitBot() *GoTGBotService
- func (svc *GoTGBotService) Listener() *BotListener
- func (svc *GoTGBotService) LoadConfigurationFromEnv(prefix string) *GoTGBotService
- func (svc *GoTGBotService) LoadConfigurationFromFile(filename string) *GoTGBotService
- func (svc *GoTGBotService) Publisher() *BotPublisher
- func (svc *GoTGBotService) Repository() IRepository
- func (svc *GoTGBotService) SetDatabase(dbs ...*gorm.DB) *GoTGBotService
- func (svc *GoTGBotService) SetRepository(repository IRepository) *GoTGBotService
- func (svc *GoTGBotService) SetupBackgroundRunOnceSchedules(schedules ...*schedules.Schedule) *GoTGBotService
- func (svc *GoTGBotService) SetupBackgroundSchedules(schedules ...*schedules.Schedule) *GoTGBotService
- func (svc *GoTGBotService) Start() error
- func (svc *GoTGBotService) Stop() error
- type IRepository
- type ListenerCallbackHandler
- type ListenerCommandHandler
- type ListenerFilter
- type ListenerFilteredHandler
- type ListenerHandlerFunc
- type SetupLevel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BotPublisherAction ¶
func BotWorkerRunnerAction ¶
func CreateBotContext ¶
func CreateBotContext(svc *GoTGBotService) (ctx context.Context, cancel context.CancelFunc)
func Has ¶
func Has(b, flag SetupLevel) bool
Types ¶
type BotListener ¶
type BotListener struct { BotRunner // contains filtered or unexported fields }
func (*BotListener) AddCallbackHandler ¶ added in v0.0.3
func (lst *BotListener) AddCallbackHandler(title string, filter func(update tgbotapi.Update) bool, handler ListenerHandlerFunc)
func (*BotListener) AddCommandHandler ¶
func (lst *BotListener) AddCommandHandler(title string, command string, handler ListenerHandlerFunc)
func (*BotListener) AddHandler ¶
func (*BotListener) SetupCommandsMessage ¶
func (lst *BotListener) SetupCommandsMessage() (msg tgbotapi.SetMyCommandsConfig, err error)
type BotPublisher ¶
type BotPublisher struct { BotRunner // contains filtered or unexported fields }
func (*BotPublisher) Publish ¶
func (pbx *BotPublisher) Publish(message tgbotapi.Chattable)
func (*BotPublisher) ReplyToMessage ¶
func (pbx *BotPublisher) ReplyToMessage(update tgbotapi.Update, text string)
func (*BotPublisher) SendHTMLMessage ¶
func (pbx *BotPublisher) SendHTMLMessage(chatID int64, htmlMessage string)
func (*BotPublisher) SendInlineKeyboard ¶
func (pbx *BotPublisher) SendInlineKeyboard(chatID int64, text string, keyboardOptions ...string)
func (*BotPublisher) SendMenuKeyboard ¶ added in v0.0.3
func (pbx *BotPublisher) SendMenuKeyboard(chatID int64, caption string, baseCommand string, keyboardOptions ...string)
SendMenuKeyboard sends a menu keyboard to the given chatID. caption is the caption of the menu. baseCommand is the command handler name that will be called when the user selects an option. keyboardOptions is a list of options. Each option is in format "Title:data". You can use "-" to separate options in a row.
func (*BotPublisher) SendTextMessage ¶
func (pbx *BotPublisher) SendTextMessage(chatID int64, text string)
type BotWorker ¶
type BotWorker struct { BotRunner // contains filtered or unexported fields }
func (*BotWorker) AddSchedule ¶
type BotWorkerAction ¶
type GoTGBotService ¶
type GoTGBotService struct { BotRunner // contains filtered or unexported fields }
func CreateBotService ¶
func CreateBotService() *GoTGBotService
CreateBotService creates a new empty bot service This is the first step to create a bot service
After this step, you should:
* LoadConfigurationFromFile or LoadConfigurationFromEnv
* InitBot
* AddRepository (optional, if not set, automatic repository will be created)
func GetBotService ¶
func GetBotService(ctx context.Context) *GoTGBotService
func (*GoTGBotService) AddCallbackHandlers ¶ added in v0.0.3
func (svc *GoTGBotService) AddCallbackHandlers(handlers ...*ListenerCallbackHandler) *GoTGBotService
func (*GoTGBotService) AddCommandHandlers ¶
func (svc *GoTGBotService) AddCommandHandlers(handlers ...*ListenerCommandHandler) *GoTGBotService
func (*GoTGBotService) AddHandlers ¶
func (svc *GoTGBotService) AddHandlers(handlers ...*ListenerFilteredHandler) *GoTGBotService
func (*GoTGBotService) Configuration ¶
func (svc *GoTGBotService) Configuration() *config.Configuration
func (*GoTGBotService) InitBot ¶
func (svc *GoTGBotService) InitBot() *GoTGBotService
InitBot setups bot, loggin
func (*GoTGBotService) Listener ¶
func (svc *GoTGBotService) Listener() *BotListener
func (*GoTGBotService) LoadConfigurationFromEnv ¶
func (svc *GoTGBotService) LoadConfigurationFromEnv(prefix string) *GoTGBotService
func (*GoTGBotService) LoadConfigurationFromFile ¶
func (svc *GoTGBotService) LoadConfigurationFromFile(filename string) *GoTGBotService
func (*GoTGBotService) Publisher ¶
func (svc *GoTGBotService) Publisher() *BotPublisher
func (*GoTGBotService) Repository ¶
func (svc *GoTGBotService) Repository() IRepository
func (*GoTGBotService) SetDatabase ¶
func (svc *GoTGBotService) SetDatabase(dbs ...*gorm.DB) *GoTGBotService
SetDatabase sets the database for the bot repository
If not set, the bot repository will be created with the default connection string
func (*GoTGBotService) SetRepository ¶
func (svc *GoTGBotService) SetRepository(repository IRepository) *GoTGBotService
SetRepository sets the repository for the bot
You must implement a IRepository interface and pass it to this method ¶
Do not need to use SetDatabase
func (*GoTGBotService) SetupBackgroundRunOnceSchedules ¶
func (svc *GoTGBotService) SetupBackgroundRunOnceSchedules(schedules ...*schedules.Schedule) *GoTGBotService
func (*GoTGBotService) SetupBackgroundSchedules ¶
func (svc *GoTGBotService) SetupBackgroundSchedules(schedules ...*schedules.Schedule) *GoTGBotService
func (*GoTGBotService) Start ¶
func (svc *GoTGBotService) Start() error
func (*GoTGBotService) Stop ¶
func (svc *GoTGBotService) Stop() error
type IRepository ¶
type ListenerCallbackHandler ¶ added in v0.0.3
type ListenerCallbackHandler struct { Title string Filter ListenerFilter Func ListenerHandlerFunc }
func CreateListenerCallbackHandler ¶ added in v0.0.3
func CreateListenerCallbackHandler(title string, command string, handlerFunc ListenerHandlerFunc) *ListenerCallbackHandler
type ListenerCommandHandler ¶
type ListenerCommandHandler struct { Command string Title string Func ListenerHandlerFunc SubCommands []*ListenerCommandHandler }
type ListenerFilter ¶
ListenerFilter is the filter for messages received by the bot. If the filter returns true, the message will be handled by the handler.
type ListenerFilteredHandler ¶
type ListenerFilteredHandler struct { Command string Title string Func ListenerHandlerFunc Filter ListenerFilter }
type ListenerHandlerFunc ¶
ListenerHandlerFunc is the handler for messages received by the bot.
type SetupLevel ¶
type SetupLevel uint8
const ( Empty SetupLevel = 1 << iota Instance Configuration Init Workers Repository Handlers )
func Clear ¶
func Clear(b, flag SetupLevel) SetupLevel
func Set ¶
func Set(b, flag SetupLevel) SetupLevel
func Toggle ¶
func Toggle(b, flag SetupLevel) SetupLevel