micha

package module
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: MIT Imports: 14 Imported by: 1

README

Micha

Tests Coverage Status Go Report Card PkgGoDev

Client lib for Telegram bot api.

Simple echo bot
package main

import (
    "log"
	
    "github.com/onrik/micha"
)

func main() {
    bot, err := micha.NewBot("<token>")
    if err != nil {
        log.Println(err)
        return
    }

    go bot.Start()

    for update := range bot.Updates() {
        if update.Message != nil {
            bot.SendMessage(update.Message.Chat.ID, update.Message.Text, nil)
        }
    }
}

Custom Telegram Bot API
package main

import (
    "log"
	
    "github.com/onrik/micha"
)

func main() {
    bot, err := micha.NewBot(
        "<token>",
        micha.WithAPIServer("http://127.0.0.1:8081"),
    )
    if err != nil {
        log.Println(err)
        return
    }

    err = bot.Logout()
    if err != nil {
        log.Println(err)
        return
    }


    go bot.Start()

    for update := range bot.Updates() {
        if update.Message != nil {
            bot.SendMessage(update.Message.Chat.ID, update.Message.Text, nil)
        }
    }
}

Documentation

Index

Constants

View Source
const (
	PARSE_MODE_DEFAULT  ParseMode = ""
	PARSE_MODE_HTML     ParseMode = "HTML"
	PARSE_MODE_MARKDOWN ParseMode = "Markdown"

	CHAT_TYPE_PRIVATE    ChatType = "private"
	CHAT_TYPE_GROUP      ChatType = "group"
	CHAT_TYPE_SUPERGROUP ChatType = "supergroup"
	CHAT_TYPE_CHANNEL    ChatType = "channel"

	CHAT_ACTION_TYPING            ChatAction = "typing"
	CHAT_ACTION_UPLOAD_PHOTO      ChatAction = "upload_photo"
	CHAT_ACTION_RECORD_VIDEO      ChatAction = "record_video"
	CHAT_ACTION_UPLOAD_VIDEO      ChatAction = "upload_video"
	CHAT_ACTION_RECORD_AUDIO      ChatAction = "record_audio"
	CHAT_ACTION_UPLOAD_AUDIO      ChatAction = "upload_audio"
	CHAT_ACTION_UPLOAD_DOCUMENT   ChatAction = "upload_document"
	CHAT_ACTION_FIND_LOCATION     ChatAction = "find_location"
	CHAT_ACTION_RECORD_VIDEO_NOTE ChatAction = "record_video_note"
	CHAT_ACTION_UPLOAD_VIDEO_NOTE ChatAction = "upload_video_note"

	MEMBER_STATUS_CREATOR       MemberStatus = "creator"
	MEMBER_STATUS_ADMINISTRATOR MemberStatus = "administrator"
	MEMBER_STATUS_MEMBER        MemberStatus = "member"
	MEMBER_STATUS_LEFT          MemberStatus = "left"
	MEMBER_STATUS_KICKED        MemberStatus = "kicked"

	MESSAGE_ENTITY_MENTION      MessageEntityType = "mention"
	MESSAGE_ENTITY_HASHTAG      MessageEntityType = "hashtag"
	MESSAGE_ENTITY_BOT_COMMAND  MessageEntityType = "bot_command"
	MESSAGE_ENTITY_URL          MessageEntityType = "url"
	MESSAGE_ENTITY_EMAIL        MessageEntityType = "email"
	MESSAGE_ENTITY_BOLD         MessageEntityType = "bold"
	MESSAGE_ENTITY_ITALIC       MessageEntityType = "italic"
	MESSAGE_ENTITY_CODE         MessageEntityType = "code"
	MESSAGE_ENTITY_PRE          MessageEntityType = "pre"
	MESSAGE_ENTITY_TEXT_LINK    MessageEntityType = "text_link"
	MESSAGE_ENTITY_TEXT_MENTION MessageEntityType = "text_mention"
)

Variables

View Source
var (
	ErrInvalidHash = errors.New("invalid hash")
)

Functions

func ValidateAuthCallback added in v1.5.0

func ValidateAuthCallback(values url.Values, botToken string) error

ValidateAuthCallback - https://core.telegram.org/widgets/login#checking-authorization

func ValidateWabAppData added in v1.5.0

func ValidateWabAppData(values url.Values, botToken string) error

ValidateWabAppData - https://core.telegram.org/bots/webapps#validating-data-received-via-the-mini-app

Types

type Animation

type Animation struct {
	FileID   string `json:"file_id"`
	Width    int    `json:"width"`
	Height   int    `json:"height"`
	Duration int    `json:"duration"`

	// Optional
	Thumb    *PhotoSize `json:"thumb,omitempty"`
	FileName string     `json:"file_name,omitempty"`
	MimeType string     `json:"mime_type,omitempty"`
	FileSize *int       `json:"file_size,omitempty"`
}

Animation object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).

type AnswerCallbackQueryOptions

type AnswerCallbackQueryOptions struct {
	Text      string `json:"text,omitempty"`
	ShowAlert bool   `json:"show_alert,omitempty"`
	URL       string `json:"url,omitempty"`
	CacheTime int    `json:"cache_time,omitempty"`
}

Answer callback query optional params

type AnswerInlineQueryOptions

type AnswerInlineQueryOptions struct {
	CacheTime         int    `json:"cache_time,omitempty"`
	IsPersonal        bool   `json:"is_personal,omitempty"`
	NextOffset        string `json:"next_offset,omitempty"`
	SwitchPmText      string `json:"switch_pm_text,omitempty"`
	SwitchPmParameter string `json:"switch_pm_parameter,omitempty"`
}

Answer inline query optional params

type Audio

type Audio struct {
	FileID   string `json:"file_id"`
	Duration int    `json:"duration"`

	// Optional
	Performer string     `json:"performer,omitempty"`
	Title     string     `json:"title,omitempty"`
	MimeType  string     `json:"mime_type,omitempty"`
	Thumb     *PhotoSize `json:"thumb,omitempty"`
	FileSize  uint64     `json:"file_size,omitempty"`
}

Audio object represents an audio file (voice note).

type Bot

type Bot struct {
	Options
	Me User
	// contains filtered or unexported fields
}

Bot telegram bot

func NewBot

func NewBot(token string, opts ...Option) (*Bot, error)

NewBot - create new bot instance

func (*Bot) AnswerCallbackQuery

func (bot *Bot) AnswerCallbackQuery(callbackQueryID string, options *AnswerCallbackQueryOptions) error

Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert.

func (*Bot) AnswerInlineQuery

func (bot *Bot) AnswerInlineQuery(inlineQueryID string, results InlineQueryResults, options *AnswerInlineQueryOptions) error

