Documentation
¶
Index ¶
- type Chat
- type Client
- func (c *Client) AckUpdate(ctx context.Context, updateID int) error
- func (c *Client) GetUpdate(ctx context.Context, updateID int) (*Update, error)
- func (c *Client) GetUpdates(ctx context.Context, limit int) ([]Update, error)
- func (c *Client) SendMessage(ctx context.Context, chatID int64, text string) error
- func (c *Client) SetHTTPDoer(doer apiclient.HTTPDoer)
- type Config
- type Instance
- type Message
- type MessageDetail
- type MessageSummary
- type Update
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chat ¶
type Chat struct {
ID int64 `json:"id"`
Type string `json:"type"`
Title string `json:"title,omitempty"`
}
Chat represents a Telegram chat.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Telegram Bot API client.
func (*Client) AckUpdate ¶
AckUpdate acknowledges all updates up to and including updateID by calling getUpdates with offset = updateID + 1. This permanently removes those updates from the pending queue.
func (*Client) GetUpdate ¶
GetUpdate fetches all pending updates and returns the one matching updateID. Returns an error if the update is not found among pending updates.
func (*Client) GetUpdates ¶
GetUpdates fetches pending updates from the Telegram Bot API. It does not pass an offset, so this is a read-only peek at pending messages.
func (*Client) SendMessage ¶ added in v0.13.0
SendMessage sends a text message to the given chat via the Telegram Bot API.
func (*Client) SetHTTPDoer ¶
SetHTTPDoer replaces the HTTP client used for API requests.
type Config ¶
type Config struct {
Name string `mapstructure:"name"`
Token string `mapstructure:"token"`
Description string `mapstructure:"description"`
AllowedUsers []int64 `mapstructure:"allowed_users"`
}
Config holds the configuration for a single Telegram bot instance.
func LoadConfigs ¶
LoadConfigs reads a .humanconfig YAML file from dir and returns the list of configured Telegram instances. Returns nil and no error if the file does not exist.
type Instance ¶
Instance represents a configured Telegram bot ready for use.
func LoadInstances ¶
LoadInstances reads config, applies env overrides, creates clients, and returns ready-to-use Telegram instances.
type Message ¶
type Message struct {
MessageID int `json:"message_id"`
From *User `json:"from,omitempty"`
Chat Chat `json:"chat"`
Date int64 `json:"date"`
Text string `json:"text"`
}
Message represents a Telegram message.
type MessageDetail ¶
type MessageDetail struct {
UpdateID int `json:"update_id"`
MessageID int `json:"message_id"`
From string `json:"from"`
FromID int64 `json:"from_id"`
Username string `json:"username"`
ChatID int64 `json:"chat_id"`
ChatType string `json:"chat_type"`
Date string `json:"date"`
Text string `json:"text"`
}
MessageDetail is the CLI output type for the get command.
type MessageSummary ¶
type MessageSummary struct {
UpdateID int `json:"update_id"`
MessageID int `json:"message_id"`
From string `json:"from"`
Date string `json:"date"`
Text string `json:"text"`
}
MessageSummary is the CLI output type for the list command.