Documentation ¶
Index ¶
- type BackgroundFunction
- type Bot
- func (b *Bot) AddBackgroundTask(fn BackgroundFunction)
- func (b *Bot) AddHandler(cmd string, handler CommandHandler)
- func (b *Bot) AddPeriodicTask(interval time.Duration, reportMessage string, fn TaskFunction)
- func (b *Bot) Init(ctx context.Context, runtime string) error
- func (b Bot) Run() (string, error)
- type ChattableCloser
- type ChattableDocument
- type ChattablePicture
- type ChattableText
- type ChattableVideo
- type CommandHandler
- type TaskFunction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackgroundFunction ¶
type BackgroundFunction func(ctx context.Context, events chan<- ChattableCloser)
BackgroundFunction runs in a background in a goroutine and sends back events as those get created
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot is a highger-level wrapper over tgbotpi. Allow adding service handlers and periodic functions.
func (*Bot) AddBackgroundTask ¶
func (b *Bot) AddBackgroundTask(fn BackgroundFunction)
func (*Bot) AddHandler ¶
func (b *Bot) AddHandler(cmd string, handler CommandHandler)
AddHandler registers a new handler function against a command string.
func (*Bot) AddPeriodicTask ¶
func (b *Bot) AddPeriodicTask(interval time.Duration, reportMessage string, fn TaskFunction)
AddPeriodicTask registers a periodic task. Param 'interval' should be an increment of 5 mins, or it will be aligned to the next 5 mins boundary.
type ChattableCloser ¶
ChattableCloser is a chattable message, which is closed after use.
type ChattableDocument ¶
type ChattableDocument struct {
tgbotapi.DocumentConfig
}
ChattableDocument is a simple chat video
type ChattablePicture ¶
type ChattablePicture struct {
tgbotapi.PhotoConfig
}
ChattablePicture is a simple chat picture
type ChattableText ¶
type ChattableText struct {
tgbotapi.MessageConfig
}
ChattableText is a simple chat message
type ChattableVideo ¶
type ChattableVideo struct {
tgbotapi.VideoConfig
}
ChattableVideo is a simple chat video
type CommandHandler ¶
type CommandHandler func(ctx context.Context, cmd *tgbotapi.Message, bot *tgbotapi.BotAPI) (response ChattableCloser, err error)
CommandHandler is a function, which can handle a specific bot command
type TaskFunction ¶
TaskFunction is a function, which is executed by bot periodically