Use this method to send answers to an inline query. No more than 50 results per query are allowed.

func (*Bot) DeleteMessage

func (bot *Bot) DeleteMessage(chatID ChatID, messageID int64) (bool, error)

Use this method to delete a message. A message can only be deleted if it was sent less than 48 hours ago. Any such recently sent outgoing message may be deleted. Additionally, if the bot is an administrator in a group chat, it can delete any message. If the bot is an administrator in a supergroup, it can delete messages from any other user and service messages about people joining or leaving the group (other types of service messages may only be removed by the group creator). In channels, bots can only remove their own messages.

func (*Bot) DeleteWebhook

func (bot *Bot) DeleteWebhook() error

func (*Bot) DownloadFileURL

func (bot *Bot) DownloadFileURL(filePath string) string

Return absolute url for file downloading by file path

func (*Bot) EditMessageCaption

func (bot *Bot) EditMessageCaption(chatID ChatID, messageID int64, inlineMessageID string, options *EditMessageCationOptions) (*Message, error)

Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).

func (*Bot) EditMessageReplyMarkup

func (bot *Bot) EditMessageReplyMarkup(chatID ChatID, messageID int64, inlineMessageID string, replyMarkup ReplyMarkup) (*Message, error)

Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).

func (*Bot) EditMessageText

func (bot *Bot) EditMessageText(chatID ChatID, messageID int64, inlineMessageID, text string, options *EditMessageTextOptions) (*Message, error)

Use this method to edit text messages sent by the bot or via the bot (for inline bots).

func (*Bot) ForwardMessage

func (bot *Bot) ForwardMessage(chatID, fromChatID ChatID, messageID int64, disableNotification bool) (*Message, error)

Use this method to forward messages of any kind.

func (*Bot) GetChat

func (bot *Bot) GetChat(chatID ChatID) (*Chat, error)

Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.).

func (*Bot) GetChatAdministrators

func (bot *Bot) GetChatAdministrators(chatID ChatID) ([]ChatMember, error)

Use this method to get a list of administrators in a chat. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.

func (*Bot) GetChatMember

func (bot *Bot) GetChatMember(chatID ChatID, userID int64) (*ChatMember, error)

Use this method to get information about a member of a chat.

func (*Bot) GetChatMembersCount

func (bot *Bot) GetChatMembersCount(chatID ChatID) (int, error)

Use this method to get the number of members in a chat.

func (*Bot) GetFile

func (bot *Bot) GetFile(fileID string) (*File, error)

Use this method to get basic info about a file and prepare it for downloading. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again.

func (*Bot) GetGameHighScores

func (bot *Bot) GetGameHighScores(userID int64, options *GetGameHighScoresOptions) ([]GameHighScore, error)

Use this method to get data for high score tables. Will return the score of the specified user and several of his neighbors in a game.

func (*Bot) GetMe

func (bot *Bot) GetMe() (*User, error)

A simple method for testing your bot's auth token. Returns basic information about the bot in form of a User object.

func (*Bot) GetUserProfilePhotos

func (bot *Bot) GetUserProfilePhotos(userID int64, offset, limit *int) (*UserProfilePhotos, error)

Use this method to get a list of profile pictures for a user.

func (*Bot) GetWebhookInfo

func (bot *Bot) GetWebhookInfo() (*WebhookInfo, error)

func (*Bot) KickChatMember

func (bot *Bot) KickChatMember(chatID ChatID, userID int64) error

Use this method to kick a user from a group or a supergroup. In the case of supergroups, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the group for this to work.

func (*Bot) LeaveChat

func (bot *Bot) LeaveChat(chatID ChatID) error

Use this method for your bot to leave a group, supergroup or channel

func (*Bot) Logout added in v1.2.0

func (bot *Bot) Logout() error

Logout Use this method to log out from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes.

func (*Bot) Raw added in v1.4.0

func (bot *Bot) Raw(method string, data any) ([]byte, error)

Raw - send any method and return raw response

func (*Bot) SendAudio

func (bot *Bot) SendAudio(chatID ChatID, audioID string, options *SendAudioOptions) (*Message, error)

Send exists audio by file_id

func (*Bot) SendAudioFile

func (bot *Bot) SendAudioFile(chatID ChatID, file io.Reader, fileName string, options *SendAudioOptions) (*Message, error)

Send audio file

func (*Bot) SendChatAction

func (bot *Bot) SendChatAction(chatID ChatID, action ChatAction) error

Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).

func (*Bot) SendContact

func (bot *Bot) SendContact(chatID ChatID, phoneNumber, firstName, lastName string, options *SendContactOptions) (*Message, error)

Use this method to send phone contacts

func (*Bot) SendDocument

func (bot *Bot) SendDocument(chatID ChatID, documentID string, options *SendDocumentOptions) (*Message, error)

Send exists document by file_id

func (*Bot) SendDocumentFile

func (bot *Bot) SendDocumentFile(chatID ChatID, file io.Reader, fileName string, options *SendDocumentOptions) (*Message, error)

Send file

func (*Bot) SendGame

func (bot *Bot) SendGame(chatID ChatID, gameShortName string, options *SendGameOptions) (*Message, error)

Use this method to send a game.

func (*Bot) SendLocation

func (bot *Bot) SendLocation(chatID ChatID, latitude, longitude float64, options *SendLocationOptions) (*Message, error)

Use this method to send point on the map

func (*Bot) SendMessage

func (bot *Bot) SendMessage(chatID ChatID, text string, options *SendMessageOptions) (*Message, error)

Use this method to send text messages.

func (*Bot) SendPhoto

func (bot *Bot) SendPhoto(chatID ChatID, photoID string, options *SendPhotoOptions) (*Message, error)

Send exists photo by file_id

func (*Bot) SendPhotoFile

func (bot *Bot) SendPhotoFile(chatID ChatID, file io.Reader, fileName string, options *SendPhotoOptions) (*Message, error)

Send photo file

func (*Bot) SendSticker

func (bot *Bot) SendSticker(chatID ChatID, stickerID string, options *SendStickerOptions) (*Message, error)

Send exists sticker by file_id

func (*Bot) SendStickerFile

func (bot *Bot) SendStickerFile(chatID ChatID, file io.Reader, fileName string, options *SendStickerOptions) (*Message, error)

Send .webp sticker file

func (*Bot) SendVenue

func (bot *Bot) SendVenue(chatID ChatID, latitude, longitude float64, title, address string, options *SendVenueOptions) (*Message, error)

Use this method to send information about a venue

func (*Bot) SendVideo

func (bot *Bot) SendVideo(chatID ChatID, videoID string, options *SendVideoOptions) (*Message, error)

Send exists video by file_id

func (*Bot) SendVideoFile

