Documentation
¶
Overview ¶
Package telegram implements a joe-bot adapter for the Telegram BotAPI
Index ¶
- func Adapter(token string, opts ...Option) joe.Module
- type Button
- type Callback
- type Config
- type Option
- type ReceiveCommandEvent
- type TelegramAdapter
- func (a *TelegramAdapter) Close() error
- func (a *TelegramAdapter) NewButton(label string, cb Callback) Button
- func (a *TelegramAdapter) RegisterAt(brain *joe.Brain)
- func (a *TelegramAdapter) Send(txt, chatIDString string) error
- func (a *TelegramAdapter) SendButtons(channel, text string, buttons ...Button) error
- func (a *TelegramAdapter) SendGIF(channel string, gif interface{}, caption string) error
- func (a *TelegramAdapter) SendPhoto(channel string, photo interface{}, caption string) error
- func (a *TelegramAdapter) SendSticker(channel string, sticker interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // Token is the token issued by botfather // https://core.telegram.org/bots/api#authorizing-your-bot Token string // UpdateTimeoutSec configures the UpdateCofnig.Timout option of the // telegram-bot-api client UpdateTimeoutSec int // UpdateResumeFrom is the last Update ID to resume from // https://core.telegram.org/bots/api#update UpdateResumeFrom int // ParseMode sets the formatting style for messages the bot sends // https://core.telegram.org/bots/api#formatting-options ParseMode string Logger *zap.Logger }
Config holds the options pased to the Telegram adapter
type Option ¶
func WithLogger ¶
WithLogger allows configuring a custom zap.Logger for the adapter to use
func WithParseMode ¶
WithParseMode allows setting the message formatting used by Send
func WithUpdateResumeFrom ¶
WithUpdateResumeFrom allows setting the starting Update ID from which to process updates froms.
func WithUpdateTimeout ¶
WithUpdateTimeout allows configuring the update loop timeout (in seconds)
type ReceiveCommandEvent ¶
type ReceiveCommandEvent struct { Arg0 string Args []string From *tgbotapi.User Chat *tgbotapi.Chat Data *tgbotapi.Message }
func (ReceiveCommandEvent) Channel ¶
func (e ReceiveCommandEvent) Channel() string
type TelegramAdapter ¶
TelegramAdapter is a joe-bot adapter for the Telegram BotAPI
func NewAdapter ¶
func NewAdapter(ctx context.Context, conf Config) (*TelegramAdapter, error)
NewAdapter creates a new instance of the TelegramAdapter
func (*TelegramAdapter) Close ¶
func (a *TelegramAdapter) Close() error
Close finishes processing updates
func (*TelegramAdapter) NewButton ¶
func (a *TelegramAdapter) NewButton(label string, cb Callback) Button
func (*TelegramAdapter) RegisterAt ¶
func (a *TelegramAdapter) RegisterAt(brain *joe.Brain)
RegisterAt implements the joe.Adapter interface by emitting the telegram API events to the given brain
func (*TelegramAdapter) Send ¶
func (a *TelegramAdapter) Send(txt, chatIDString string) error
Send sends a messages (formatted using Config.ParseMode) via the Telegram BotAPI
func (*TelegramAdapter) SendButtons ¶
func (a *TelegramAdapter) SendButtons(channel, text string, buttons ...Button) error
func (*TelegramAdapter) SendGIF ¶
func (a *TelegramAdapter) SendGIF(channel string, gif interface{}, caption string) error
func (*TelegramAdapter) SendPhoto ¶
func (a *TelegramAdapter) SendPhoto(channel string, photo interface{}, caption string) error
func (*TelegramAdapter) SendSticker ¶
func (a *TelegramAdapter) SendSticker(channel string, sticker interface{}) error