Documentation
¶
Index ¶
- func SetCommandsForToken(ctx context.Context, token string) error
- type Bot
- func (b *Bot) IsRunning() bool
- func (b *Bot) SendMessage(ctx context.Context, text string) error
- func (b *Bot) SendMessageWithKeyboard(ctx context.Context, text string, keyboard InlineKeyboardMarkup) error
- func (b *Bot) SendPhoto(ctx context.Context, pngData []byte, caption string) error
- func (b *Bot) SetCommands(ctx context.Context) error
- func (b *Bot) Start(ctx context.Context)
- func (b *Bot) Stop()
- type Dependencies
- type InlineKeyboardButton
- type InlineKeyboardMarkup
- type TelegramMessage
- type TelegramUpdate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot represents the Telegram bot.
func New ¶
func New(token, chatID, label string, deps *Dependencies) *Bot
New creates a new Telegram bot.
func (*Bot) SendMessage ¶
SendMessage sends a Markdown message to the configured chat.
func (*Bot) SendMessageWithKeyboard ¶ added in v0.1.3
func (b *Bot) SendMessageWithKeyboard(ctx context.Context, text string, keyboard InlineKeyboardMarkup) error
SendMessageWithKeyboard sends a Markdown message with an inline keyboard.
func (*Bot) SendPhoto ¶
SendPhoto sends a PNG photo with an optional caption to the configured chat.
func (*Bot) SetCommands ¶ added in v0.1.0
SetCommands registers bot commands via setMyCommands so they appear as autocomplete suggestions in Telegram clients.
type Dependencies ¶
type Dependencies struct {
Settings *store.SettingsStore
Secrets *store.SecretStore
Upstreams *store.UpstreamStore
Traffic *store.TrafficStore
Instances *store.InstanceStore
// Callbacks for actions that need service layer (set by caller)
GetPublicIP func(ctx context.Context) string
IsProxyRunning func(ctx context.Context) bool
IsInstanceRunning func(ctx context.Context, containerName string) bool
GetUptime func(ctx context.Context) string
GetEngineVersion func() string
RestartProxy func(ctx context.Context) error
StartInstance func(ctx context.Context, id int64) error
StopInstance func(ctx context.Context, id int64) error
GenerateQR func(ctx context.Context, link string) ([]byte, error)
GetSchedulerTasks func(ctx context.Context) []string
}
Dependencies holds the stores/services the bot needs for command execution.
type InlineKeyboardButton ¶ added in v0.1.3
InlineKeyboardButton is a Telegram Bot API InlineKeyboardButton.
type InlineKeyboardMarkup ¶ added in v0.1.3
type InlineKeyboardMarkup struct {
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
}
InlineKeyboardMarkup is a Telegram Bot API reply markup for inline keyboards.
type TelegramMessage ¶
type TelegramMessage struct {
MessageID int64 `json:"message_id"`
Text string `json:"text"`
From struct {
ID int64 `json:"id"`
Username string `json:"username"`
} `json:"from"`
}
TelegramMessage represents a message from Telegram.
type TelegramUpdate ¶
type TelegramUpdate struct {
UpdateID int64 `json:"update_id"`
Message *TelegramMessage `json:"message,omitempty"`
}
TelegramUpdate represents an incoming update.