func (bot *Bot) SendVideoFile(chatID ChatID, file io.Reader, fileName string, options *SendVideoOptions) (*Message, error)

Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document).

func (*Bot) SendVideoNote

func (bot *Bot) SendVideoNote(chatID ChatID, videoNoteID string, options *SendVideoNoteOptions) (*Message, error)

Send exists video note by file_id

func (*Bot) SendVideoNoteFile

func (bot *Bot) SendVideoNoteFile(chatID ChatID, file io.Reader, fileName string, options *SendVideoNoteOptions) (*Message, error)

Use this method to send video messages

func (*Bot) SendVoice

func (bot *Bot) SendVoice(chatID ChatID, voiceID string, options *SendVoiceOptions) (*Message, error)

Send exists voice by file_id

func (*Bot) SendVoiceFile

func (bot *Bot) SendVoiceFile(chatID ChatID, file io.Reader, fileName string, options *SendVoiceOptions) (*Message, error)

Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document).

func (*Bot) SetGameScore

func (bot *Bot) SetGameScore(userID int64, score int, options *SetGameScoreOptions) (*Message, error)

Use this method to set the score of the specified user in a game.

func (*Bot) SetWebhook

func (bot *Bot) SetWebhook(webhookURL string, options *SetWebhookOptions) error

func (*Bot) Start

func (bot *Bot) Start(allowedUpdates ...string)

Start getting updates

func (*Bot) Stop

func (bot *Bot) Stop()

Stop getting updates

func (*Bot) UnbanChatMember

func (bot *Bot) UnbanChatMember(chatID ChatID, userID int64) error

Use this method to unban a previously kicked user in a supergroup. The user will not return to the group automatically, but will be able to join via link, etc. The bot must be an administrator in the group for this to work.

func (*Bot) Updates

func (bot *Bot) Updates() <-chan Update

Updates channel

type CallbackQuery

type CallbackQuery struct {
	ID   string `json:"id"`
	From User   `json:"from"`

	// Optional
	Message         *Message `json:"message,omitempty"`
	InlineMessageID string   `json:"inline_message_id,omitempty"`
	ChatInstance    string   `json:"chat_instance,omitempty"`
	Data            string   `json:"data,omitempty"`
	GameShortName   string   `json:"game_short_name,omitempty"`
}

CallbackQuery object represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field message will be presented. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be presented.

type Chat

type Chat struct {
	ID   ChatID   `json:"id"`
	Type ChatType `json:"type"`

	// Optional
	Title            string           `json:"title,omitempty"`
	Username         string           `json:"username,omitempty"`
	FirstName        string           `json:"first_name,omitempty"`
	LastName         string           `json:"last_name,omitempty"`
	Photo            *ChatPhoto       `json:"photo,omitempty"`
	Description      string           `json:"description,omitempty"`
	InviteLink       string           `json:"invite_link,omitempty"`
	PinnedMessage    *Message         `json:"pinned_message,omitempty"`
	Permissions      *ChatPermissions `json:"permissions,omitempty"`
	StickerSetName   string           `json:"sticker_set_name,omitempty"`
	CanSetStickerSet bool             `json:"can_set_sticker_set,omitempty"`
}

Chat object represents a chat.

type ChatAction

type ChatAction string

type ChatID

type ChatID string

func (*ChatID) UnmarshalJSON

func (chatID *ChatID) UnmarshalJSON(value []byte) error

type ChatMember

type ChatMember struct {
	User   User         `json:"user"`
	Status MemberStatus `json:"status"`

	// Optional
	UntilDate             int64 `json:"until_date,omitempty"`
	CanBeEdited           bool  `json:"can_be_edited,omitempty"`
	CanPostMessages       bool  `json:"can_post_messages,omitempty"`
	CanEditMessages       bool  `json:"can_edit_messages,omitempty"`
	CanDeleteMessages     bool  `json:"can_delete_messages,omitempty"`
	CanRestrictMembers    bool  `json:"can_restrict_members,omitempty"`
	CanPromoteMembers     bool  `json:"can_promote_members,omitempty"`
	CanChangeInfo         bool  `json:"can_change_info,omitempty"`
	CanInviteUsers        bool  `json:"can_invite_users,omitempty"`
	CanPinMessages        bool  `json:"can_pin_messages,omitempty"`
	IsMember              bool  `json:"is_member,omitempty"`
	CanSendMessages       bool  `json:"can_send_messages,omitempty"`
	CanSendMediaMessages  bool  `json:"can_send_media_messages,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"`
}

ChatMember object contains information about one member of a chat.

type ChatPermissions added in v1.2.0

type ChatPermissions struct {
	CanSendMessages       bool `json:"can_send_messages,omitempty"`
	CanSendMediaMessages  bool `json:"can_send_media_messages,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"`
}

ChatPermissions describes actions that a non-administrator user is allowed to take in a chat.

type ChatPhoto added in v1.2.0

type ChatPhoto struct {
	SmallFileID string `json:"small_file_id"`
	BigFileID   string `json:"big_file_id"`
}

ChatPhoto object represents a chat photo.

type ChatType

type ChatType string

type ChosenInlineResult

type ChosenInlineResult struct {
	ResultID        string    `json:"result_id"`
	From            User      `json:"from"`
	Location        *Location `json:"location"`
	InlineMessageID string    `json:"inline_message_id"`
	Query           string    `json:"query"`
}

ChosenInlineResult object represents a result of an inline query that was chosen by the user and sent to their chat partner.

type Contact

type Contact struct {
	PhoneNumber string `json:"phone_number"`
	FirstName   string `json:"first_name"`

	// Optional
	LastName string `json:"last_name,omitempty"`
	UserID   int64  `json:"user_id,omitempty"`
	VCard    string `json:"vcard,omitempty"`
}

Contact object represents a contact to Telegram user

type Document

type Document struct {
	FileID string `json:"file_id"`

	// Optional
	Thumb    *PhotoSize `json:"thumb,omitempty"`
	FileName string     `json:"file_name,omitempty"`
	MimeType string     `json:"mime_type,omitempty"`
	FileSize uint64     `json:"file_size,omitempty"`
}

Document object represents a general file (as opposed to Photo or Audio). Telegram users can send files of any type of up to 1.5 GB in size.

type EditMessageCationOptions

type EditMessageCationOptions struct {
	Caption     string      `json:"caption,omitempty"`
	ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}

Edit message caption optional params

type EditMessageTextOptions

type EditMessageTextOptions struct {
	ParseMode             ParseMode   `json:"parse_mode,omitempty"`
	DisableWebPagePreview bool        `json:"disable_web_page_preview,omitempty"`
	ReplyMarkup           ReplyMarkup `json:"reply_markup,omitempty"`
}

Edit message text optional params

type File

