Documentation
¶
Overview ¶
Package tg provides core Telegram types shared by receiver and sender.
This package contains:
- All Telegram API types (Message, User, Chat, Update, etc.)
- Error types and sentinel errors
- SecretToken for safe token handling
- Base configuration
- Keyboard builders
Usage ¶
import "github.com/prilive-com/galigo/tg"
var msg tg.Message
var err tg.APIError
token := tg.SecretToken("123:ABC...")
Index ¶
- Constants
- Variables
- func DetectSentinel(code int, desc string) error
- func HasLeft(m ChatMember) bool
- func IsAdmin(m ChatMember) bool
- func IsBanned(m ChatMember) bool
- func IsMember(m ChatMember) bool
- func IsOwner(m ChatMember) bool
- func IsRestricted(m ChatMember) bool
- func TimeHTML(unix int64, format, fallbackText string) string
- func TimeMarkdownV2(unix int64, format, fallbackText string) string
- type APIError
- type AcceptedGiftTypes
- type Animation
- type Audio
- type Birthdate
- type BotCommand
- type BotCommandScope
- func BotCommandScopeAllChatAdministrators() BotCommandScope
- func BotCommandScopeAllGroupChats() BotCommandScope
- func BotCommandScopeAllPrivateChats() BotCommandScope
- func BotCommandScopeChat(chatID ChatID) BotCommandScope
- func BotCommandScopeChatAdministrators(chatID ChatID) BotCommandScope
- func BotCommandScopeChatMember(chatID ChatID, userID int64) BotCommandScope
- func BotCommandScopeDefault() BotCommandScope
- type BotDescription
- type BotName
- type BotShortDescription
- type BusinessBotRights
- type BusinessConnection
- type BusinessHours
- type BusinessIntro
- type BusinessLocation
- type BusinessOpeningHoursInterval
- type CallbackGame
- type CallbackQuery
- type Chat
- type ChatAdministratorRights
- type ChatBoost
- type ChatBoostSource
- type ChatBoostSourceGiftCode
- type ChatBoostSourceGiveaway
- type ChatBoostSourcePremium
- type ChatBoostSourceUnknown
- type ChatFullInfo
- type ChatID
- type ChatInviteLink
- type ChatJoinRequest
- type ChatLocation
- type ChatMember
- type ChatMemberAdministrator
- type ChatMemberBanned
- type ChatMemberLeft
- type ChatMemberMember
- type ChatMemberOwner
- type ChatMemberRestricted
- type ChatMemberUpdated
- type ChatOwnerChanged
- type ChatOwnerLeft
- type ChatPermissions
- type ChatPhoto
- type ChatType
- type Checklist
- type ChecklistTask
- type ChosenInlineResult
- type Config
- func (c *Config) Validate() error
- func (c Config) WithBaseURL(url string) Config
- func (c Config) WithCircuitBreaker(enabled bool, threshold uint32, timeout time.Duration) Config
- func (c Config) WithParseMode(mode ParseMode) Config
- func (c Config) WithRateLimits(globalRPS float64, perChatRPS float64) Config
- func (c Config) WithRetries(n int) Config
- func (c Config) WithTimeout(d time.Duration) Config
- func (c Config) WithToken(token string) Config
- type ConfigError
- type Contact
- type Dice
- type Document
- type Editable
- type File
- type ForumTopic
- type ForumTopicClosed
- type ForumTopicCreated
- type ForumTopicEdited
- type ForumTopicReopened
- type Game
- type GameHighScore
- type GeneralForumTopicHidden
- type GeneralForumTopicUnhidden
- type Gift
- type Gifts
- type InlineKeyboardButton
- func Btn(text, callbackData string) InlineKeyboardButton
- func BtnLogin(text string, loginURL LoginURL) InlineKeyboardButton
- func BtnPay(text string) InlineKeyboardButton
- func BtnSwitch(text, query string) InlineKeyboardButton
- func BtnSwitchCurrent(text, query string) InlineKeyboardButton
- func BtnURL(text, url string) InlineKeyboardButton
- func BtnWebApp(text, url string) InlineKeyboardButton
- func Row(buttons ...InlineKeyboardButton) []InlineKeyboardButton
- type InlineKeyboardMarkup
- func Confirm(yesData, noData string) *InlineKeyboardMarkup
- func ConfirmCustom(yesText, yesData, noText, noData string) *InlineKeyboardMarkup
- func Grid[T any](items []T, columns int, btnFunc func(T) InlineKeyboardButton) *InlineKeyboardMarkup
- func InlineKeyboard(rows ...[]InlineKeyboardButton) *InlineKeyboardMarkup
- func Pagination(current, total int, prefix string) *InlineKeyboardMarkup
- type InlineMessage
- type InlineQuery
- type InlineQueryResult
- type InlineQueryResultArticle
- type InlineQueryResultDocument
- type InlineQueryResultPhoto
- type InlineQueryResultUnknown
- type InlineQueryResultsButton
- type InputChecklist
- type InputChecklistTask
- type InputContactMessageContent
- type InputInvoiceMessageContent
- type InputLocationMessageContent
- type InputMessageContent
- type InputTextMessageContent
- type InputVenueMessageContent
- type Keyboard
- func (k *Keyboard) Add(buttons ...InlineKeyboardButton) *Keyboard
- func (k *Keyboard) AllButtons() iter.Seq[InlineKeyboardButton]
- func (k *Keyboard) Build() *InlineKeyboardMarkup
- func (k *Keyboard) Empty() bool
- func (k *Keyboard) Inline() *InlineKeyboardMarkup
- func (k *Keyboard) MarshalJSON() ([]byte, error)
- func (k *Keyboard) Row(buttons ...InlineKeyboardButton) *Keyboard
- func (k *Keyboard) RowCount() int
- func (k *Keyboard) Rows() iter.Seq[[]InlineKeyboardButton]
- type KeyboardButton
- type KeyboardButtonPollType
- type KeyboardButtonRequestChat
- type KeyboardButtonRequestUsers
- type LabeledPrice
- type LinkPreviewOptions
- type Location
- type LoginURL
- type MaskPosition
- type Message
- type MessageEntity
- type MessageID
- type OrderInfo
- type OwnedGift
- type OwnedGifts
- type ParseMode
- type PassportElementError
- type PassportElementErrorDataField
- type PassportElementErrorFile
- type PassportElementErrorFiles
- type PassportElementErrorFrontSide
- type PassportElementErrorReverseSide
- type PassportElementErrorSelfie
- type PassportElementErrorTranslationFile
- type PassportElementErrorTranslationFiles
- type PassportElementErrorUnspecified
- type PhotoSize
- type Poll
- type PollAnswer
- type PollOption
- type PreCheckoutQuery
- type PreparedInlineMessage
- type ReactionType
- type ReplyKeyboardMarkup
- type ReplyKeyboardRemove
- type ReplyParameters
- type ResponseParameters
- type RevenueWithdrawalState
- type RevenueWithdrawalStateFailed
- type RevenueWithdrawalStatePending
- type RevenueWithdrawalStateSucceeded
- type RevenueWithdrawalStateUnknown
- type SecretToken
- type SentWebAppMessage
- type ShippingAddress
- type ShippingOption
- type ShippingQuery
- type StarAmount
- type StarTransaction
- type StarTransactions
- type Sticker
- type StickerSet
- type StoredMessage
- type Story
- type SuccessfulPayment
- type SwitchInlineQueryChosenChat
- type TransactionPartner
- type TransactionPartnerFragment
- type TransactionPartnerOther
- type TransactionPartnerTelegramAPI
- type TransactionPartnerTelegramAds
- type TransactionPartnerUnknown
- type TransactionPartnerUser
- type UniqueGift
- type UniqueGiftBackdrop
- type UniqueGiftBackdropColors
- type UniqueGiftColors
- type UniqueGiftModel
- type UniqueGiftSymbol
- type Update
- type User
- type UserChatBoosts
- type UserProfileAudios
- type UserProfilePhotos
- type ValidationError
- type Venue
- type Video
- type VideoNote
- type VideoQuality
- type Voice
- type WebAppInfo
Constants ¶
const ( ForumColorBlue = 0x6FB9F0 // 7322096 ForumColorYellow = 0xFFD67E // 16766590 ForumColorViolet = 0xCB86DB // 13338331 ForumColorGreen = 0x8EEE98 // 9367192 ForumColorRose = 0xFF93B2 // 16749490 ForumColorRed = 0xFB6F5F // 16478047 )
Forum topic icon colors (official Telegram colors).
const ( GiftRarityUncommon = "uncommon" GiftRarityRare = "rare" GiftRarityEpic = "epic" GiftRarityLegendary = "legendary" )
UniqueGiftModel rarity constants (added in Bot API 9.4).
const ( ButtonStyleDanger = "danger" // Red ButtonStyleSuccess = "success" // Green ButtonStylePrimary = "primary" // Blue )
Button style constants for InlineKeyboardButton and KeyboardButton.
Variables ¶
var ( // API errors ErrForbidden = errors.New("galigo: forbidden") ErrNotFound = errors.New("galigo: not found") ErrTooManyRequests = errors.New("galigo: too many requests") // Message errors ErrMessageNotFound = errors.New("galigo: message not found") ErrMessageNotModified = errors.New("galigo: message not modified") ErrMessageCantBeEdited = errors.New("galigo: message can't be edited") ErrMessageCantBeDeleted = errors.New("galigo: message can't be deleted") ErrMessageTooOld = errors.New("galigo: message too old") // Chat/User errors ErrBotBlocked = errors.New("galigo: bot blocked by user") ErrBotKicked = errors.New("galigo: bot kicked from chat") ErrChatNotFound = errors.New("galigo: chat not found") ErrUserDeactivated = errors.New("galigo: user deactivated") ErrNoRights = errors.New("galigo: not enough rights") // Callback errors ErrCallbackExpired = errors.New("galigo: callback query expired") ErrInvalidCallbackData = errors.New("galigo: invalid callback data") // Client errors ErrRateLimited = errors.New("galigo: rate limit exceeded") ErrCircuitOpen = errors.New("galigo: circuit breaker open") ErrMaxRetries = errors.New("galigo: max retries exceeded") ErrResponseTooLarge = errors.New("galigo: response too large") // Validation errors ErrInvalidToken = errors.New("galigo: invalid bot token format") ErrPathTraversal = errors.New("galigo: path traversal attempt") ErrInvalidConfig = errors.New("galigo: invalid configuration") )
Sentinel errors - use with errors.Is()
Functions ¶
func DetectSentinel ¶
DetectSentinel maps Telegram error codes/descriptions to sentinel errors. Description-based detection is prioritized over HTTP status codes for more specific errors.
Design note: This function uses substring matching on error descriptions, which is inherently fragile if Telegram changes their error messages. However, this approach was chosen over code-only mapping because:
- Telegram uses the same HTTP codes (400, 403) for many different errors
- Description matching provides more specific error identification
- The acceptance test suite validates these mappings against real Telegram responses
If Telegram changes an error message, the acceptance tests will catch the drift.
func IsAdmin ¶
func IsAdmin(m ChatMember) bool
IsAdmin returns true if the member is an administrator (including owner).
func IsMember ¶
func IsMember(m ChatMember) bool
IsMember returns true if the member is a regular member.
func IsOwner ¶
func IsOwner(m ChatMember) bool
IsOwner returns true if the member is the chat owner.
func IsRestricted ¶
func IsRestricted(m ChatMember) bool
IsRestricted returns true if the member is restricted.
func TimeHTML ¶
TimeHTML returns an HTML date/time string for Telegram. Format tokens: r=relative, w=weekday, d=short date, D=long date, t=short time, T=long time. The format parameter must be a valid Telegram format string (e.g. "wDT"), not arbitrary user input. The fallbackText is shown to clients that don't support tg-time and is NOT HTML-escaped. Example: TimeHTML(1647531900, "wDT", "March 17, 2022 15:45") produces <tg-time unix="1647531900" format="wDT">March 17, 2022 15:45</tg-time>
func TimeMarkdownV2 ¶
TimeMarkdownV2 returns a MarkdownV2 date/time string for Telegram. The fallbackText must not contain unescaped MarkdownV2 special characters (e.g. ], [, )). The format parameter must be a valid Telegram format string (e.g. "Dt"). Example: TimeMarkdownV2(1647531900, "wDT", "March 17") produces 
Types ¶
type APIError ¶
type APIError struct {
Code int
Description string
RetryAfter time.Duration
Method string // API method that failed
Parameters *ResponseParameters // Additional response parameters
// contains filtered or unexported fields
}
APIError represents an error response from Telegram API. Use errors.As() to extract details, errors.Is() to match sentinels.
func NewAPIError ¶
NewAPIError creates an APIError with automatic sentinel detection.
func NewAPIErrorWithRetry ¶
func NewAPIErrorWithRetry(method string, code int, description string, retryAfter time.Duration) *APIError
NewAPIErrorWithRetry creates an APIError with retry information.
func (*APIError) IsRetryable ¶
IsRetryable returns true if the error is temporary and may succeed on retry.
type AcceptedGiftTypes ¶
type AcceptedGiftTypes struct {
UnlimitedGifts bool `json:"unlimited_gifts,omitempty"`
LimitedGifts bool `json:"limited_gifts,omitempty"`
UniqueGifts bool `json:"unique_gifts,omitempty"`
PremiumSubscription bool `json:"premium_subscription,omitempty"`
}
AcceptedGiftTypes describes which gift types are accepted.
type Animation ¶
type Animation struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Width int `json:"width"`
Height int `json:"height"`
Duration int `json:"duration"`
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
FileName string `json:"file_name,omitempty"`
MimeType string `json:"mime_type,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
}
Animation represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).
type Audio ¶
type Audio struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Duration int `json:"duration"`
Performer string `json:"performer,omitempty"`
Title string `json:"title,omitempty"`
FileName string `json:"file_name,omitempty"`
MimeType string `json:"mime_type,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
}
Audio represents an audio file.
type Birthdate ¶
type Birthdate struct {
Day int `json:"day"`
Month int `json:"month"`
Year *int `json:"year,omitempty"`
}
Birthdate represents a user's birthdate.
type BotCommand ¶
type BotCommand struct {
Command string `json:"command"` // 1-32 chars, lowercase a-z, 0-9, _
Description string `json:"description"` // 1-256 chars
}
BotCommand represents a bot command shown in the menu.
type BotCommandScope ¶
type BotCommandScope struct {
Type string `json:"type"` // Required: scope type
ChatID ChatID `json:"chat_id,omitempty"` // For chat/chat_administrators/chat_member
UserID int64 `json:"user_id,omitempty"` // For chat_member only
}
BotCommandScope defines which users see specific commands. This is a polymorphic type with several variants.
func BotCommandScopeAllChatAdministrators ¶
func BotCommandScopeAllChatAdministrators() BotCommandScope
BotCommandScopeAllChatAdministrators returns scope for all chat administrators.
func BotCommandScopeAllGroupChats ¶
func BotCommandScopeAllGroupChats() BotCommandScope
BotCommandScopeAllGroupChats returns scope for all group chats.
func BotCommandScopeAllPrivateChats ¶
func BotCommandScopeAllPrivateChats() BotCommandScope
BotCommandScopeAllPrivateChats returns scope for all private chats.
func BotCommandScopeChat ¶
func BotCommandScopeChat(chatID ChatID) BotCommandScope
BotCommandScopeChat returns scope for a specific chat.
func BotCommandScopeChatAdministrators ¶
func BotCommandScopeChatAdministrators(chatID ChatID) BotCommandScope
BotCommandScopeChatAdministrators returns scope for administrators of a specific chat.
func BotCommandScopeChatMember ¶
func BotCommandScopeChatMember(chatID ChatID, userID int64) BotCommandScope
BotCommandScopeChatMember returns scope for a specific member of a chat.
func BotCommandScopeDefault ¶
func BotCommandScopeDefault() BotCommandScope
BotCommandScopeDefault returns the default scope for all users.
type BotDescription ¶
type BotDescription struct {
Description string `json:"description"` // 0-512 chars
}
BotDescription represents the bot's long description (shown in empty chat).
type BotName ¶
type BotName struct {
Name string `json:"name"` // 0-64 chars
}
BotName represents the bot's display name.
type BotShortDescription ¶
type BotShortDescription struct {
ShortDescription string `json:"short_description"` // 0-120 chars
}
BotShortDescription represents the bot's short description (shown in profile/search).
type BusinessBotRights ¶
type BusinessBotRights struct {
CanReply bool `json:"can_reply"`
CanReadMessages bool `json:"can_read_messages"`
CanDeleteAllMessages bool `json:"can_delete_all_messages"`
CanEditName bool `json:"can_edit_name"`
CanEditBio bool `json:"can_edit_bio"`
CanEditProfilePhoto bool `json:"can_edit_profile_photo"`
CanEditUsername bool `json:"can_edit_username"`
CanChangeGiftSettings bool `json:"can_change_gift_settings"`
CanViewGiftsAndStars bool `json:"can_view_gifts_and_stars"`
CanConvertGiftsToStars bool `json:"can_convert_gifts_to_stars"`
CanTransferAndUpgradeGifts bool `json:"can_transfer_and_upgrade_gifts"`
CanTransferStars bool `json:"can_transfer_stars"`
CanManageStories bool `json:"can_manage_stories"`
}
BusinessBotRights describes the rights of a bot in a business account.
type BusinessConnection ¶
type BusinessConnection struct {
ID string `json:"id"`
User User `json:"user"`
UserChatID int64 `json:"user_chat_id"`
Date int64 `json:"date"`
Rights BusinessBotRights `json:"rights"`
IsEnabled bool `json:"is_enabled"`
}
BusinessConnection represents a connection with a business account.
type BusinessHours ¶
type BusinessHours struct {
TimeZoneName string `json:"time_zone_name"`
OpeningHours []BusinessOpeningHoursInterval `json:"opening_hours"`
}
BusinessHours represents business opening hours.
type BusinessIntro ¶
type BusinessIntro struct {
Title string `json:"title,omitempty"`
Message string `json:"message,omitempty"`
Sticker *Sticker `json:"sticker,omitempty"`
}
BusinessIntro represents a business intro.
type BusinessLocation ¶
type BusinessLocation struct {
Address string `json:"address"`
Location *Location `json:"location,omitempty"`
}
BusinessLocation represents a business location.
type BusinessOpeningHoursInterval ¶
type BusinessOpeningHoursInterval struct {
OpeningMinute int `json:"opening_minute"`
ClosingMinute int `json:"closing_minute"`
}
BusinessOpeningHoursInterval represents a time interval.
type CallbackGame ¶
type CallbackGame struct{}
CallbackGame is a placeholder for the "callback_game" button. When pressed, Telegram opens the game.
type CallbackQuery ¶
type CallbackQuery struct {
ID string `json:"id"`
From *User `json:"from"`
Message *Message `json:"message,omitempty"`
InlineMessageID string `json:"inline_message_id,omitempty"`
ChatInstance string `json:"chat_instance"`
Data string `json:"data,omitempty"`
GameShortName string `json:"game_short_name,omitempty"`
}
CallbackQuery represents an incoming callback query from an inline keyboard.
func (*CallbackQuery) MessageSig ¶
func (c *CallbackQuery) MessageSig() (string, int64)
MessageSig implements Editable.
type Chat ¶
type Chat struct {
ID int64 `json:"id"`
Type string `json:"type"`
Title string `json:"title,omitempty"`
Username string `json:"username,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
IsForum bool `json:"is_forum,omitempty"`
Photo *ChatPhoto `json:"photo,omitempty"`
ActiveUsernames []string `json:"active_usernames,omitempty"`
Bio string `json:"bio,omitempty"`
HasPrivateForwards bool `json:"has_private_forwards,omitempty"`
HasRestrictedVoiceAndVideoMessages bool `json:"has_restricted_voice_and_video_messages,omitempty"`
JoinToSendMessages bool `json:"join_to_send_messages,omitempty"`
JoinByRequest bool `json:"join_by_request,omitempty"`
Description string `json:"description,omitempty"`
InviteLink string `json:"invite_link,omitempty"`
PinnedMessage *Message `json:"pinned_message,omitempty"`
SlowModeDelay int `json:"slow_mode_delay,omitempty"`
MessageAutoDeleteTime int `json:"message_auto_delete_time,omitempty"`
HasProtectedContent bool `json:"has_protected_content,omitempty"`
StickerSetName string `json:"sticker_set_name,omitempty"`
CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
LinkedChatID int64 `json:"linked_chat_id,omitempty"`
}
Chat represents a Telegram chat.
type ChatAdministratorRights ¶
type ChatAdministratorRights struct {
IsAnonymous bool `json:"is_anonymous"`
CanManageChat bool `json:"can_manage_chat"`
CanDeleteMessages bool `json:"can_delete_messages"`
CanManageVideoChats bool `json:"can_manage_video_chats"`
CanRestrictMembers bool `json:"can_restrict_members"`
CanPromoteMembers bool `json:"can_promote_members"`
CanChangeInfo bool `json:"can_change_info"`
CanInviteUsers bool `json:"can_invite_users"`
CanPostMessages *bool `json:"can_post_messages,omitempty"`
CanEditMessages *bool `json:"can_edit_messages,omitempty"`
CanPinMessages *bool `json:"can_pin_messages,omitempty"`
CanPostStories *bool `json:"can_post_stories,omitempty"`
CanEditStories *bool `json:"can_edit_stories,omitempty"`
CanDeleteStories *bool `json:"can_delete_stories,omitempty"`
CanManageTopics *bool `json:"can_manage_topics,omitempty"`
CanManageDirectMessages *bool `json:"can_manage_direct_messages,omitempty"`
CanManageTags *bool `json:"can_manage_tags,omitempty"` // 9.5
}
ChatAdministratorRights represents the rights of an administrator in a chat.
func ContentManagerRights ¶
func ContentManagerRights() ChatAdministratorRights
ContentManagerRights returns permissions for content management only.
func FullAdminRights ¶
func FullAdminRights() ChatAdministratorRights
FullAdminRights returns administrator rights with all permissions enabled.
func ModeratorRights ¶
func ModeratorRights() ChatAdministratorRights
ModeratorRights returns typical moderator permissions (no promote, no change info).
type ChatBoost ¶
type ChatBoost struct {
BoostID string `json:"boost_id"`
AddDate int64 `json:"add_date"`
ExpirationDate int64 `json:"expiration_date"`
Source ChatBoostSource `json:"source"`
}
ChatBoost represents a boost added to a chat.
func (*ChatBoost) UnmarshalJSON ¶
UnmarshalJSON handles the polymorphic Source field.
type ChatBoostSource ¶
type ChatBoostSource interface {
GetSource() string
// contains filtered or unexported methods
}
ChatBoostSource describes the source of a chat boost.
type ChatBoostSourceGiftCode ¶
type ChatBoostSourceGiftCode struct {
Source string `json:"source"` // Always "gift_code"
User User `json:"user"`
}
ChatBoostSourceGiftCode represents a boost from a gift code.
func (ChatBoostSourceGiftCode) GetSource ¶
func (ChatBoostSourceGiftCode) GetSource() string
type ChatBoostSourceGiveaway ¶
type ChatBoostSourceGiveaway struct {
Source string `json:"source"` // Always "giveaway"
GiveawayMessageID int `json:"giveaway_message_id"`
User *User `json:"user,omitempty"`
PrizeStarCount int `json:"prize_star_count,omitempty"`
IsUnclaimed bool `json:"is_unclaimed,omitempty"`
}
ChatBoostSourceGiveaway represents a boost from a giveaway.
func (ChatBoostSourceGiveaway) GetSource ¶
func (ChatBoostSourceGiveaway) GetSource() string
type ChatBoostSourcePremium ¶
type ChatBoostSourcePremium struct {
Source string `json:"source"` // Always "premium"
User User `json:"user"`
}
ChatBoostSourcePremium represents a boost from a Premium subscriber.
func (ChatBoostSourcePremium) GetSource ¶
func (ChatBoostSourcePremium) GetSource() string
type ChatBoostSourceUnknown ¶
type ChatBoostSourceUnknown struct {
Source string `json:"source"`
Raw json.RawMessage `json:"-"`
}
ChatBoostSourceUnknown is a fallback for future boost source types.
func (ChatBoostSourceUnknown) GetSource ¶
func (s ChatBoostSourceUnknown) GetSource() string
type ChatFullInfo ¶
type ChatFullInfo struct {
// Basic info (always present)
ID int64 `json:"id"`
Type string `json:"type"` // "private", "group", "supergroup", "channel"
Title string `json:"title,omitempty"`
Username string `json:"username,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
// Optional fields
IsForum bool `json:"is_forum,omitempty"`
AccentColorID int `json:"accent_color_id,omitempty"`
MaxReactionCount int `json:"max_reaction_count,omitempty"`
Photo *ChatPhoto `json:"photo,omitempty"`
FirstProfileAudio *Audio `json:"first_profile_audio,omitempty"` // 9.4
ActiveUsernames []string `json:"active_usernames,omitempty"`
Birthdate *Birthdate `json:"birthdate,omitempty"`
BusinessIntro *BusinessIntro `json:"business_intro,omitempty"`
BusinessLocation *BusinessLocation `json:"business_location,omitempty"`
BusinessOpeningHours *BusinessHours `json:"business_opening_hours,omitempty"`
PersonalChat *Chat `json:"personal_chat,omitempty"`
AvailableReactions []ReactionType `json:"available_reactions,omitempty"`
BackgroundCustomEmojiID string `json:"background_custom_emoji_id,omitempty"`
ProfileAccentColorID *int `json:"profile_accent_color_id,omitempty"`
ProfileBackgroundCustomEmojiID string `json:"profile_background_custom_emoji_id,omitempty"`
EmojiStatusCustomEmojiID string `json:"emoji_status_custom_emoji_id,omitempty"`
EmojiStatusExpirationDate int64 `json:"emoji_status_expiration_date,omitempty"`
Bio string `json:"bio,omitempty"`
HasPrivateForwards bool `json:"has_private_forwards,omitempty"`
HasRestrictedVoiceAndVideoMessages bool `json:"has_restricted_voice_and_video_messages,omitempty"`
JoinToSendMessages bool `json:"join_to_send_messages,omitempty"`
JoinByRequest bool `json:"join_by_request,omitempty"`
Description string `json:"description,omitempty"`
InviteLink string `json:"invite_link,omitempty"`
PinnedMessage *Message `json:"pinned_message,omitempty"`
Permissions *ChatPermissions `json:"permissions,omitempty"`
CanSendPaidMedia bool `json:"can_send_paid_media,omitempty"`
SlowModeDelay int `json:"slow_mode_delay,omitempty"`
UnrestrictBoostCount int `json:"unrestrict_boost_count,omitempty"`
MessageAutoDeleteTime int `json:"message_auto_delete_time,omitempty"`
HasAggressiveAntiSpamEnabled bool `json:"has_aggressive_anti_spam_enabled,omitempty"`
HasHiddenMembers bool `json:"has_hidden_members,omitempty"`
HasProtectedContent bool `json:"has_protected_content,omitempty"`
HasVisibleHistory bool `json:"has_visible_history,omitempty"`
StickerSetName string `json:"sticker_set_name,omitempty"`
CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
CustomEmojiStickerSetName string `json:"custom_emoji_sticker_set_name,omitempty"`
LinkedChatID int64 `json:"linked_chat_id,omitempty"`
Location *ChatLocation `json:"location,omitempty"`
UniqueGiftColors *UniqueGiftColors `json:"unique_gift_colors,omitempty"` // 9.3
PaidMessageStarCount int `json:"paid_message_star_count,omitempty"` // 9.3
}
ChatFullInfo contains full information about a chat. Returned by the getChat method.
type ChatID ¶
type ChatID = any
ChatID represents a Telegram chat identifier. Valid types: int64 (numeric ID) or string (channel username like "@channelusername")
type ChatInviteLink ¶
type ChatInviteLink struct {
InviteLink string `json:"invite_link"`
Creator *User `json:"creator"`
CreatesJoinRequest bool `json:"creates_join_request"`
IsPrimary bool `json:"is_primary"`
IsRevoked bool `json:"is_revoked"`
Name string `json:"name,omitempty"`
ExpireDate int64 `json:"expire_date,omitempty"`
MemberLimit int `json:"member_limit,omitempty"`
PendingJoinRequestCount int `json:"pending_join_request_count,omitempty"`
}
ChatInviteLink represents an invite link for a chat.
type ChatJoinRequest ¶
type ChatJoinRequest struct {
Chat *Chat `json:"chat"`
From *User `json:"from"`
UserChatID int64 `json:"user_chat_id"`
Date int64 `json:"date"`
Bio string `json:"bio,omitempty"`
InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
}
ChatJoinRequest represents a join request sent to a chat.
type ChatLocation ¶
ChatLocation represents a location to which a chat is connected.
type ChatMember ¶
type ChatMember interface {
// Status returns the member's status string.
Status() string
// GetUser returns the user information.
GetUser() *User
// contains filtered or unexported methods
}
ChatMember represents a member of a chat. This is a sealed interface — the concrete types are:
- ChatMemberOwner
- ChatMemberAdministrator
- ChatMemberMember
- ChatMemberRestricted
- ChatMemberLeft
- ChatMemberBanned
func UnmarshalChatMember ¶
func UnmarshalChatMember(data []byte) (ChatMember, error)
UnmarshalChatMember deserializes JSON into the correct ChatMember concrete type.
type ChatMemberAdministrator ¶
type ChatMemberAdministrator struct {
CanBeEdited bool `json:"can_be_edited"`
IsAnonymous bool `json:"is_anonymous"`
CanManageChat bool `json:"can_manage_chat"`
CanDeleteMessages bool `json:"can_delete_messages"`
CanManageVideoChats bool `json:"can_manage_video_chats"`
CanRestrictMembers bool `json:"can_restrict_members"`
CanPromoteMembers bool `json:"can_promote_members"`
CanChangeInfo bool `json:"can_change_info"`
CanInviteUsers bool `json:"can_invite_users"`
CanPostMessages *bool `json:"can_post_messages,omitempty"`
CanEditMessages *bool `json:"can_edit_messages,omitempty"`
CanPinMessages *bool `json:"can_pin_messages,omitempty"`
CanPostStories *bool `json:"can_post_stories,omitempty"`
CanEditStories *bool `json:"can_edit_stories,omitempty"`
CanDeleteStories *bool `json:"can_delete_stories,omitempty"`
CanManageTopics *bool `json:"can_manage_topics,omitempty"`
CanManageDirectMessages *bool `json:"can_manage_direct_messages,omitempty"`
CanManageTags *bool `json:"can_manage_tags,omitempty"` // 9.5
CustomTitle string `json:"custom_title,omitempty"`
// contains filtered or unexported fields
}
ChatMemberAdministrator represents a chat administrator.
func (ChatMemberAdministrator) Status ¶
func (ChatMemberAdministrator) Status() string
type ChatMemberBanned ¶
type ChatMemberBanned struct {
UntilDate int64 `json:"until_date"`
// contains filtered or unexported fields
}
ChatMemberBanned represents a banned user.
func (ChatMemberBanned) Status ¶
func (ChatMemberBanned) Status() string
type ChatMemberLeft ¶
type ChatMemberLeft struct {
// contains filtered or unexported fields
}
ChatMemberLeft represents a user who left the chat.
func (ChatMemberLeft) Status ¶
func (ChatMemberLeft) Status() string
type ChatMemberMember ¶
type ChatMemberMember struct {
UntilDate int64 `json:"until_date,omitempty"`
Tag string `json:"tag,omitempty"` // 9.5
// contains filtered or unexported fields
}
ChatMemberMember represents a regular chat member.
func (ChatMemberMember) Status ¶
func (ChatMemberMember) Status() string
type ChatMemberOwner ¶
type ChatMemberOwner struct {
IsAnonymous bool `json:"is_anonymous"`
CustomTitle string `json:"custom_title,omitempty"`
// contains filtered or unexported fields
}
ChatMemberOwner represents a chat owner.
func (ChatMemberOwner) Status ¶
func (ChatMemberOwner) Status() string
type ChatMemberRestricted ¶
type ChatMemberRestricted struct {
IsMember bool `json:"is_member"`
CanSendMessages bool `json:"can_send_messages"`
CanSendAudios bool `json:"can_send_audios"`
CanSendDocuments bool `json:"can_send_documents"`
CanSendPhotos bool `json:"can_send_photos"`
CanSendVideos bool `json:"can_send_videos"`
CanSendVideoNotes bool `json:"can_send_video_notes"`
CanSendVoiceNotes bool `json:"can_send_voice_notes"`
CanSendPolls bool `json:"can_send_polls"`
CanSendOtherMessages bool `json:"can_send_other_messages"`
CanAddWebPagePreviews bool `json:"can_add_web_page_previews"`
CanChangeInfo bool `json:"can_change_info"`
CanInviteUsers bool `json:"can_invite_users"`
CanPinMessages bool `json:"can_pin_messages"`
CanManageTopics bool `json:"can_manage_topics"`
UntilDate int64 `json:"until_date"`
Tag string `json:"tag,omitempty"` // 9.5
CanEditTag bool `json:"can_edit_tag"` // 9.5 — plain bool, NO omitempty (restriction pattern)
// contains filtered or unexported fields
}
ChatMemberRestricted represents a restricted user.
func (ChatMemberRestricted) Status ¶
func (ChatMemberRestricted) Status() string
type ChatMemberUpdated ¶
type ChatMemberUpdated struct {
Chat *Chat `json:"chat"`
From *User `json:"from"`
Date int64 `json:"date"`
OldChatMember ChatMember `json:"-"`
NewChatMember ChatMember `json:"-"`
InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
ViaChatFolderInviteLink bool `json:"via_chat_folder_invite_link,omitempty"`
}
ChatMemberUpdated represents changes in the status of a chat member.
func (*ChatMemberUpdated) UnmarshalJSON ¶
func (u *ChatMemberUpdated) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom unmarshaling for ChatMemberUpdated. The OldChatMember and NewChatMember fields are ChatMember interfaces that require discriminated union parsing.
type ChatOwnerChanged ¶
type ChatOwnerChanged struct {
NewOwner *User `json:"new_owner"`
}
ChatOwnerChanged is a service message: chat ownership has transferred. Added in Bot API 9.4.
type ChatOwnerLeft ¶
type ChatOwnerLeft struct {
NewOwner *User `json:"new_owner,omitempty"`
}
ChatOwnerLeft is a service message: the chat owner left the chat. Added in Bot API 9.4.
type ChatPermissions ¶
type ChatPermissions struct {
CanSendMessages *bool `json:"can_send_messages,omitempty"`
CanSendAudios *bool `json:"can_send_audios,omitempty"`
CanSendDocuments *bool `json:"can_send_documents,omitempty"`
CanSendPhotos *bool `json:"can_send_photos,omitempty"`
CanSendVideos *bool `json:"can_send_videos,omitempty"`
CanSendVideoNotes *bool `json:"can_send_video_notes,omitempty"`
CanSendVoiceNotes *bool `json:"can_send_voice_notes,omitempty"`
CanSendPolls *bool `json:"can_send_polls,omitempty"`
CanSendOtherMessages *bool `json:"can_send_other_messages,omitempty"`
CanAddWebPagePreviews *bool `json:"can_add_web_page_previews,omitempty"`
CanChangeInfo *bool `json:"can_change_info,omitempty"`
CanInviteUsers *bool `json:"can_invite_users,omitempty"`
CanPinMessages *bool `json:"can_pin_messages,omitempty"`
CanManageTopics *bool `json:"can_manage_topics,omitempty"`
CanEditTag *bool `json:"can_edit_tag,omitempty"` // 9.5
}
ChatPermissions describes actions that a non-administrator user is allowed to take in a chat. Pointer fields distinguish between "not set" (nil) and "explicitly false" (*false).
func AllPermissions ¶
func AllPermissions() ChatPermissions
AllPermissions returns ChatPermissions with all permissions enabled.
func NoPermissions ¶
func NoPermissions() ChatPermissions
NoPermissions returns ChatPermissions with all permissions disabled.
func ReadOnlyPermissions ¶
func ReadOnlyPermissions() ChatPermissions
ReadOnlyPermissions returns permissions for read-only access (no sending).
func TextOnlyPermissions ¶
func TextOnlyPermissions() ChatPermissions
TextOnlyPermissions returns permissions for text-only messaging.
type ChatPhoto ¶
type ChatPhoto struct {
SmallFileID string `json:"small_file_id"`
SmallFileUniqueID string `json:"small_file_unique_id"`
BigFileID string `json:"big_file_id"`
BigFileUniqueID string `json:"big_file_unique_id"`
}
ChatPhoto represents a chat photo.
type ChatType ¶
type ChatType string
ChatType represents the type of a Telegram chat.
const ( ChatTypePrivate ChatType = "private" ChatTypeGroup ChatType = "group" ChatTypeSupergroup ChatType = "supergroup" ChatTypeChannel ChatType = "channel" )
Supported chat types.
type Checklist ¶
type Checklist struct {
Title string `json:"title"`
TitleEntities []MessageEntity `json:"title_entities,omitempty"`
Tasks []ChecklistTask `json:"tasks"`
OthersCanAddTasks bool `json:"others_can_add_tasks"`
OthersCanMarkTasksAsDone bool `json:"others_can_mark_tasks_as_done"`
}
Checklist represents a checklist in a received message.
type ChecklistTask ¶
type ChecklistTask struct {
ID int `json:"id"`
Text string `json:"text"`
TextEntities []MessageEntity `json:"text_entities,omitempty"`
IsDone bool `json:"is_done"`
CompletedByID int64 `json:"completed_by_id,omitempty"`
}
ChecklistTask represents a task in a received checklist.
type ChosenInlineResult ¶
type ChosenInlineResult struct {
ResultID string `json:"result_id"`
From *User `json:"from"`
Location *Location `json:"location,omitempty"`
InlineMessageID string `json:"inline_message_id,omitempty"`
Query string `json:"query"`
}
ChosenInlineResult represents a result chosen by a user.
type Config ¶
type Config struct {
// BaseURL is the Telegram Bot API base URL.
// Default: https://api.telegram.org
BaseURL string
// Token is the bot authentication token.
Token SecretToken
// Timeouts
RequestTimeout time.Duration // Default: 30s
ConnectTimeout time.Duration // Default: 10s
// Retry settings
MaxRetries int // Default: 3
RetryBaseWait time.Duration // Default: 1s
RetryMaxWait time.Duration // Default: 30s
// Rate limiting
RateLimit float64 // Requests per second, 0 = disabled
RateLimitBurst int // Burst size for rate limiter
PerChatRPS float64 // Per-chat rate limit
PerChatBurst int // Per-chat burst size
GlobalRPS float64 // Global rate limit
GlobalBurst int // Global burst size
// Circuit breaker
CircuitBreakerEnabled bool
CircuitBreakerThreshold uint32 // Failure threshold
CircuitBreakerInterval time.Duration // Counting interval
CircuitBreakerTimeout time.Duration // Reset timeout
// Default message options
DefaultParseMode ParseMode
DisableWebPagePreview bool
DisableNotification bool
ProtectContent bool
AllowSendingWithoutReply bool
}
Config holds shared configuration for Telegram operations. Use functional options or environment variables to customize.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
func (Config) WithBaseURL ¶
WithBaseURL returns a copy of the config with the given base URL.
func (Config) WithCircuitBreaker ¶
WithCircuitBreaker returns a copy with circuit breaker settings.
func (Config) WithParseMode ¶
WithParseMode returns a copy of the config with the given default parse mode.
func (Config) WithRateLimits ¶
WithRateLimits returns a copy with rate limiting settings.
func (Config) WithRetries ¶
WithRetries returns a copy of the config with the given max retries.
func (Config) WithTimeout ¶
WithTimeout returns a copy of the config with the given request timeout.
type ConfigError ¶
ConfigError represents a configuration error.
func NewConfigError ¶
func NewConfigError(key, message string) *ConfigError
NewConfigError creates a new ConfigError.
func (*ConfigError) Error ¶
func (e *ConfigError) Error() string
type Contact ¶
type Contact struct {
PhoneNumber string `json:"phone_number"`
FirstName string `json:"first_name"`
LastName string `json:"last_name,omitempty"`
UserID int64 `json:"user_id,omitempty"`
Vcard string `json:"vcard,omitempty"`
}
Contact represents a phone contact.
type Document ¶
type Document struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
FileName string `json:"file_name,omitempty"`
MimeType string `json:"mime_type,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
}
Document represents a general file.
type Editable ¶
type Editable interface {
// MessageSig returns message identifier and chat ID.
// For inline messages: return (inline_message_id, 0)
// For regular messages: return (message_id as string, chat_id)
MessageSig() (messageID string, chatID int64)
}
Editable represents anything that can be edited (message, callback, stored reference). Implement this interface to edit messages stored in your database.
type File ¶
type File struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
FileSize int64 `json:"file_size,omitempty"`
FilePath string `json:"file_path,omitempty"`
}
File represents a file ready to be downloaded.
type ForumTopic ¶
type ForumTopic struct {
MessageThreadID int `json:"message_thread_id"`
Name string `json:"name"`
IconColor int `json:"icon_color"`
IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
}
ForumTopic represents a forum topic.
type ForumTopicClosed ¶
type ForumTopicClosed struct{}
ForumTopicClosed represents a service message about a closed topic.
type ForumTopicCreated ¶
type ForumTopicCreated struct {
Name string `json:"name"`
IconColor int `json:"icon_color"`
IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
}
ForumTopicCreated represents a service message about a new forum topic.
type ForumTopicEdited ¶
type ForumTopicEdited struct {
Name string `json:"name,omitempty"`
IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
}
ForumTopicEdited represents a service message about an edited topic.
type ForumTopicReopened ¶
type ForumTopicReopened struct{}
ForumTopicReopened represents a service message about a reopened topic.
type Game ¶
type Game struct {
Title string `json:"title"`
Description string `json:"description"`
Photo []PhotoSize `json:"photo"`
Text string `json:"text,omitempty"`
TextEntities []MessageEntity `json:"text_entities,omitempty"`
Animation *Animation `json:"animation,omitempty"`
}
Game represents a game.
type GameHighScore ¶
type GameHighScore struct {
Position int `json:"position"`
User User `json:"user"`
Score int `json:"score"`
}
GameHighScore represents one row of the high scores table.
type GeneralForumTopicHidden ¶
type GeneralForumTopicHidden struct{}
GeneralForumTopicHidden represents a service message about hidden General topic.
type GeneralForumTopicUnhidden ¶
type GeneralForumTopicUnhidden struct{}
GeneralForumTopicUnhidden represents a service message about unhidden General topic.
type Gift ¶
type Gift struct {
ID string `json:"id"`
Sticker Sticker `json:"sticker"`
StarCount int `json:"star_count"`
UpgradeStarCount int `json:"upgrade_star_count,omitempty"`
TotalCount int `json:"total_count,omitempty"`
RemainingCount int `json:"remaining_count,omitempty"`
}
Gift represents a gift that can be sent.
type Gifts ¶
type Gifts struct {
Gifts []Gift `json:"gifts"`
}
Gifts represents a list of available gifts.
type InlineKeyboardButton ¶
type InlineKeyboardButton struct {
Text string `json:"text"`
IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"` // 9.4
Style string `json:"style,omitempty"` // 9.4: "danger"|"success"|"primary"
URL string `json:"url,omitempty"`
CallbackData string `json:"callback_data,omitempty"`
WebApp *WebAppInfo `json:"web_app,omitempty"`
LoginURL *LoginURL `json:"login_url,omitempty"`
SwitchInlineQuery string `json:"switch_inline_query,omitempty"`
SwitchInlineQueryCurrentChat string `json:"switch_inline_query_current_chat,omitempty"`
SwitchInlineQueryChosenChat *SwitchInlineQueryChosenChat `json:"switch_inline_query_chosen_chat,omitempty"`
Pay bool `json:"pay,omitempty"`
}
InlineKeyboardButton represents a button in an inline keyboard.
func Btn ¶
func Btn(text, callbackData string) InlineKeyboardButton
Btn creates a callback button (most common type).
func BtnLogin ¶
func BtnLogin(text string, loginURL LoginURL) InlineKeyboardButton
BtnLogin creates a login URL button.
func BtnPay ¶
func BtnPay(text string) InlineKeyboardButton
BtnPay creates a Pay button (must be first in first row).
func BtnSwitch ¶
func BtnSwitch(text, query string) InlineKeyboardButton
BtnSwitch creates an inline query switch button.
func BtnSwitchCurrent ¶
func BtnSwitchCurrent(text, query string) InlineKeyboardButton
BtnSwitchCurrent creates an inline query switch button for current chat.
func BtnWebApp ¶
func BtnWebApp(text, url string) InlineKeyboardButton
BtnWebApp creates a Web App button.
func Row ¶
func Row(buttons ...InlineKeyboardButton) []InlineKeyboardButton
Row creates a row of buttons (for use with InlineKeyboard).
func (InlineKeyboardButton) WithIcon ¶
func (b InlineKeyboardButton) WithIcon(customEmojiID string) InlineKeyboardButton
WithIcon returns a copy of the button with a custom emoji icon. The bot must be eligible to use custom emoji in the message.
func (InlineKeyboardButton) WithStyle ¶
func (b InlineKeyboardButton) WithStyle(style string) InlineKeyboardButton
WithStyle returns a copy of the button with the given style. Valid values: ButtonStyleDanger ("danger"), ButtonStyleSuccess ("success"), ButtonStylePrimary ("primary").
type InlineKeyboardMarkup ¶
type InlineKeyboardMarkup struct {
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
}
InlineKeyboardMarkup represents an inline keyboard attached to a message.
func Confirm ¶
func Confirm(yesData, noData string) *InlineKeyboardMarkup
Confirm creates a Yes/No confirmation keyboard.
func ConfirmCustom ¶
func ConfirmCustom(yesText, yesData, noText, noData string) *InlineKeyboardMarkup
ConfirmCustom creates a confirmation keyboard with custom labels.
func Grid ¶
func Grid[T any](items []T, columns int, btnFunc func(T) InlineKeyboardButton) *InlineKeyboardMarkup
Grid creates a keyboard with buttons arranged in a grid.
func InlineKeyboard ¶
func InlineKeyboard(rows ...[]InlineKeyboardButton) *InlineKeyboardMarkup
InlineKeyboard creates a keyboard from rows of buttons.
func Pagination ¶
func Pagination(current, total int, prefix string) *InlineKeyboardMarkup
Pagination creates a pagination keyboard.
type InlineMessage ¶
type InlineMessage struct {
InlineMessageID string `json:"inline_message_id"`
}
InlineMessage represents an inline message reference.
func (InlineMessage) MessageSig ¶
func (m InlineMessage) MessageSig() (string, int64)
MessageSig implements Editable for inline messages.
type InlineQuery ¶
type InlineQuery struct {
ID string `json:"id"`
From *User `json:"from"`
Query string `json:"query"`
Offset string `json:"offset"`
ChatType string `json:"chat_type,omitempty"`
Location *Location `json:"location,omitempty"`
}
InlineQuery represents an incoming inline query.
type InlineQueryResult ¶
type InlineQueryResult interface {
GetType() string
// contains filtered or unexported methods
}
InlineQueryResult represents one result of an inline query.
type InlineQueryResultArticle ¶
type InlineQueryResultArticle struct {
Type string `json:"type"` // Always "article"
ID string `json:"id"`
Title string `json:"title"`
InputMessageContent InputMessageContent `json:"input_message_content"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
URL string `json:"url,omitempty"`
HideURL bool `json:"hide_url,omitempty"`
Description string `json:"description,omitempty"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
ThumbnailWidth int `json:"thumbnail_width,omitempty"`
ThumbnailHeight int `json:"thumbnail_height,omitempty"`
}
InlineQueryResultArticle represents a link to an article or web page.
func (InlineQueryResultArticle) GetType ¶
func (InlineQueryResultArticle) GetType() string
type InlineQueryResultDocument ¶
type InlineQueryResultDocument struct {
Type string `json:"type"` // Always "document"
ID string `json:"id"`
Title string `json:"title"`
DocumentURL string `json:"document_url"`
MimeType string `json:"mime_type"`
Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
Description string `json:"description,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
ThumbnailURL string `json:"thumbnail_url,omitempty"`
ThumbnailWidth int `json:"thumbnail_width,omitempty"`
ThumbnailHeight int `json:"thumbnail_height,omitempty"`
}
InlineQueryResultDocument represents a link to a file.
func (InlineQueryResultDocument) GetType ¶
func (InlineQueryResultDocument) GetType() string
type InlineQueryResultPhoto ¶
type InlineQueryResultPhoto struct {
Type string `json:"type"` // Always "photo"
ID string `json:"id"`
PhotoURL string `json:"photo_url"`
ThumbnailURL string `json:"thumbnail_url"`
PhotoWidth int `json:"photo_width,omitempty"`
PhotoHeight int `json:"photo_height,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
InlineQueryResultPhoto represents a link to a photo.
func (InlineQueryResultPhoto) GetType ¶
func (InlineQueryResultPhoto) GetType() string
type InlineQueryResultUnknown ¶
type InlineQueryResultUnknown struct {
Type string `json:"type"`
Raw json.RawMessage `json:"-"`
}
InlineQueryResultUnknown is a fallback for unknown/future result types.
func (InlineQueryResultUnknown) GetType ¶
func (r InlineQueryResultUnknown) GetType() string
type InlineQueryResultsButton ¶
type InlineQueryResultsButton struct {
Text string `json:"text"`
WebApp *WebAppInfo `json:"web_app,omitempty"`
StartParameter string `json:"start_parameter,omitempty"`
}
InlineQueryResultsButton represents a button above inline query results.
type InputChecklist ¶
type InputChecklist struct {
Title string `json:"title"`
ParseMode string `json:"parse_mode,omitempty"`
TitleEntities []MessageEntity `json:"title_entities,omitempty"`
Tasks []InputChecklistTask `json:"tasks"`
OthersCanAddTasks bool `json:"others_can_add_tasks,omitempty"`
OthersCanMarkTasksAsDone bool `json:"others_can_mark_tasks_as_done,omitempty"`
}
InputChecklist represents a checklist to be sent.
type InputChecklistTask ¶
type InputChecklistTask struct {
ID int `json:"id"`
Text string `json:"text"`
ParseMode string `json:"parse_mode,omitempty"`
TextEntities []MessageEntity `json:"text_entities,omitempty"`
}
InputChecklistTask represents a task in a checklist to be sent.
type InputContactMessageContent ¶
type InputContactMessageContent struct {
PhoneNumber string `json:"phone_number"`
FirstName string `json:"first_name"`
LastName string `json:"last_name,omitempty"`
VCard string `json:"vcard,omitempty"`
}
InputContactMessageContent represents contact content for an inline query result.
type InputInvoiceMessageContent ¶
type InputInvoiceMessageContent struct {
Title string `json:"title"`
Description string `json:"description"`
Payload string `json:"payload"`
ProviderToken string `json:"provider_token,omitempty"`
Currency string `json:"currency"`
Prices []LabeledPrice `json:"prices"`
MaxTipAmount int `json:"max_tip_amount,omitempty"`
SuggestedTipAmounts []int `json:"suggested_tip_amounts,omitempty"`
ProviderData string `json:"provider_data,omitempty"`
PhotoURL string `json:"photo_url,omitempty"`
PhotoSize int `json:"photo_size,omitempty"`
PhotoWidth int `json:"photo_width,omitempty"`
PhotoHeight int `json:"photo_height,omitempty"`
NeedName bool `json:"need_name,omitempty"`
NeedPhoneNumber bool `json:"need_phone_number,omitempty"`
NeedEmail bool `json:"need_email,omitempty"`
NeedShippingAddress bool `json:"need_shipping_address,omitempty"`
SendPhoneNumberToProvider bool `json:"send_phone_number_to_provider,omitempty"`
SendEmailToProvider bool `json:"send_email_to_provider,omitempty"`
IsFlexible bool `json:"is_flexible,omitempty"`
}
InputInvoiceMessageContent represents invoice content for an inline query result.
type InputLocationMessageContent ¶
type InputLocationMessageContent struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
LivePeriod int `json:"live_period,omitempty"`
Heading int `json:"heading,omitempty"`
ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
}
InputLocationMessageContent represents location content for an inline query result.
type InputMessageContent ¶
type InputMessageContent interface {
// contains filtered or unexported methods
}
InputMessageContent represents the content of a message to be sent as a result of an inline query.
type InputTextMessageContent ¶
type InputTextMessageContent struct {
MessageText string `json:"message_text"`
ParseMode string `json:"parse_mode,omitempty"`
Entities []MessageEntity `json:"entities,omitempty"`
LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
}
InputTextMessageContent represents text content for an inline query result.
type InputVenueMessageContent ¶
type InputVenueMessageContent struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Title string `json:"title"`
Address string `json:"address"`
FoursquareID string `json:"foursquare_id,omitempty"`
FoursquareType string `json:"foursquare_type,omitempty"`
GooglePlaceID string `json:"google_place_id,omitempty"`
GooglePlaceType string `json:"google_place_type,omitempty"`
}
InputVenueMessageContent represents venue content for an inline query result.
type Keyboard ¶
type Keyboard struct {
// contains filtered or unexported fields
}
Keyboard builds inline keyboards fluently.
func (*Keyboard) Add ¶
func (k *Keyboard) Add(buttons ...InlineKeyboardButton) *Keyboard
Add appends buttons to the last row, or creates a new row if empty.
func (*Keyboard) AllButtons ¶
func (k *Keyboard) AllButtons() iter.Seq[InlineKeyboardButton]
AllButtons returns an iterator over all buttons.
func (*Keyboard) Build ¶
func (k *Keyboard) Build() *InlineKeyboardMarkup
Build returns the completed InlineKeyboardMarkup.
func (*Keyboard) Inline ¶
func (k *Keyboard) Inline() *InlineKeyboardMarkup
Inline returns the completed InlineKeyboardMarkup (alias for Build).
func (*Keyboard) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Keyboard) Row ¶
func (k *Keyboard) Row(buttons ...InlineKeyboardButton) *Keyboard
Row adds a row of buttons.
type KeyboardButton ¶
type KeyboardButton struct {
Text string `json:"text"`
IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"` // 9.4
Style string `json:"style,omitempty"` // 9.4
RequestUsers *KeyboardButtonRequestUsers `json:"request_users,omitempty"`
RequestChat *KeyboardButtonRequestChat `json:"request_chat,omitempty"`
RequestContact bool `json:"request_contact,omitempty"`
RequestLocation bool `json:"request_location,omitempty"`
RequestPoll *KeyboardButtonPollType `json:"request_poll,omitempty"`
WebApp *WebAppInfo `json:"web_app,omitempty"`
}
KeyboardButton represents one button of a reply keyboard.
type KeyboardButtonPollType ¶
type KeyboardButtonPollType struct {
Type string `json:"type,omitempty"` // "quiz" or "regular"
}
KeyboardButtonPollType limits polls to a specific type.
type KeyboardButtonRequestChat ¶
type KeyboardButtonRequestChat struct {
RequestID int `json:"request_id"`
ChatIsChannel bool `json:"chat_is_channel"`
ChatIsForum *bool `json:"chat_is_forum,omitempty"`
ChatHasUsername *bool `json:"chat_has_username,omitempty"`
ChatIsCreated bool `json:"chat_is_created,omitempty"`
UserAdministratorRights *ChatAdministratorRights `json:"user_administrator_rights,omitempty"`
BotAdministratorRights *ChatAdministratorRights `json:"bot_administrator_rights,omitempty"`
BotIsMember bool `json:"bot_is_member,omitempty"`
}
KeyboardButtonRequestChat defines criteria for requesting a chat.
type KeyboardButtonRequestUsers ¶
type KeyboardButtonRequestUsers struct {
RequestID int `json:"request_id"`
UserIsBot *bool `json:"user_is_bot,omitempty"`
UserIsPremium *bool `json:"user_is_premium,omitempty"`
MaxQuantity int `json:"max_quantity,omitempty"`
}
KeyboardButtonRequestUsers defines criteria for requesting users.
type LabeledPrice ¶
type LabeledPrice struct {
Label string `json:"label"`
Amount int `json:"amount"` // Smallest currency unit (cents, etc.)
}
LabeledPrice represents a portion of the price for goods or services.
type LinkPreviewOptions ¶
type LinkPreviewOptions struct {
IsDisabled bool `json:"is_disabled,omitempty"`
URL string `json:"url,omitempty"`
PreferSmallMedia bool `json:"prefer_small_media,omitempty"`
PreferLargeMedia bool `json:"prefer_large_media,omitempty"`
ShowAboveText bool `json:"show_above_text,omitempty"`
}
LinkPreviewOptions describes options for link preview generation. These are rendering hints - Telegram may ignore them based on URL availability, metadata, or user settings.
https://core.telegram.org/bots/api#linkpreviewoptions
func (*LinkPreviewOptions) Validate ¶
func (o *LinkPreviewOptions) Validate() error
Validate checks for invalid option combinations.
type Location ¶
type Location struct {
Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"`
HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
LivePeriod int `json:"live_period,omitempty"`
Heading int `json:"heading,omitempty"`
ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
}
Location represents a point on the map.
type LoginURL ¶
type LoginURL struct {
URL string `json:"url"`
ForwardText string `json:"forward_text,omitempty"`
BotUsername string `json:"bot_username,omitempty"`
RequestWriteAccess bool `json:"request_write_access,omitempty"`
}
LoginURL represents HTTP URL login button parameters.
type MaskPosition ¶
type MaskPosition struct {
Point string `json:"point"` // "forehead", "eyes", "mouth", "chin"
XShift float64 `json:"x_shift"`
YShift float64 `json:"y_shift"`
Scale float64 `json:"scale"`
}
MaskPosition describes the position of a mask on a face.
type Message ¶
type Message struct {
MessageID int `json:"message_id"`
MessageThreadID int `json:"message_thread_id,omitempty"`
From *User `json:"from,omitempty"`
SenderChat *Chat `json:"sender_chat,omitempty"`
Date int64 `json:"date"`
Chat *Chat `json:"chat"`
ForwardFrom *User `json:"forward_from,omitempty"`
ForwardFromChat *Chat `json:"forward_from_chat,omitempty"`
ForwardDate int64 `json:"forward_date,omitempty"`
IsTopicMessage bool `json:"is_topic_message,omitempty"`
IsAutomaticForward bool `json:"is_automatic_forward,omitempty"`
ReplyToMessage *Message `json:"reply_to_message,omitempty"`
ViaBot *User `json:"via_bot,omitempty"`
EditDate int64 `json:"edit_date,omitempty"`
HasProtectedContent bool `json:"has_protected_content,omitempty"`
MediaGroupID string `json:"media_group_id,omitempty"`
AuthorSignature string `json:"author_signature,omitempty"`
Text string `json:"text,omitempty"`
Entities []MessageEntity `json:"entities,omitempty"`
Caption string `json:"caption,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
Photo []PhotoSize `json:"photo,omitempty"`
Document *Document `json:"document,omitempty"`
Animation *Animation `json:"animation,omitempty"`
Video *Video `json:"video,omitempty"`
Audio *Audio `json:"audio,omitempty"`
Voice *Voice `json:"voice,omitempty"`
Sticker *Sticker `json:"sticker,omitempty"`
VideoNote *VideoNote `json:"video_note,omitempty"`
Contact *Contact `json:"contact,omitempty"`
Location *Location `json:"location,omitempty"`
Venue *Venue `json:"venue,omitempty"`
Poll *Poll `json:"poll,omitempty"`
NewChatMembers []User `json:"new_chat_members,omitempty"`
LeftChatMember *User `json:"left_chat_member,omitempty"`
NewChatTitle string `json:"new_chat_title,omitempty"`
NewChatPhoto []PhotoSize `json:"new_chat_photo,omitempty"`
DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"`
GroupChatCreated bool `json:"group_chat_created,omitempty"`
SupergroupChatCreated bool `json:"supergroup_chat_created,omitempty"`
ChannelChatCreated bool `json:"channel_chat_created,omitempty"`
ChatOwnerLeft *ChatOwnerLeft `json:"chat_owner_left,omitempty"` // 9.4
ChatOwnerChanged *ChatOwnerChanged `json:"chat_owner_changed,omitempty"` // 9.4
SenderTag string `json:"sender_tag,omitempty"` // 9.5
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
Message represents a Telegram message.
func (*Message) MessageSig ¶
MessageSig implements Editable.
type MessageEntity ¶
type MessageEntity struct {
Type string `json:"type"`
Offset int `json:"offset"`
Length int `json:"length"`
URL string `json:"url,omitempty"`
User *User `json:"user,omitempty"`
Language string `json:"language,omitempty"`
CustomEmojiID string `json:"custom_emoji_id,omitempty"`
UnixTime int64 `json:"unix_time,omitempty"` // 9.5: date_time entity
DateTimeFormat string `json:"date_time_format,omitempty"` // 9.5: date_time entity
}
MessageEntity represents a special entity in a text message.
type MessageID ¶
type MessageID struct {
MessageID int `json:"message_id"`
}
MessageID represents a message identifier (returned by copyMessage).
type OrderInfo ¶
type OrderInfo struct {
Name string `json:"name,omitempty"`
PhoneNumber string `json:"phone_number,omitempty"`
Email string `json:"email,omitempty"`
ShippingAddress ShippingAddress `json:"shipping_address,omitempty"`
}
OrderInfo represents information about an order.
type OwnedGift ¶
type OwnedGift struct {
Type string `json:"type"` // "regular" or "unique"
Gift *Gift `json:"gift,omitempty"`
OwnedGiftID string `json:"owned_gift_id,omitempty"`
// Sender info
SenderUser *User `json:"sender_user,omitempty"`
SendDate int64 `json:"send_date"`
// Message
Text string `json:"text,omitempty"`
TextEntities []MessageEntity `json:"text_entities,omitempty"`
// State flags
IsSaved bool `json:"is_saved,omitempty"`
CanBeUpgraded bool `json:"can_be_upgraded,omitempty"`
WasRefunded bool `json:"was_refunded,omitempty"`
// Star values
ConvertStarCount int `json:"convert_star_count,omitempty"`
PrepaidUpgradeStarCount int `json:"prepaid_upgrade_star_count,omitempty"`
TransferStarCount int `json:"transfer_star_count,omitempty"`
}
OwnedGift represents a gift owned by a user.
type OwnedGifts ¶
type OwnedGifts struct {
TotalCount int `json:"total_count"`
Gifts []OwnedGift `json:"gifts"`
NextOffset string `json:"next_offset,omitempty"`
}
OwnedGifts represents a list of gifts owned by a user.
type ParseMode ¶
type ParseMode string
ParseMode defines the text formatting mode for messages.
const ( ParseModeHTML ParseMode = "HTML" ParseModeMarkdown ParseMode = "Markdown" ParseModeMarkdownV2 ParseMode = "MarkdownV2" )
Supported parse modes.
type PassportElementError ¶
type PassportElementError interface {
GetSource() string
// contains filtered or unexported methods
}
PassportElementError describes an error in Telegram Passport data. This is a SEND-ONLY type — no UnmarshalJSON needed.
type PassportElementErrorDataField ¶
type PassportElementErrorDataField struct {
Source string `json:"source"` // Always "data"
Type string `json:"type"`
FieldName string `json:"field_name"`
DataHash string `json:"data_hash"`
Message string `json:"message"`
}
PassportElementErrorDataField represents an error in a data field.
func (PassportElementErrorDataField) GetSource ¶
func (PassportElementErrorDataField) GetSource() string
type PassportElementErrorFile ¶
type PassportElementErrorFile struct {
Source string `json:"source"` // Always "file"
Type string `json:"type"`
FileHash string `json:"file_hash"`
Message string `json:"message"`
}
PassportElementErrorFile represents an error with a document scan.
func (PassportElementErrorFile) GetSource ¶
func (PassportElementErrorFile) GetSource() string
type PassportElementErrorFiles ¶
type PassportElementErrorFiles struct {
Source string `json:"source"` // Always "files"
Type string `json:"type"`
FileHashes []string `json:"file_hashes"`
Message string `json:"message"`
}
PassportElementErrorFiles represents an error with multiple document scans.
func (PassportElementErrorFiles) GetSource ¶
func (PassportElementErrorFiles) GetSource() string
type PassportElementErrorFrontSide ¶
type PassportElementErrorFrontSide struct {
Source string `json:"source"` // Always "front_side"
Type string `json:"type"`
FileHash string `json:"file_hash"`
Message string `json:"message"`
}
PassportElementErrorFrontSide represents an error with the front side.
func (PassportElementErrorFrontSide) GetSource ¶
func (PassportElementErrorFrontSide) GetSource() string
type PassportElementErrorReverseSide ¶
type PassportElementErrorReverseSide struct {
Source string `json:"source"` // Always "reverse_side"
Type string `json:"type"`
FileHash string `json:"file_hash"`
Message string `json:"message"`
}
PassportElementErrorReverseSide represents an error with the reverse side.
func (PassportElementErrorReverseSide) GetSource ¶
func (PassportElementErrorReverseSide) GetSource() string
type PassportElementErrorSelfie ¶
type PassportElementErrorSelfie struct {
Source string `json:"source"` // Always "selfie"
Type string `json:"type"`
FileHash string `json:"file_hash"`
Message string `json:"message"`
}
PassportElementErrorSelfie represents an error with the selfie.
func (PassportElementErrorSelfie) GetSource ¶
func (PassportElementErrorSelfie) GetSource() string
type PassportElementErrorTranslationFile ¶
type PassportElementErrorTranslationFile struct {
Source string `json:"source"` // Always "translation_file"
Type string `json:"type"`
FileHash string `json:"file_hash"`
Message string `json:"message"`
}
PassportElementErrorTranslationFile represents an error with one translation file.
func (PassportElementErrorTranslationFile) GetSource ¶
func (PassportElementErrorTranslationFile) GetSource() string
type PassportElementErrorTranslationFiles ¶
type PassportElementErrorTranslationFiles struct {
Source string `json:"source"` // Always "translation_files"
Type string `json:"type"`
FileHashes []string `json:"file_hashes"`
Message string `json:"message"`
}
PassportElementErrorTranslationFiles represents an error with translation files.
func (PassportElementErrorTranslationFiles) GetSource ¶
func (PassportElementErrorTranslationFiles) GetSource() string
type PassportElementErrorUnspecified ¶
type PassportElementErrorUnspecified struct {
Source string `json:"source"` // Always "unspecified"
Type string `json:"type"`
ElementHash string `json:"element_hash"`
Message string `json:"message"`
}
PassportElementErrorUnspecified represents an unspecified error.
func (PassportElementErrorUnspecified) GetSource ¶
func (PassportElementErrorUnspecified) GetSource() string
type PhotoSize ¶
type PhotoSize struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Width int `json:"width"`
Height int `json:"height"`
FileSize int64 `json:"file_size,omitempty"`
}
PhotoSize represents one size of a photo or thumbnail.
type Poll ¶
type Poll struct {
ID string `json:"id"`
Question string `json:"question"`
Options []PollOption `json:"options"`
TotalVoterCount int `json:"total_voter_count"`
IsClosed bool `json:"is_closed"`
IsAnonymous bool `json:"is_anonymous"`
Type string `json:"type"`
AllowsMultipleAnswers bool `json:"allows_multiple_answers"`
CorrectOptionID int `json:"correct_option_id,omitempty"`
Explanation string `json:"explanation,omitempty"`
ExplanationEntities []MessageEntity `json:"explanation_entities,omitempty"`
OpenPeriod int `json:"open_period,omitempty"`
CloseDate int64 `json:"close_date,omitempty"`
}
Poll represents a poll.
type PollAnswer ¶
type PollAnswer struct {
PollID string `json:"poll_id"`
VoterChat *Chat `json:"voter_chat,omitempty"`
User *User `json:"user,omitempty"`
OptionIDs []int `json:"option_ids"`
}
PollAnswer represents an answer of a user in a non-anonymous poll.
type PollOption ¶
PollOption contains information about one answer option in a poll.
type PreCheckoutQuery ¶
type PreCheckoutQuery struct {
ID string `json:"id"`
From *User `json:"from"`
Currency string `json:"currency"`
TotalAmount int `json:"total_amount"`
InvoicePayload string `json:"invoice_payload"`
ShippingOptionID string `json:"shipping_option_id,omitempty"`
OrderInfo *OrderInfo `json:"order_info,omitempty"`
}
PreCheckoutQuery represents an incoming pre-checkout query.
type PreparedInlineMessage ¶
type PreparedInlineMessage struct {
ID string `json:"id"`
ExpirationDate int64 `json:"expiration_date"`
}
PreparedInlineMessage represents a prepared inline message.
type ReactionType ¶
type ReactionType struct {
Type string `json:"type"` // "emoji" or "custom_emoji"
Emoji string `json:"emoji,omitempty"`
CustomEmoji string `json:"custom_emoji_id,omitempty"`
}
ReactionType represents a reaction type.
type ReplyKeyboardMarkup ¶
type ReplyKeyboardMarkup struct {
Keyboard [][]KeyboardButton `json:"keyboard"`
IsPersistent bool `json:"is_persistent,omitempty"`
ResizeKeyboard bool `json:"resize_keyboard,omitempty"`
OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"`
InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`
Selective bool `json:"selective,omitempty"`
}
ReplyKeyboardMarkup represents a custom keyboard with reply options.
type ReplyKeyboardRemove ¶
type ReplyKeyboardRemove struct {
RemoveKeyboard bool `json:"remove_keyboard"` // Always true
Selective bool `json:"selective,omitempty"`
}
ReplyKeyboardRemove requests removal of the custom keyboard.
type ReplyParameters ¶
type ReplyParameters struct {
MessageID int `json:"message_id"`
ChatID any `json:"chat_id,omitempty"`
AllowSendingWithoutReply bool `json:"allow_sending_without_reply,omitempty"`
Quote string `json:"quote,omitempty"`
QuoteParseMode string `json:"quote_parse_mode,omitempty"`
QuoteEntities []MessageEntity `json:"quote_entities,omitempty"`
QuotePosition int `json:"quote_position,omitempty"`
}
ReplyParameters describes reply behavior for a message.
type ResponseParameters ¶
type ResponseParameters struct {
MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
RetryAfter int `json:"retry_after,omitempty"`
}
ResponseParameters contains information about why a request was unsuccessful.
type RevenueWithdrawalState ¶
type RevenueWithdrawalState interface {
// contains filtered or unexported methods
}
RevenueWithdrawalState describes the state of a revenue withdrawal.
type RevenueWithdrawalStateFailed ¶
type RevenueWithdrawalStateFailed struct {
Type string `json:"type"` // Always "failed"
}
RevenueWithdrawalStateFailed represents a failed withdrawal.
type RevenueWithdrawalStatePending ¶
type RevenueWithdrawalStatePending struct {
Type string `json:"type"` // Always "pending"
}
RevenueWithdrawalStatePending represents a pending withdrawal.
type RevenueWithdrawalStateSucceeded ¶
type RevenueWithdrawalStateSucceeded struct {
Type string `json:"type"` // Always "succeeded"
Date int64 `json:"date"`
URL string `json:"url"`
}
RevenueWithdrawalStateSucceeded represents a successful withdrawal.
type RevenueWithdrawalStateUnknown ¶
type RevenueWithdrawalStateUnknown struct {
Type string `json:"type"`
Raw json.RawMessage `json:"-"`
}
RevenueWithdrawalStateUnknown is a fallback for future withdrawal states.
type SecretToken ¶
type SecretToken string
SecretToken wraps a bot token to prevent accidental logging. Implements fmt.Stringer, fmt.GoStringer, slog.LogValuer, and encoding.TextMarshaler.
func (SecretToken) GoString ¶
func (s SecretToken) GoString() string
GoString returns redacted for %#v (fmt.GoStringer).
func (SecretToken) IsEmpty ¶
func (s SecretToken) IsEmpty() bool
IsEmpty returns true if the token is empty.
func (SecretToken) LogValue ¶
func (s SecretToken) LogValue() slog.Value
LogValue returns a redacted value for slog (slog.LogValuer). This ensures the token is never logged even with %+v.
func (SecretToken) MarshalText ¶
func (s SecretToken) MarshalText() ([]byte, error)
MarshalText returns redacted bytes (encoding.TextMarshaler). Prevents accidental JSON/YAML serialization of the token.
func (SecretToken) String ¶
func (s SecretToken) String() string
String returns a redacted placeholder (fmt.Stringer).
func (SecretToken) Value ¶
func (s SecretToken) Value() string
Value returns the actual token value. Only use this when sending to Telegram API.
type SentWebAppMessage ¶
type SentWebAppMessage struct {
InlineMessageID string `json:"inline_message_id,omitempty"`
}
SentWebAppMessage describes an inline message sent by a Web App.
type ShippingAddress ¶
type ShippingAddress struct {
CountryCode string `json:"country_code"`
State string `json:"state"`
City string `json:"city"`
StreetLine1 string `json:"street_line1"`
StreetLine2 string `json:"street_line2"`
PostCode string `json:"post_code"`
}
ShippingAddress represents a shipping address.
type ShippingOption ¶
type ShippingOption struct {
ID string `json:"id"`
Title string `json:"title"`
Prices []LabeledPrice `json:"prices"`
}
ShippingOption represents one shipping option.
type ShippingQuery ¶
type ShippingQuery struct {
ID string `json:"id"`
From *User `json:"from"`
InvoicePayload string `json:"invoice_payload"`
ShippingAddress ShippingAddress `json:"shipping_address"`
}
ShippingQuery represents an incoming shipping query.
type StarAmount ¶
type StarAmount struct {
Amount int `json:"amount"`
NanostarAmount int `json:"nanostar_amount,omitempty"`
}
StarAmount represents an amount of Telegram Stars.
type StarTransaction ¶
type StarTransaction struct {
ID string `json:"id"`
Amount int `json:"amount"`
NanostarAmount int `json:"nanostar_amount,omitempty"`
Date int64 `json:"date"`
Source TransactionPartner `json:"source,omitempty"`
Receiver TransactionPartner `json:"receiver,omitempty"`
}
StarTransaction describes a Telegram Star transaction.
func (*StarTransaction) UnmarshalJSON ¶
func (s *StarTransaction) UnmarshalJSON(data []byte) error
UnmarshalJSON handles polymorphic Source/Receiver fields.
type StarTransactions ¶
type StarTransactions struct {
Transactions []StarTransaction `json:"transactions"`
}
StarTransactions contains a list of Star transactions.
type Sticker ¶
type Sticker struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Type string `json:"type"` // "regular", "mask", "custom_emoji"
Width int `json:"width"`
Height int `json:"height"`
IsAnimated bool `json:"is_animated"`
IsVideo bool `json:"is_video"`
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
Emoji string `json:"emoji,omitempty"`
SetName string `json:"set_name,omitempty"`
PremiumAnimation *File `json:"premium_animation,omitempty"`
MaskPosition *MaskPosition `json:"mask_position,omitempty"`
CustomEmojiID string `json:"custom_emoji_id,omitempty"`
NeedsRepainting bool `json:"needs_repainting,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
}
Sticker represents a sticker.
type StickerSet ¶
type StickerSet struct {
Name string `json:"name"`
Title string `json:"title"`
StickerType string `json:"sticker_type"` // "regular", "mask", "custom_emoji"
IsAnimated bool `json:"is_animated"`
IsVideo bool `json:"is_video"`
Stickers []Sticker `json:"stickers"`
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
}
StickerSet represents a sticker set.
type StoredMessage ¶
StoredMessage is a helper for implementing Editable with database-stored messages.
func (StoredMessage) MessageSig ¶
func (m StoredMessage) MessageSig() (string, int64)
MessageSig implements Editable.
type SuccessfulPayment ¶
type SuccessfulPayment struct {
Currency string `json:"currency"`
TotalAmount int `json:"total_amount"`
InvoicePayload string `json:"invoice_payload"`
ShippingOptionID string `json:"shipping_option_id,omitempty"`
OrderInfo *OrderInfo `json:"order_info,omitempty"`
TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
SubscriptionExpirationDate int64 `json:"subscription_expiration_date,omitempty"`
IsRecurring bool `json:"is_recurring,omitempty"`
IsFirstRecurring bool `json:"is_first_recurring,omitempty"`
}
SuccessfulPayment contains information about a successful payment.
type SwitchInlineQueryChosenChat ¶
type SwitchInlineQueryChosenChat struct {
Query string `json:"query,omitempty"`
AllowUserChats bool `json:"allow_user_chats,omitempty"`
AllowBotChats bool `json:"allow_bot_chats,omitempty"`
AllowGroupChats bool `json:"allow_group_chats,omitempty"`
AllowChannelChats bool `json:"allow_channel_chats,omitempty"`
}
SwitchInlineQueryChosenChat represents inline query switch to chosen chat.
type TransactionPartner ¶
type TransactionPartner interface {
// contains filtered or unexported methods
}
TransactionPartner describes the source or receiver of a Star transaction.
type TransactionPartnerFragment ¶
type TransactionPartnerFragment struct {
Type string `json:"type"` // Always "fragment"
WithdrawalState RevenueWithdrawalState `json:"withdrawal_state,omitempty"`
}
TransactionPartnerFragment represents a withdrawal to Fragment.
func (*TransactionPartnerFragment) UnmarshalJSON ¶
func (p *TransactionPartnerFragment) UnmarshalJSON(data []byte) error
UnmarshalJSON handles the nested polymorphic WithdrawalState.
type TransactionPartnerOther ¶
type TransactionPartnerOther struct {
Type string `json:"type"` // Always "other"
}
TransactionPartnerOther represents an unknown transaction partner type.
type TransactionPartnerTelegramAPI ¶
type TransactionPartnerTelegramAPI struct {
Type string `json:"type"` // Always "telegram_api"
RequestCount int `json:"request_count"`
}
TransactionPartnerTelegramAPI represents payment from Telegram API usage.
type TransactionPartnerTelegramAds ¶
type TransactionPartnerTelegramAds struct {
Type string `json:"type"` // Always "telegram_ads"
}
TransactionPartnerTelegramAds represents a transfer to Telegram Ads.
type TransactionPartnerUnknown ¶
type TransactionPartnerUnknown struct {
Type string `json:"type"`
Raw json.RawMessage `json:"-"`
}
TransactionPartnerUnknown is a fallback for future/unknown partner types.
type TransactionPartnerUser ¶
type TransactionPartnerUser struct {
Type string `json:"type"` // Always "user"
User User `json:"user"`
InvoicePayload string `json:"invoice_payload,omitempty"`
PaidMediaPayload string `json:"paid_media_payload,omitempty"`
SubscriptionPeriod int `json:"subscription_period,omitempty"`
Gift *Gift `json:"gift,omitempty"`
}
TransactionPartnerUser represents a transaction with a user.
type UniqueGift ¶
type UniqueGift struct {
BaseName string `json:"base_name"`
Name string `json:"name"`
Number int `json:"number"`
Model UniqueGiftModel `json:"model"`
Symbol UniqueGiftSymbol `json:"symbol"`
Backdrop UniqueGiftBackdrop `json:"backdrop"`
Colors *UniqueGiftColors `json:"colors,omitempty"` // 9.3 — optional
IsBurned bool `json:"is_burned,omitempty"` // 9.4
}
UniqueGift represents a gift upgraded to a unique one. Added in Bot API 9.0, updated in 9.3 and 9.4.
type UniqueGiftBackdrop ¶
type UniqueGiftBackdrop struct {
Name string `json:"name"`
Colors UniqueGiftBackdropColors `json:"colors"`
RarityPerMille int `json:"rarity_per_mille"` // required, 0 for crafted
}
UniqueGiftBackdrop describes the backdrop of a unique gift. Added in Bot API 9.0.
type UniqueGiftBackdropColors ¶
type UniqueGiftBackdropColors struct {
CenterColor int `json:"center_color"`
EdgeColor int `json:"edge_color"`
SymbolColor int `json:"symbol_color"`
TextColor int `json:"text_color"`
}
UniqueGiftBackdropColors describes the colors of the backdrop of a unique gift. All fields are RGB24 integers (0..16777215 / 0x000000..0xFFFFFF). Added in Bot API 9.0.
type UniqueGiftColors ¶
type UniqueGiftColors struct {
ModelCustomEmojiID string `json:"model_custom_emoji_id"`
SymbolCustomEmojiID string `json:"symbol_custom_emoji_id"`
LightThemeMainColor int `json:"light_theme_main_color"` // RGB24
LightThemeOtherColors []int `json:"light_theme_other_colors"` // 1-3 RGB24 colors
DarkThemeMainColor int `json:"dark_theme_main_color"` // RGB24
DarkThemeOtherColors []int `json:"dark_theme_other_colors"` // 1-3 RGB24 colors
}
UniqueGiftColors describes the color scheme for a user's name, message replies and link previews based on a unique gift. Added in Bot API 9.3.
type UniqueGiftModel ¶
type UniqueGiftModel struct {
Name string `json:"name"`
Sticker Sticker `json:"sticker"`
RarityPerMille int `json:"rarity_per_mille"` // 9.0 — required, 0 for crafted
Rarity string `json:"rarity,omitempty"` // 9.4: "uncommon"|"rare"|"epic"|"legendary"
}
UniqueGiftModel describes the model of a unique gift. Added in Bot API 9.0, updated in 9.4.
type UniqueGiftSymbol ¶
type UniqueGiftSymbol struct {
Name string `json:"name"`
Sticker Sticker `json:"sticker"`
RarityPerMille int `json:"rarity_per_mille"` // required, 0 for crafted
}
UniqueGiftSymbol describes the symbol of a unique gift. Added in Bot API 9.0.
type Update ¶
type Update struct {
UpdateID int `json:"update_id"`
Message *Message `json:"message,omitempty"`
EditedMessage *Message `json:"edited_message,omitempty"`
ChannelPost *Message `json:"channel_post,omitempty"`
EditedChannelPost *Message `json:"edited_channel_post,omitempty"`
CallbackQuery *CallbackQuery `json:"callback_query,omitempty"`
InlineQuery *InlineQuery `json:"inline_query,omitempty"`
ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`
ShippingQuery *ShippingQuery `json:"shipping_query,omitempty"`
PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query,omitempty"`
Poll *Poll `json:"poll,omitempty"`
PollAnswer *PollAnswer `json:"poll_answer,omitempty"`
MyChatMember *ChatMemberUpdated `json:"my_chat_member,omitempty"`
ChatMember *ChatMemberUpdated `json:"chat_member,omitempty"`
ChatJoinRequest *ChatJoinRequest `json:"chat_join_request,omitempty"`
}
Update represents an incoming update from Telegram.
type User ¶
type User struct {
ID int64 `json:"id"`
IsBot bool `json:"is_bot"`
FirstName string `json:"first_name"`
LastName string `json:"last_name,omitempty"`
Username string `json:"username,omitempty"`
LanguageCode string `json:"language_code,omitempty"`
IsPremium bool `json:"is_premium,omitempty"`
AddedToAttachmentMenu bool `json:"added_to_attachment_menu,omitempty"`
CanJoinGroups bool `json:"can_join_groups,omitempty"`
CanReadAllGroupMessages bool `json:"can_read_all_group_messages,omitempty"`
SupportsInlineQueries bool `json:"supports_inline_queries,omitempty"`
AllowsUsersToCreateTopics bool `json:"allows_users_to_create_topics,omitempty"` // 9.4
}
User represents a Telegram user or bot.
type UserChatBoosts ¶
type UserChatBoosts struct {
Boosts []ChatBoost `json:"boosts"`
}
UserChatBoosts represents a list of boosts added to a chat by a user.
type UserProfileAudios ¶
type UserProfileAudios struct {
TotalCount int `json:"total_count"`
Audios []Audio `json:"audios"`
}
UserProfileAudios contains a list of profile audios for a user. Added in Bot API 9.4.
type UserProfilePhotos ¶
type UserProfilePhotos struct {
TotalCount int `json:"total_count"`
Photos [][]PhotoSize `json:"photos"`
}
UserProfilePhotos represents a user's profile pictures.
type ValidationError ¶
ValidationError represents a request validation error.
func NewValidationError ¶
func NewValidationError(field, message string) *ValidationError
NewValidationError creates a new ValidationError.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type Venue ¶
type Venue struct {
Location Location `json:"location"`
Title string `json:"title"`
Address string `json:"address"`
FoursquareID string `json:"foursquare_id,omitempty"`
FoursquareType string `json:"foursquare_type,omitempty"`
GooglePlaceID string `json:"google_place_id,omitempty"`
GooglePlaceType string `json:"google_place_type,omitempty"`
}
Venue represents a venue.
type Video ¶
type Video struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Width int `json:"width"`
Height int `json:"height"`
Duration int `json:"duration"`
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
FileName string `json:"file_name,omitempty"`
MimeType string `json:"mime_type,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
Qualities []VideoQuality `json:"qualities,omitempty"` // 9.4
}
Video represents a video file.
type VideoNote ¶
type VideoNote struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Length int `json:"length"`
Duration int `json:"duration"`
Thumbnail *PhotoSize `json:"thumbnail,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
}
VideoNote represents a video message.
type VideoQuality ¶
type VideoQuality struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Width int `json:"width"`
Height int `json:"height"`
Codec string `json:"codec"` // "h264", "h265", "av01"
FileSize int64 `json:"file_size,omitempty"`
}
VideoQuality represents an available quality version of a video. Added in Bot API 9.4.
type Voice ¶
type Voice struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Duration int `json:"duration"`
MimeType string `json:"mime_type,omitempty"`
FileSize int64 `json:"file_size,omitempty"`
}
Voice represents a voice note.
type WebAppInfo ¶
type WebAppInfo struct {
URL string `json:"url"`
}
WebAppInfo contains information about a Web App.