telegram

package
v0.1.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: MIT Imports: 30 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ClientName = "telegram"
)

Variables

This section is empty.

Functions

func IsRetryable

func IsRetryable(err error) bool

Types

type APIError

type APIError struct {
	Method      string
	StatusCode  int
	ErrorCode   int
	Description string
	RetryAfter  time.Duration
}

func (*APIError) Error

func (e *APIError) Error() string

type AnswerCallbackQueryRequest

type AnswerCallbackQueryRequest struct {
	CallbackQueryID string `json:"callback_query_id"`
	Text            string `json:"text,omitempty"`
	ShowAlert       bool   `json:"show_alert,omitempty"`
}

type Audio added in v0.1.9

type Audio struct {
	FileID   string `json:"file_id"`
	FileName string `json:"file_name,omitempty"`
	MIMEType string `json:"mime_type,omitempty"`
	FileSize int64  `json:"file_size,omitempty"`
	Duration int    `json:"duration,omitempty"`
}

type BotAPI

type BotAPI interface {
	GetMe(ctx context.Context) (User, error)
	GetUpdates(ctx context.Context, req GetUpdatesRequest) ([]Update, error)
	GetFile(ctx context.Context, fileID string) (File, error)
	DownloadFile(ctx context.Context, filePath string) ([]byte, error)
	SendMessage(ctx context.Context, req SendMessageRequest) (SentMessage, error)
	SendChatAction(ctx context.Context, req SendChatActionRequest) error
	SendVoice(ctx context.Context, req SendVoiceRequest) (SentMessage, error)
	SendAudio(ctx context.Context, req SendAudioRequest) (SentMessage, error)
	EditMessageText(ctx context.Context, req EditMessageTextRequest) (EditMessageTextResponse, error)
	AnswerCallbackQuery(ctx context.Context, req AnswerCallbackQueryRequest) error
	DeleteMessage(ctx context.Context, req DeleteMessageRequest) error
	SetMyCommands(ctx context.Context, req SetMyCommandsRequest) error
	DeleteMyCommands(ctx context.Context, req DeleteMyCommandsRequest) error
}

type BotCommand

type BotCommand struct {
	Command     string `json:"command"`
	Description string `json:"description"`
}

type BotCommandScope

type BotCommandScope struct {
	Type   string `json:"type"`
	ChatID int64  `json:"chat_id,omitempty"`
}

type CallbackQuery

type CallbackQuery struct {
	ID      string   `json:"id"`
	From    *User    `json:"from"`
	Message *Message `json:"message,omitempty"`
	Data    string   `json:"data,omitempty"`
}

type Chat