type File struct {
	FileID string `json:"file_id"`

	// Optional
	FileSize uint64 `json:"file_size,omitempty"`
	FilePath string `json:"file_path,omitempty"`
}

File object represents a file ready to be downloaded. The file can be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile.

type ForceReply

type ForceReply struct {
	ForceReply bool `json:"force_reply"`
	Selective  bool `json:"selective,omitempty"`
	// contains filtered or unexported fields
}

ForceReply object Upon receiving a message with this object, Telegram clients will display a reply interface to the user. This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode.

type Game

type Game struct {
	Title       string      `json:"title"`
	Description string      `json:"description"`
	Photo       []PhotoSize `json:"photo"`

	// Optional
	Text         string          `json:"text"`
	TextEntities []MessageEntity `json:"text_entities"`
	Animation    *Animation      `json:"animation"`
}

Game object represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers.

type GameHighScore

type GameHighScore struct {
	Position int  `json:"position"`
	User     User `json:"user"`
	Score    int  `json:"score"`
}

GameHighScore object represents one row of the high scores table for a game.

type GetGameHighScoresOptions

type GetGameHighScoresOptions struct {
	ChatID          ChatID `json:"chat_id,omitempty"`
	MessageID       int64  `json:"message_id,omitempty"`
	InlineMessageID string `json:"inline_message_id,omitempty"`
}

Get game high scopres optional params

type HTTPError added in v1.3.0

type HTTPError struct {
	StatusCode int
}

func (HTTPError) Error added in v1.3.0

func (e HTTPError) Error() string

type HttpClient

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

HttpClient interface

type InlineKeyboardButton

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

	// Optional
	URL                          string    `json:"url,omitempty"`
	LoginURL                     *LoginURL `json:"login_url,omitempty"`
	CallbackData                 string    `json:"callback_data,omitempty"`
	SwitchInlineQuery            string    `json:"switch_inline_query,omitempty"`
	SwitchInlineQueryCurrentChat string    `json:"switch_inline_query_current_chat,omitempty"`
	Pay                          bool      `json:"pay,omitempty"`
}

InlineKeyboardButton object represents one button of an inline keyboard. You must use exactly one of the optional fields.

type InlineKeyboardMarkup

type InlineKeyboardMarkup struct {
	InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
	// contains filtered or unexported fields
}

InlineKeyboardMarkup object represents an inline keyboard that appears right next to the message it belongs to.

type InlineQuery

type InlineQuery struct {
	ID       string    `json:"id"`
	From     User      `json:"from"`
	Location *Location `json:"location,omitempty"`
	Query    string    `json:"query"`
	Offset   string    `json:"offset"`
}

InlineQuery object represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results.

type InlineQueryResult

type InlineQueryResult interface {
	// contains filtered or unexported methods
}

type InlineQueryResultArticle

type InlineQueryResultArticle struct {
	Type  InlineResultType `json:"type"`
	ID    string           `json:"id"`
	Title string           `json:"title"`

	// Optional
	URL                 string                `json:"url,omitempty"`
	HideURL             bool                  `json:"hide_url,omitempty"`
	Description         string                `json:"description,omitempty"`
	ThumbURL            string                `json:"thumb_url,omitempty"`
	ThumbWidth          int                   `json:"thumb_width,omitempty"`
	ThumbHeight         int                   `json:"thumb_height,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to an article or web page.

type InlineQueryResultAudio

type InlineQueryResultAudio struct {
	Type     InlineResultType `json:"type"`
	ID       string           `json:"id"`
	AudioURL string           `json:"audio_url"`
	Title    string           `json:"title"`

	// Optional
	Performer           string                `json:"performer,omitempty"`
	AudioDuration       int                   `json:"audio_duration,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to an mp3 audio file. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio.

type InlineQueryResultCachedAudio

type InlineQueryResultCachedAudio struct {
	Type        InlineResultType `json:"type"`
	ID          string           `json:"id"`
	AudioFileID string           `json:"audio_file_id"`

	// Optional
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to an mp3 audio file stored on the Telegram servers. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio.

type InlineQueryResultCachedDocument

type InlineQueryResultCachedDocument struct {
	Type           InlineResultType `json:"type"`
	ID             string           `json:"id"`
	Title          string           `json:"title"`
	DocumentFileID string           `json:"document_file_id"`

	// Optional
	Description         string                `json:"description,omitempty"`
	Caption             string                `json:"caption,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only pdf-files and zip archives can be sent using this method.

type InlineQueryResultCachedGif

type InlineQueryResultCachedGif struct {
	Type      InlineResultType `json:"type"`
	ID        string           `json:"id"`
	GifFileID string           `json:"gif_file_id"`

	// Optional
	Title               string                `json:"title,omitempty"`
	Caption             string                `json:"caption,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to an animated GIF file stored on the Telegram servers. By default, this animated GIF file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with specified content instead of the animation.

type InlineQueryResultCachedMpeg4Gif

type InlineQueryResultCachedMpeg4Gif struct {
	Type        InlineResultType `json:"type"`
	ID          string           `json:"id"`
	Mpeg4FileID string           `json:"mpeg4_file_id"`

	// Optional
	Title               string                `json:"title,omitempty"`
	Caption             string                `json:"caption,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers. By default, this animated MPEG-4 file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.

type InlineQueryResultCachedPhoto

type InlineQueryResultCachedPhoto struct {
	Type        InlineResultType `json:"type"`
	ID          string           `json:"id"`
	PhotoFileID string           `json:"photo_file_id"`

	// Optional
	Title               string                `json:"title,omitempty"`
	Description         string                `json:"description,omitempty"`
	Caption             string                `json:"caption,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to a photo stored on the Telegram servers. By default, this photo will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.

type InlineQueryResultCachedSticker

type InlineQueryResultCachedSticker struct {
	Type          InlineResultType `json:"type"`
	ID            string           `json:"id"`
	StickerFileID string           `json:"sticker_file_id"`

	// Optional
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to a sticker stored on the Telegram servers. By default, this sticker will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the sticker.

type InlineQueryResultCachedVideo

type InlineQueryResultCachedVideo struct {
	Type        InlineResultType `json:"type"`
	ID          string           `json:"id"`
	VideoFileID string           `json:"video_file_id"`

	// Optional
	Title               string                `json:"title,omitempty"`
	Description         string                `json:"description,omitempty"`
	Caption             string                `json:"caption,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to a video file stored on the Telegram servers. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video.

type InlineQueryResultCachedVoice

type InlineQueryResultCachedVoice struct {
	Type        InlineResultType `json:"type"`
	ID          string           `json:"id"`
	VoiceFileID string           `json:"voice_file_id"`

	// Optional
	Title               string                `json:"title"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to a voice message stored on the Telegram servers. By default, this voice message will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the voice message.

type InlineQueryResultContact

type InlineQueryResultContact struct {
	Type        InlineResultType `json:"type"`
	ID          string           `json:"id"`
	PhoneNumber string           `json:"phone_number"`
	FirstName   string           `json:"first_name"`

	// Optional
	LastName            string                `json:"last_name,omitempty"`
	ThumbURL            string                `json:"thumb_url,omitempty"`
	ThumbWidth          int                   `json:"thumb_width,omitempty"`
	ThumbHeight         int                   `json:"thumb_height,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the contact.

type InlineQueryResultDocument

type InlineQueryResultDocument struct {
	Type        InlineResultType `json:"type"`
	ID          string           `json:"id"`
	Title       string           `json:"title"`
	DocumentURL string           `json:"document_url"`
	MimeType    string           `json:"mime_type"`

	// Optional
	Caption             string                `json:"caption,omitempty"`
	Description         string                `json:"description,omitempty"`
	ThumbURL            string                `json:"thumb_url,omitempty"`
	ThumbWidth          int                   `json:"thumb_width,omitempty"`
	ThumbHeight         int                   `json:"thumb_height,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to a file. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only .PDF and .ZIP files can be sent using this method.

type InlineQueryResultGame

type InlineQueryResultGame struct {
	Type          InlineResultType `json:"type"`
	ID            string           `json:"id"`
	GameShortName string           `json:"game_short_name"`

	// Optional
	ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	// contains filtered or unexported fields
}

Represents a Game.

type InlineQueryResultGif

type InlineQueryResultGif struct {
	Type   InlineResultType `json:"type"`
	ID     string           `json:"id"`
	GifURL string           `json:"gif_url"`

	// Optional
	GifWidth            int                   `json:"gif_width,omitempty"`
	GifHeight           int                   `json:"gif_height,omitempty"`
	GifDuration         int                   `json:"gif_duration"`
	ThumbURL            string                `json:"thumb_url,omitempty"`
	Title               string                `json:"title,omitempty"`
	Caption             string                `json:"caption,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to an animated GIF file. By default, this animated GIF file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.

type InlineQueryResultLocation

type InlineQueryResultLocation struct {
	Type      InlineResultType `json:"type"`
	ID        string           `json:"id"`
	Latitude  float64          `json:"latitude"`
	Longitude float64          `json:"longitude"`
	Title     string           `json:"title"`

	// Optional
	ThumbURL            string                `json:"thumb_url,omitempty"`
	ThumbWidth          int                   `json:"thumb_width,omitempty"`
	ThumbHeight         int                   `json:"thumb_height,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a location on a map. By default, the location will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the location.

type InlineQueryResultMpeg4Gif

type InlineQueryResultMpeg4Gif struct {
	Type     InlineResultType `json:"type"`
	ID       string           `json:"id"`
	Mpeg4URL string           `json:"mpeg4_url"`

	// Optional
	Mpeg4Width          int                   `json:"mpeg4_width,omitempty"`
	Mpeg4Height         int                   `json:"mpeg4_height,omitempty"`
	Mpeg4Duration       int                   `json:"mpeg4_duration,omitempty"`
	ThumbURL            string                `json:"thumb_url,omitempty"`
	Title               string                `json:"title,omitempty"`
	Caption             string                `json:"caption,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default, this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.

type InlineQueryResultPhoto

type InlineQueryResultPhoto struct {
	Type     InlineResultType `json:"type"`
	ID       string           `json:"id"`
	PhotoURL string           `json:"photo_url"`

	// Optional
	MimeType            string                `json:"mime_type,omitempty"`
	PhotoWidth          int                   `json:"photo_width,omitempty"`
	PhotoHeight         int                   `json:"photo_height,omitempty"`
	ThumbURL            string                `json:"thumb_url,omitempty"`
	Title               string                `json:"title,omitempty"`
	Description         string                `json:"description,omitempty"`
	Caption             string                `json:"caption,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to a photo. By default, this photo will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.

type InlineQueryResultVenue

type InlineQueryResultVenue struct {
	Type      InlineResultType `json:"type"`
	ID        string           `json:"id"`
	Latitude  float64          `json:"latitude"`
	Longitude float64          `json:"longitude"`
	Title     string           `json:"title"`
	Address   string           `json:"address"`

	// Optional
	FoursquareID        string                `json:"foursquare_id,omitempty"`
	ThumbURL            string                `json:"thumb_url,omitempty"`
	ThumbWidth          int                   `json:"thumb_width,omitempty"`
	ThumbHeight         int                   `json:"thumb_height,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a venue. By default, the venue will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the venue.

type InlineQueryResultVideo

type InlineQueryResultVideo struct {
	Type     InlineResultType `json:"type"`
	ID       string           `json:"id"`
	VideoURL string           `json:"video_url"`
	MimeType string           `json:"mime_type"`

	// Optional
	ThumbURL            string                `json:"thumb_url,omitempty"`
	Title               string                `json:"title,omitempty"`
	Caption             string                `json:"caption,omitempty"`
	VideoWidth          int                   `json:"video_width,omitempty"`
	VideoHeight         int                   `json:"video_height,omitempty"`
	VideoDuration       int                   `json:"video_duration,omitempty"`
	Description         string                `json:"description,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to a page containing an embedded video player or a video file. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video.

type InlineQueryResultVoice

type InlineQueryResultVoice struct {
	Type     InlineResultType `json:"type"`
	ID       string           `json:"id"`
	VoiceURL string           `json:"voice_url"`
	Title    string           `json:"title"`

	// Optional
	VoiceDuration       int                   `json:"voice_duration,omitempty"`
	ReplyMarkup         *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
	InputMessageContent InputMessageContent   `json:"input_message_content,omitempty"`
	// contains filtered or unexported fields
}

Represents a link to a voice recording in an .ogg container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message.

type InlineQueryResults

type InlineQueryResults []InlineQueryResult

type InlineResultType

type InlineResultType string
const (
	INLINE_TYPE_RESULT_ARTICLE   InlineResultType = "article"
	INLINE_TYPE_RESULT_PHOTO     InlineResultType = "photo"
	INLINE_TYPE_RESULT_GIF       InlineResultType = "gif"
	INLINE_TYPE_RESULT_MPEG4_GIF InlineResultType = "mpeg4_gif"
	INLINE_TYPE_RESULT_VIDEO     InlineResultType = "video"
	INLINE_TYPE_RESULT_AUDIO     InlineResultType = "audio"
	INLINE_TYPE_RESULT_VOICE     InlineResultType = "voice"
	INLINE_TYPE_RESULT_DOCUMENT  InlineResultType = "document"
	INLINE_TYPE_RESULT_LOCATION  InlineResultType = "location"
	INLINE_TYPE_RESULT_VENUE     InlineResultType = "venue"
	INLINE_TYPE_RESULT_CONTACT   InlineResultType = "contact"
	INLINE_TYPE_RESULT_STICKER   InlineResultType = "sticker"
	INLINE_TYPE_RESULT_GAME      InlineResultType = "game"
)

type InputContactMessageContent

type InputContactMessageContent struct {
	PhoneNumber string `json:"phone_number"`
	FirstName   string `json:"first_name"`
	LastName    string `json:"last_name"`
	// contains filtered or unexported fields
}

InputContactMessageContent contains a contact for displaying as an inline query result.

type InputLocationMessageContent

type InputLocationMessageContent struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	// contains filtered or unexported fields
}

InputLocationMessageContent contains a location for displaying as an inline query result.

type InputMessageContent

type InputMessageContent interface {
	// contains filtered or unexported methods
}

type InputTextMessageContent

type InputTextMessageContent struct {
	MessageText           string    `json:"message_text"`
	ParseMode             ParseMode `json:"parse_mode"`
	DisableWebPagePreview bool      `json:"disable_web_page_preview"`
	// contains filtered or unexported fields
}

InputTextMessageContent contains text for displaying as 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"`
	// contains filtered or unexported fields
}

InputVenueMessageContent contains a venue for displaying an inline query result.

type Invoice

type Invoice struct {
	Title          string
	Description    string
	StartParameter string
	Currency       string
	TotalAmount    int
}

type KeyboardButton

type KeyboardButton struct {
	Text string `json:"text"`

	// Optional
	RequestContact  bool `json:"request_contact,omitempty"`
	RequestLocation bool `json:"request_location,omitempty"`
}

KeyboardButton object represents one button of the reply keyboard. For simple text buttons String can be used instead of this object to specify text of the button. Optional fields are mutually exclusive.

type Location

type Location struct {
	Longitude float64 `json:"longitude"`
	Latitude  float64 `json:"latitude"`
}

Location object represents geographic position.

type Logger

type Logger interface {
	ErrorContext(ctx context.Context, msg string, args ...any)
}

Logger interface

type LoginURL added in v1.2.0

type LoginURL struct {
	URL string `json:"url"`

	// Optional
	ForwardText        string `json:"forward_text,omitempty"`
	BotUsername        string `json:"bot_username,omitempty"`
	RequestWriteAccess bool   `json:"request_write_access,omitempty"`
}

LoginURL object represents a parameter of the inline keyboard button used to automatically authorize a user. Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram. All the user needs to do is tap/click a button and confirm that they want to log in:

type MaskPosition added in v1.2.0

type MaskPosition struct {
	Point  string  `json:"point"`
	XShift float64 `json:"x_shift"`
	YShift float64 `json:"y_shift"`
	Scale  float64 `json:"scale"`
}

MaskPosition object describes the position on faces where a mask should be placed by default.

type MemberStatus

type MemberStatus string

type Message

type Message struct {
	MessageID int64  `json:"message_id"`
	From      User   `json:"from"`
	Date      uint64 `json:"date"`
	Chat      Chat   `json:"chat"`

	// Optional
	ForwardFrom           *User                `json:"forward_from,omitempty"`
	ForwardFromChat       *Chat                `json:"forward_from_chat,omitempty"`
	ForwardFromMessageID  int64                `json:"forward_from_message_id,omitempty"`
	ForwardSignature      string               `json:"forward_signature,omitempty"`
	ForwardSenderName     string               `json:"forward_sender_name,omitempty"`
	ForwardDate           uint64               `json:"forward_date,omitempty"`
	ReplyToMessage        *Message             `json:"reply_to_message,omitempty"`
	EditDate              uint64               `json:"edit_date,omitempty"`
	MediaGroupID          string               `json:"media_group_id,omitempty"`
	AuthorSignature       string               `json:"author_signature,omitempty"`
	Text                  string               `json:"text,omitempty"`
	Entities              []MessageEntity      `json:"entities,omitempty"`
	CaptionEntities       []MessageEntity      `json:"caption_entities,omitempty"`
	Audio                 *Audio               `json:"audio,omitempty"`
	Document              *Document            `json:"document,omitempty"`
	Animation             *Animation           `json:"animation,omitempty"`
	Game                  *Game                `json:"game,omitempty"`
	Photo                 []PhotoSize          `json:"photo,omitempty"`
	Sticker               *Sticker             `json:"sticker,omitempty"`
	Video                 *Video               `json:"video,omitempty"`
	Voice                 *Voice               `json:"voice,omitempty"`
	VideoNote             *VideoNote           `json:"video_note,omitempty"`
	Caption               string               `json:"caption,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"`
	MigrateToChatID       ChatID               `json:"migrate_to_chat_id,omitempty"`
	MigrateFromChatID     ChatID               `json:"migrate_from_chat_id,omitempty"`
	PinnedMessage         *Message             `json:"pinned_message,omitempty"`
	Invoice               *Invoice             `json:"invoice,omitempty"`
	SuccessfulPayment     *SuccessfulPayment   `json:"successful_payment,omitempty"`
	ConnectedWebsite      string               `json:"connected_website,omitempty"`
	PassportData          *PassportData        `json:"passport_data,omitempty"`
	ReplyMarkup           InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}

Message object represents a message.

type MessageEntity

type MessageEntity struct {
	Type   MessageEntityType `json:"type"`
	Offset int               `json:"offset"`
	Limit  int               `json:"limit"`

	// Optional
	URL  string `json:"url,omitempty"`  // For “text_link” only, url that will be opened after user taps on the text
	User *User  `json:"user,omitempty"` // For “text_mention” only, the mentioned user
}

MessageEntity object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.

type MessageEntityType

type MessageEntityType string

type Option

type Option func(*Options)

func WithAPIServer added in v1.2.0

func WithAPIServer(url string) Option

WithAPIServer - set custom api server (https://github.com/tdlib/telegram-bot-api)

func WithCtx added in v1.3.0

func WithCtx(ctx context.Context) Option

WithAPIServer - set custom context

func WithHttpClient

func WithHttpClient(httpClient HttpClient) Option

WithHttpClient - set custom http client

func WithLimit

func WithLimit(limit int) Option

WithLimit - set getUpdates limit Values between 1—100 are accepted. Defaults to 100.

func WithLogger

func WithLogger(logger Logger) Option

WithLogger - set logger

func WithTimeout

func WithTimeout(timeout int) Option

WithTimeout - set timeout in seconds for getUpdates long polling Defaults to 25

type Options

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

type ParseMode

type ParseMode string

type PassportData added in v1.2.0

type PassportData struct {
}

type PhotoSize

type PhotoSize struct {
	FileID string `json:"file_id"`
	Width  int    `json:"width"`
	Height int    `json:"height"`

	// Optional
	FileSize uint64 `json:"file_size,omitempty"`
}

PhotoSize object represents an image/sticker of a particular size.

type Poll added in v1.2.0

type Poll struct {
	ID       string       `json:"id"`
	Question string       `json:"question"`
	Options  []PollOption `json:"options"`
	IsClosed bool         `json:"is_closed"`
}

Poll object contains information about a poll.

type PollOption added in v1.2.0

type PollOption struct {
	Text       string `json:"text"`
	VoterCount int    `json:"voter_count"`
}

PollOption object contains information about one answer option in a poll.

type PreCheckoutQuery added in v1.2.0

type PreCheckoutQuery struct {
}

type ReplyKeyboardMarkup

type ReplyKeyboardMarkup struct {
	Keyboard        [][]KeyboardButton `json:"keyboard"`
	ResizeKeyboard  bool               `json:"resize_keyboard,omitempty"`
	OneTimeKeyboard bool               `json:"one_time_keyboard,omitempty"`
	Selective       bool               `json:"selective,omitempty"`
	// contains filtered or unexported fields
}

ReplyKeyboardMarkup object represents a custom keyboard with reply options

type ReplyKeyboardRemove

type ReplyKeyboardRemove struct {
	RemoveKeyboard bool `json:"remove_keyboard,omitempty"`
	Selective      bool `json:"selective,omitempty"`
	// contains filtered or unexported fields
}

ReplyKeyboardRemove object Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button

type ReplyMarkup

type ReplyMarkup interface {
	// contains filtered or unexported methods
}

type Response

type Response struct {
	Ok          bool            `json:"ok"`
	ErrorCode   int             `json:"error_code"`
	Description string          `json:"description"`
	Result      json.RawMessage `json:"result"`
}

type ResponseParameters added in v1.2.0

type ResponseParameters struct {
	MigrateToChatID ChatID `json:"migrate_to_chat_id,omitempty"`
	RetryAfter      int64  `json:"retry_after,omitempty"`
}

ResponseParameters contains information about why a request was unsuccessful.

type SendAudioOptions

type SendAudioOptions struct {
	Caption             string      `json:"caption,omitempty"`
	ParseMode           ParseMode   `json:"parse_mode,omitempty"`
	Duration            int         `json:"duration,omitempty"`
	Performer           string      `json:"performer,omitempty"`
	Title               string      `json:"title,omitempty"`
	Thumb               string      `json:"thumb,omitempty"` // TODO add thumb as file
	DisableNotification bool        `json:"disable_notification,omitempty"`
	ProtectContent      bool        `json:"protect_content,omitempty"`
	ReplyToMessageID    int64       `json:"reply_to_message_id,omitempty"`
	ReplyMarkup         ReplyMarkup `json:"reply_markup,omitempty"`
}

SendAudioOptions optional params SendAudio method

type SendContactOptions

type SendContactOptions struct {
	VCard               string      `json:"vcard,omitempty"`
	DisableNotification bool        `json:"disable_notification,omitempty"`
	ReplyToMessageID    int64       `json:"reply_to_message_id,omitempty"`
	ReplyMarkup         ReplyMarkup `json:"reply_markup,omitempty"`
}

SendContactOptions optional params for SendContact method

type SendDocumentOptions

type SendDocumentOptions struct {
	Thumb               string      `json:"thumb,omitempty"` // TODO add thumb as file
	Caption             string      `json:"caption,omitempty"`
	ParseMode           ParseMode   `json:"parse_mode,omitempty"`
	DisableNotification bool        `json:"disable_notification,omitempty"`
	ReplyToMessageID    int64       `json:"reply_to_message_id,omitempty"`
	ReplyMarkup         ReplyMarkup `json:"reply_markup,omitempty"`
}

SendDocumentOptions optional params SendDocument method

type SendGameOptions

type SendGameOptions struct {
	DisableNotification bool        `json:"disable_notification,omitempty"`
	ReplyToMessageID    int64       `json:"reply_to_message_id,omitempty"`
	ReplyMarkup         ReplyMarkup `json:"reply_markup,omitempty"`
}

SendGameOptions optional params for SendGame method

type SendLocationOptions

type SendLocationOptions struct {
	LivePeriod          int         `json:"live_period,omitempty"`
	DisableNotification bool        `json:"disable_notification,omitempty"`
	ReplyToMessageID    int64       `json:"reply_to_message_id,omitempty"`
	ReplyMarkup         ReplyMarkup `json:"reply_markup,omitempty"`
}

SendLocationOptions optional params for SendLocation method

type SendMessageOptions

type SendMessageOptions struct {
	ParseMode             ParseMode   `json:"parse_mode,omitempty"`
	DisableWebPagePreview bool        `json:"disable_web_page_preview,omitempty"`
	DisableNotification   bool        `json:"disable_notification,omitempty"`
	ReplyToMessageID      int64       `json:"reply_to_message_id,omitempty"`
	ReplyMarkup           ReplyMarkup `json:"reply_markup,omitempty"`
}

SendMessageOptions optional params SendMessage method

type SendPhotoOptions

type SendPhotoOptions struct {
	Caption             string      `json:"caption,omitempty"`
	ParseMode           ParseMode   `json:"parse_mode,omitempty"`
	DisableNotification bool        `json:"disable_notification,omitempty"`
	ReplyToMessageID    int64       `json:"reply_to_message_id,omitempty"`
	ReplyMarkup         ReplyMarkup `json:"reply_markup,omitempty"`
}

SendPhotoOptions optional params SendPhoto method

type SendStickerOptions

type SendStickerOptions struct {
	DisableNotification bool        `json:"disable_notification,omitempty"`
	ReplyToMessageID    int64       `json:"reply_to_message_id,omitempty"`
	ReplyMarkup         ReplyMarkup `json:"reply_markup,omitempty"`
}

Send sticker optional params

type SendVenueOptions

type SendVenueOptions struct {
	FoursquareID        string      `json:"foursquare_id,omitempty"`
	FoursquareType      string      `json:"foursquare_type,omitempty"`
	DisableNotification bool        `json:"disable_notification,omitempty"`
	ReplyToMessageID    int64       `json:"reply_to_message_id,omitempty"`
	ReplyMarkup         ReplyMarkup `json:"reply_markup,omitempty"`
}

SendVenueOptions optional params for SendVenue method

type SendVideoNoteOptions

type SendVideoNoteOptions struct {
	Duration            int         `json:"duration,omitempty"`
	Length              int         `json:"length,omitempty"`
	Thumb               string      `json:"thumb,omitempty"` // TODO add thumb as file
	DisableNotification bool        `json:"disable_notification,omitempty"`
	ReplyToMessageID    int64       `json:"reply_to_message_id,omitempty"`
	ReplyMarkup         ReplyMarkup `json:"reply_markup,omitempty"`
}

SendVideoNoteOptions optional params for SendVideoNote method

type SendVideoOptions

type SendVideoOptions struct {
	Duration            int         `json:"duration,omitempty"`
	Width               int         `json:"width,omitempty"`
	Height              int         `json:"height,omitempty"`
	Thumb               string      `json:"thumb,omitempty"` // TODO add thumb as file
	Caption             string      `json:"caption,omitempty"`
	ParseMode           ParseMode   `json:"parse_mode,omitempty"`
	SupportsStreaming   bool        `json:"supports_streaming,omitempty"`
	DisableNotification bool        `json:"disable_notification,omitempty"`
	ReplyToMessageID    int64       `json:"reply_to_message_id,omitempty"`
	ReplyMarkup         ReplyMarkup `json:"reply_markup,omitempty"`
}

SendVideoOptions video optional params SendVideo method

type SendVoiceOptions

type SendVoiceOptions struct {
	Caption             string      `json:"caption,omitempty"`
	ParseMode           ParseMode   `json:"parse_mode,omitempty"`
	Duration            int         `json:"duration,omitempty"`
	DisableNotification bool        `json:"disable_notification,omitempty"`
	ReplyToMessageID    int64       `json:"reply_to_message_id,omitempty"`
	ReplyMarkup         ReplyMarkup `json:"reply_markup,omitempty"`
}

SendVoiceOptions optional params for SendVoice method

type SetGameScoreOptions

type SetGameScoreOptions struct {
	ChatID             ChatID `json:"chat_id,omitempty"`
	MessageID          int64  `json:"message_id,omitempty"`
	InlineMessageID    string `json:"inline_message_id,omitempty"`
	DisableEditMessage bool   `json:"disable_edit_message,omitempty"`
	Force              bool   `json:"force,omitempty"`
}

Set game score optional params

type SetWebhookOptions

type SetWebhookOptions struct {
	Certificate    []byte   `json:"certificate,omitempty"`
	MaxConnections int      `json:"max_connections,omitempty"`
	AllowedUpdates []string `json:"allowed_updates,omitempty"`
}

Set webhook query optional params

type ShippingAddress

type ShippingAddress struct {
}

type ShippingQuery added in v1.2.0

type ShippingQuery struct {
}

type Sticker

type Sticker struct {
	FileID     string `json:"file_id"`
	Width      int    `json:"width"`
	Height     int    `json:"height"`
	IsAnimated bool   `json:"is_animated,omitempty"`

	// Optional
	Thumb        *PhotoSize    `json:"thumb,omitempty"`
	Emoji        string        `json:"emoji,omitempty"`
	SetName      string        `json:"set_name,omitempty"`
	MaskPosition *MaskPosition `json:"mask_position,omitempty"`
	FileSize     uint64        `json:"file_size,omitempty"`
}

Sticker object represents a WebP image, so-called sticker.

type StickerSet added in v1.2.0

type StickerSet struct {
	Name          string    `json:"name"`
	Title         string    `json:"title"`
	IsAnimated    bool      `json:"is_animated"`
	ContainsMasks bool      `json:"contains_masks"`
	Stickers      []Sticker `json:"stickers"`
}

StickerSet object represents a sticker set.

type SuccessfulPayment added in v1.2.0

type SuccessfulPayment struct {
}

type Update

type Update struct {
	UpdateID uint64 `json:"update_id"`

	// Optional
	Message            *Message            `json:"message,omitempty"`
	EditedMessage      *Message            `json:"edited_message,omitempty"`
	ChannelPost        *Message            `json:"channel_post,omitempty"`
	EditedChannelPost  *Message            `json:"edited_channel_post,omitempty"`
	InlineQuery        *InlineQuery        `json:"inline_query,omitempty"`
	ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`
	CallbackQuery      *CallbackQuery      `json:"callback_query,omitempty"`
	ShippingQuery      *ShippingQuery      `json:"shipping_query,omitempty"`
	PreCheckoutQuery   *PreCheckoutQuery   `json:"pre_checkout_query,omitempty"`
	Poll               *Poll               `json:"poll,omitempty"`
}

Update object represents an incoming update. Only one of the optional parameters can be present in any given update.

type User

type User struct {
	ID           int64  `json:"id"`
	IsBot        bool   `json:"is_bot"`
	FirstName    string `json:"first_name"`
	LastName     string `json:"last_name"`
	Username     string `json:"username"`
	LanguageCode string `json:"language_code"`
}

User object represents a Telegram user, bot

type UserProfilePhotos

type UserProfilePhotos struct {
	TotalCount int           `json:"total_count"`
	Photos     [][]PhotoSize `json:"photos"`
}

UserProfilePhotos object represent a user's profile pictures.

type Venue

type Venue struct {
	Location Location `json:"location"`
	Title    string   `json:"title"`
	Address  string   `json:"address"`

	// Optional
	FoursquareID   string `json:"foursquare_id,omitempty"`
	FoursquareType string `json:"foursquare_type,omitempty"`
}

Venue object represents a venue.

type Video

type Video struct {
	FileID   string `json:"file_id"`
	Width    int    `json:"width"`
	Height   int    `json:"height"`
	Duration int    `json:"duration"`

	// Optional
	Thumb    *PhotoSize `json:"thumb,omitempty"`
	MimeType string     `json:"mime_type,omitempty"`
	FileSize uint64     `json:"file_size,omitempty"`
}

Video object represents an MP4-encoded video.

type VideoNote

type VideoNote struct {
	FileID   string `json:"file_id"`
	Length   int    `json:"length"`
	Duration int    `json:"duration"`

	// Optional
	Thumb    *PhotoSize `json:"thumb,omitempty"`
	FileSize int        `json:"file_size,omitempty"`
}

VideoNote object represents a video message.

type Voice

type Voice struct {
	FileID   string `json:"file_id"`
	Duration int    `json:"duration"`

	// Optional
	MimeType string `json:"mime_type,omitempty"`
	FileSize int    `json:"file_size,omitempty"`
}

Voice object represents a voice note.

type WebhookInfo

type WebhookInfo struct {
	URL                  string   `json:"url"`
	HasCustomCertificate bool     `json:"has_custom_certificate"`
	PendingUpdateCount   int      `json:"pending_update_count"`
	LastErrorDate        uint64   `json:"last_error_date,omitempty"`
	LastErrorMessage     string   `json:"last_error_message,omitempty"`
	MaxConnections       int      `json:"max_connections,omitempty"`
	AllowedUpdates       []string `json:"allowed_updates,omitempty"`
}

WebhookInfo contains information about the current status of a webhook.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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