type Chat struct {
	ID   int64  `json:"id"`
	Type string `json:"type"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg ClientConfig) (*Client, error)

func (*Client) AnswerCallbackQuery

func (c *Client) AnswerCallbackQuery(ctx context.Context, req AnswerCallbackQueryRequest) error

func (*Client) DeleteMessage

func (c *Client) DeleteMessage(ctx context.Context, req DeleteMessageRequest) error

func (*Client) DeleteMyCommands

func (c *Client) DeleteMyCommands(ctx context.Context, req DeleteMyCommandsRequest) error

func (*Client) DownloadFile

func (c *Client) DownloadFile(ctx context.Context, filePath string) ([]byte, error)

func (*Client) EditMessageText

func (*Client) GetFile

func (c *Client) GetFile(ctx context.Context, fileID string) (File, error)

func (*Client) GetMe

func (c *Client) GetMe(ctx context.Context) (User, error)

func (*Client) GetUpdates

func (c *Client) GetUpdates(ctx context.Context, req GetUpdatesRequest) ([]Update, error)

func (*Client) SendAudio added in v0.1.10

func (c *Client) SendAudio(ctx context.Context, req SendAudioRequest) (SentMessage, error)

func (*Client) SendChatAction

func (c *Client) SendChatAction(ctx context.Context, req SendChatActionRequest) error

func (*Client) SendMessage

func (c *Client) SendMessage(ctx context.Context, req SendMessageRequest) (SentMessage, error)

func (*Client) SendVoice added in v0.1.9

func (c *Client) SendVoice(ctx context.Context, req SendVoiceRequest) (SentMessage, error)

func (*Client) SetMyCommands

func (c *Client) SetMyCommands(ctx context.Context, req SetMyCommandsRequest) error

type ClientConfig

type ClientConfig struct {
	Token      string
	BaseURL    string
	HTTPClient HTTPDoer
}

type Config

type Config struct {
	BaseURL                 string
	APIToken                string
	BotToken                string
	TelegramBaseURL         string
	AllowedUserID           int64
	ClientName              string
	WorkingDir              string
	PollTimeout             time.Duration
	PollLimit               int
	PollRetryDelay          time.Duration
	StreamFlushInterval     time.Duration
	BotHTTPClient           HTTPDoer
	DaemonHTTPClient        *http.Client
	Offset                  *atomic.Int64
	SkipCommandRegistration bool
}

type DeleteMessageRequest

type DeleteMessageRequest struct {
	ChatID    int64 `json:"chat_id"`
	MessageID int64 `json:"message_id"`
}

type DeleteMyCommandsRequest

type DeleteMyCommandsRequest struct {
	Scope *BotCommandScope `json:"scope,omitempty"`
}

type DeliveryAddress

type DeliveryAddress struct {
	ChatID    int64 `json:"chat_id"`
	ThreadID  int64 `json:"thread_id,omitempty"`
	MessageID int64 `json:"message_id,omitempty"`
}

type Document

type Document struct {
	FileID   string `json:"file_id"`
	FileName string `json:"file_name,omitempty"`
	MIMEType string `json:"mime_type,omitempty"`
	FileSize int64  `json:"file_size,omitempty"`
}

type EditMessageTextRequest

type EditMessageTextRequest struct {
	ChatID      int64                 `json:"chat_id"`
	MessageID   int64                 `json:"message_id"`
	Text        string                `json:"text"`
	ParseMode   string                `json:"parse_mode,omitempty"`
	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}

type EditMessageTextResponse

type EditMessageTextResponse struct {
	MessageID int64 `json:"message_id"`
}

type File

type File struct {
	FileID   string `json:"file_id"`
	FilePath string `json:"file_path,omitempty"`
	FileSize int64  `json:"file_size,omitempty"`
}

type GetFileRequest

type GetFileRequest struct {
	FileID string `json:"file_id"`
}

type GetUpdatesRequest

type GetUpdatesRequest struct {
	Offset         int64    `json:"offset,omitempty"`
	Limit          int      `json:"limit,omitempty"`
	TimeoutSeconds int      `json:"timeout,omitempty"`
	AllowedUpdates []string `json:"allowed_updates,omitempty"`
}

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

type InlineKeyboardButton

type InlineKeyboardButton struct {
	Text         string `json:"text"`
	CallbackData string `json:"callback_data,omitempty"`
}

type InlineKeyboardMarkup

type InlineKeyboardMarkup struct {
	InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
}

type Message

type Message struct {
	MessageID       int64       `json:"message_id"`
	MessageThreadID int64       `json:"message_thread_id,omitempty"`
	Date            int64       `json:"date,omitempty"`
	From            *User       `json:"from,omitempty"`
	Chat            Chat        `json:"chat"`
	Text            string      `json:"text,omitempty"`
	Caption         string      `json:"caption,omitempty"`
	Photo           []PhotoSize `json:"photo,omitempty"`
	Document        *Document   `json:"document,omitempty"`
	Voice           *Voice      `json:"voice,omitempty"`
	Audio           *Audio      `json:"audio,omitempty"`
	ReplyToMessage  *Message    `json:"reply_to_message,omitempty"`
}

type PhotoSize

type PhotoSize struct {
	FileID   string `json:"file_id"`
	FileSize int64  `json:"file_size,omitempty"`
	Width    int    `json:"width,omitempty"`
	Height   int    `json:"height,omitempty"`
}

type RestartDeliveryCodec

type RestartDeliveryCodec struct{}

func (RestartDeliveryCodec) ClientName

func (RestartDeliveryCodec) ClientName() string

func (RestartDeliveryCodec) NormalizeRestartDeliveryAddress

func (RestartDeliveryCodec) NormalizeRestartDeliveryAddress(raw json.RawMessage) (json.RawMessage, error)

type RestartDeliverySender

type RestartDeliverySender struct {
	// contains filtered or unexported fields
}

func (*RestartDeliverySender) ClientName

func (s *RestartDeliverySender) ClientName() string

func (*RestartDeliverySender) DeliverRestartNotification

func (s *RestartDeliverySender) DeliverRestartNotification(ctx context.Context, delivery core.ClientDelivery, fallback string) error

type RestartDeliverySenderConfig

type RestartDeliverySenderConfig struct {
	BotToken   string
	BaseURL    string
	HTTPClient HTTPDoer
	API        BotAPI
}

type SendAudioRequest added in v0.1.10

type SendAudioRequest struct {
	ChatID          int64
	MessageThreadID int64
	Audio           []byte
	FileName        string
	Caption         string
	MIMEType        string
}

type SendChatActionRequest

type SendChatActionRequest struct {
	ChatID          int64  `json:"chat_id"`
	MessageThreadID int64  `json:"message_thread_id,omitempty"`
	Action          string `json:"action"`
}

type SendMessageRequest

type SendMessageRequest struct {
	ChatID          int64                 `json:"chat_id"`
	MessageThreadID int64                 `json:"message_thread_id,omitempty"`
	Text            string                `json:"text"`
	ParseMode       string                `json:"parse_mode,omitempty"`
	ReplyMarkup     *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}

type SendVoiceRequest added in v0.1.9

type SendVoiceRequest struct {
	ChatID          int64
	MessageThreadID int64
	Voice           []byte
	FileName        string
	Caption         string
	MIMEType        string
}

type SentMessage

type SentMessage struct {
	MessageID       int64 `json:"message_id"`
	MessageThreadID int64 `json:"message_thread_id,omitempty"`
}

type SetMyCommandsRequest

type SetMyCommandsRequest struct {
	Commands []BotCommand     `json:"commands"`
	Scope    *BotCommandScope `json:"scope,omitempty"`
}

type Update

type Update struct {
	UpdateID      int64          `json:"update_id"`
	Message       *Message       `json:"message,omitempty"`
	CallbackQuery *CallbackQuery `json:"callback_query,omitempty"`
}

type User

type User struct {
	ID       int64  `json:"id"`
	IsBot    bool   `json:"is_bot"`
	Username string `json:"username,omitempty"`
}

type Voice added in v0.1.9

type Voice struct {
	FileID   string `json:"file_id"`
	MIMEType string `json:"mime_type,omitempty"`
	FileSize int64  `json:"file_size,omitempty"`
	Duration int    `json:"duration,omitempty"`
}

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(cfg Config) (*Worker, error)

func (*Worker) Run

func (w *Worker) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL