gogram

package module
v1.0.1-0...-78dff00 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: MIT Imports: 13 Imported by: 0

README

gogram-bot

A super light-weight fast library for Telegram bot API.

You have totally 7 files. They are very easy to pick up:

  • bot.go: Contains Bot struct, which represents a bot and methods related to it.
  • data.go: Contains the majority of structs that will be used to send something to telegram (text, pic...), I call those structs data. Each data has two methods; Send and Check. Send sends the data to Request function (in utils.go) and Check will be called in Request to check if required fields are empty or not (also might check validation of data fields).
  • utils.go: You don't really need it. In general, it adds data fields to request, and contains a very important function called Request (which you also won't use directly).
  • data_test.go: All test are here. tests must be done on a real bot token and most tests need more than just bot token. you must provide them by flags.
  • types.go: A long and boring file which you barely use, but it has some cool stuff like Reply Keyboard and Inline Keyboard. Instead of using them directly, you will add a reply keyboard or inline keyboard to your message through the data itself.
  • inlineMode.go: All methods related to handling and answering Inline Messages are here.
  • passport.go: An interface for Telegram Passport.

An Example:

We are going to make an echo bot.

package main

import (
	"github.com/gcoder-dev/gogram-bot"
	"log"
)

var bot = gogram.Bot{Token: "Your Bot Token", Handler: handle, Concurrent: true}

func main() {
	response, err := gogram.SetWebhookData{Url: "Your webhook url"}.Send(bot)
	if err != nil {
		log.Fatalf("%+v---%+v\n", response, err)
	}
	bot.Listener("Port")
}

func handle(update gogram.Update, bot gogram.Bot) {
	response, err := gogram.TextData{Text: update.Message.Text, ChatId: update.Message.Chat.Id}.Send(bot)
	if err != nil {
		log.Fatalf("%+v---%+v\n", response, err)
	}
}

Brief and simple. Now Let's go through it step by step:
var bot = gogram.Bot{Token: "Your Bot Token", Handler: handle, Concurrent: true}

First we create a bot. These are the fields:
Token: the token you got from telegram. it is the only mandatory field.
Handler: Every time telegram sends something to your bot, Handler will be called. Handler is a function with handle(update gogram.Update, bot gogram.Bot) signature.
Concurrent: When set to true, every handler will be called in a separate goroutine. you don't have to wait for goroutines or anything. just set Concurrent to true and let the magic happens.

response, err := gogram.SetWebhookData{Url: "Your webhook url"}.Send(bot)

SetWebhookData is a data in data.go. Telegram sends new updates to Url. If you're using heroku just head over to settings and use your domain for Url.

bot.Listener("Port")

When telegram send an update to your webhook Url that we sat before, you need to listen for it. Listener is a method of Bot. It listens for upcoming updates and when received something, it will call your Handler. Pass Listener a port (optionally you can add an IP). If you're using heroku simply pass Listener os.Getenv("PORT").
For example if your webhook url is 230.59.33.219:8004 (this is a random ip and port), you might pass Listener "8004".

Now lets see what our handler does:

response, err := gogram.TextData{Text: update.Message.Text, ChatId: update.Message.Chat.Id}.Send(bot)

when a user sends something to your bot, it will be delivered to your handler as an Update struct. Later we use Update to get the Text message, id of sender or many other things. Update might contain a Message, InlineQuery, CallbackQuery or Poll struct. Go ahead and head over to types.go and take a look at Update and Message structs.
In our handler, we create a TextData; use Update and pass Text the text user sent and id of sender to ChatId, and finally send it with Send method.


How to add Reply Keyboard and Inline Keyboard to message?

func handle(update gogram.Update, bot gogram.Bot) {
    d := PhotoData{Photo: "pass a url, file_id or a file", ChatId: "a chat id"}
    err := d.SetInlineKeyboard(false, InlineButton{CallbackData: "hi", Text: "1"},
    InlineButton{Text: "Bye", CallbackData: "2"})
    if err != nil {
        return
    }
    d.Send(bot)
}

That was pretty much it! All data structs work the same.

Documentation

Index

Constants

View Source
const (
	TypeText              = "Text"
	TypePhoto             = "Photo"
	TypeAnimation         = "Animation"
	TypeForwardFrom       = "ForwardFrom"
	TypeReply             = "Reply"
	TypeAudio             = "Audio"
	TypeDocument          = "Document"
	TypeSticker           = "Sticker"
	TypeVideo             = "Video"
	TypeVideoNote         = "VideoNote"
	TypeVoice             = "Voice"
	TypeContact           = "Contact"
	TypeDice              = "Dice"
	TypeGame              = "Game"
	TypePoll              = "Poll"
	TypeVenue             = "Venue"
	TypeLocation          = "Location"
	TypeMemberLeftChat    = "MemberLeftChat"
	TypeNewChatTitle      = "NewChatTitle"
	TypeNewChatPhoto      = "NewChatPhoto"
	TypeDeleteChatPhoto   = "DeleteChatPhoto"
	TypeGroupCreated      = "GroupCreated"
	TypeSuperGroupCreated = "SuperGroupCreated"
	TypeChannelCreated    = "ChannelCreated"
	TypeMigrateToChatId   = "MigrateToChatId"
	TypeMigrateFromChatId = "MigrateFromChatId"
	TypePinnedMessage     = "PinnedMessage"
	TypeInvoice           = "Invoice"
	TypeSuccessfulPayment = "SuccessfulPayment"
	TypePassport          = "Passport"
	TypeUnknown           = "Unknown"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddStickerToSetData

type AddStickerToSetData struct {
	UserId       int          `json:"user_id"`
	Name         string       `json:"name"`
	Emojis       string       `json:"emojis"`
	PngSticker   any          `json:"png_sticker"`
	TgsSticker   *os.File     `json:"tgs_sticker"`
	WebmSticker  *os.File     `json:"webm_sticker"`
	MaskPosition MaskPosition `json:"mask_position"`
}

AddStickerToSetData adds a new sticker to a set created by the bot. You must use exactly one of the fields PngSticker, TgsSticker, or WebmSticker. Animated stickers can be added to animated sticker sets and only to them. Animated sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True on success.

func (AddStickerToSetData) Check

func (a AddStickerToSetData) Check() error

func (AddStickerToSetData) Send

func (a AddStickerToSetData) Send(b Bot) (Response, error)

type Animation

type Animation struct {
	FileId string `json:"file_id"`
}

type AnimationData

type AnimationData struct {
	ChatId                   int             `json:"chat_id"`
	Animation                any             `json:"animation"`
	Duration                 int             `json:"duration"`
	Width                    int             `json:"width"`
	Height                   int             `json:"height"`
	Caption                  string          `json:"caption"`
	ParseMode                string          `json:"parse_mode"`
	CaptionEntities          []MessageEntity `json:"caption_entities"`
	DisableNotification      bool            `json:"disable_notification"`
	ReplyToMessageId         int             `json:"reply_to_message_id"`
	AllowSendingWithoutReply bool            `json:"allow_sending_without_reply"`
	Keyboard
}

AnimationData sends animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.

func (AnimationData) Check

func (a AnimationData) Check() error

func (AnimationData) Send

func (a AnimationData) Send(b Bot) (Response, error)

type AnswerCallbackQueryData

type AnswerCallbackQueryData struct {
	CallbackQueryId string `json:"callback_query_id"`
	Text            string `json:"text"`
	ShowAlert       bool   `json:"show_alert"`
	Url             string `json:"url"`
	CacheTime       string `json:"cache_time"`
}

AnswerCallbackQueryData sends 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. On success, True is returned. more info in https://core.telegram.org/bots/api#answercallbackquery

func (AnswerCallbackQueryData) Check

func (a AnswerCallbackQueryData) Check() error

func (AnswerCallbackQueryData) Send

type AnswerInlineQueryData

type AnswerInlineQueryData struct {
	InlineQueryId     string        `json:"inline_query_id"`
	Results           []QueryAnswer `json:"results"`
	CacheTime         int           `json:"cache_time"`
	IsPersonal        bool          `json:"is_personal"`
	NextOffset        string        `json:"next_offset"`
	SwitchPmText      string        `json:"switch_pm_text"`
	SwitchPmParameter string        `json:"switch_pm_parameter"`
}

AnswerInlineQueryData sends answers to an inline query. On success, True is returned. No more than 50 results per query are allowed.

func (AnswerInlineQueryData) Check

func (a AnswerInlineQueryData) Check() error

func (AnswerInlineQueryData) Send

func (a AnswerInlineQueryData) Send(b Bot) (Response, error)

type AnswerPreCheckoutQuery

type AnswerPreCheckoutQuery struct {
	PreCheckoutQueryId string `json:"pre_checkout_query_id"`
	Ok                 bool   `json:"ok"`
	ErrorMessage       string `json:"error_message"`
}

AnswerPreCheckoutQuery responds to pre-checkout queries. Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.

func (AnswerPreCheckoutQuery) Check

func (a AnswerPreCheckoutQuery) Check() error

func (AnswerPreCheckoutQuery) Send

type AnswerShippingQueryData

type AnswerShippingQueryData struct {
	ShippingQueryId string            `json:"shipping_query_id"`
	Ok              bool              `json:"ok"`
	ShippingOptions []ShippingOptions `json:"shipping_options"`
	ErrorMessage    string            `json:"error_message"`
}

AnswerShippingQueryData replies to shipping queries. If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. On success, True is returned.

func (AnswerShippingQueryData) Check

func (a AnswerShippingQueryData) Check() error

func (AnswerShippingQueryData) Send

type Audio

type Audio struct {
	FileId       string    `json:"file_Id"`
	FileUniqueId string    `json:"file_unique_id"`
	Duration     int       `json:"duration"`
	Performer    string    `json:"performer"`
	Title        string    `json:"title"`
	FileName     string    `json:"file_name"`
	MimeType     string    `json:"mime_type"`
	FileSize     int       `json:"file_size"`
	Thumb        PhotoSize `json:"thumb"`
}

type AudioData

type AudioData struct {
	ChatId int `json:"chat_id"`
	// audio file to send. Pass a file_id as string to send an audio file that exists on the Telegram
	// servers (recommended), pass an HTTP URL as a string for Telegram to get an audio file from the Internet,
	// or upload a new video using os.Open(<file_name>).
	Audio                    any             `json:"audio"`
	Performer                string          `json:"performer"`
	Title                    string          `json:"title"`
	Duration                 int             `json:"duration"`
	Caption                  string          `json:"caption"`
	ParseMode                string          `json:"parse_mode"`
	CaptionEntities          []MessageEntity `json:"caption_entities"`
	DisableNotification      bool            `json:"disable_notification"`
	ReplyToMessageId         int             `json:"reply_to_message_id"`
	AllowSendingWithoutReply bool            `json:"allow_sending_without_reply"`
	Keyboard
}

AudioData sends audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.

func (AudioData) Check

func (a AudioData) Check() error

func (AudioData) Send

func (a AudioData) Send(b Bot) (Response, error)

type BanChatMemberData

type BanChatMemberData struct {
	ChatId int `json:"chat_id"`
	UserId int `json:"user_id"`
	// Date when the user will be unbanned, unix time.
	// If user is banned for more than 366 days or less
	// than 30 seconds from the current time they are considered to be banned forever.
	// Applied for supergroups and channels only.
	UntilDate int `json:"until_date"`
	// Pass True to delete all messages from the chat for the user that is being removed.
	// If False, the user will be able to see messages in the group that were sent before
	// the user was removed. Always True for supergroups and channels.
	RevokeMessages bool `json:"revoke_messages"`
}

BanChatMemberData bans a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

func (BanChatMemberData) Check

func (ban BanChatMemberData) Check() error

func (BanChatMemberData) Send

func (ban BanChatMemberData) Send(b Bot) (Response, error)

type Bot

type Bot struct {
	// Token of your Bot.
	// This field is mandatory.
	Token string
	// Handler is invokes by webhookHandler when webhook sends a new update.
	Handler func(Update, Bot)
	// if set to true, each Handler will run in a seperated goroutine.
	Concurrent bool
	// set Proxy for all connections. make
	Proxy *url.URL
	// Debug if set to true, every time Listener receives something, it will be printed.
	Debug bool
}

Bot represents a bot. you can create multiple bots Token is required; but Handler and Self are optional

func (Bot) ActivateProxy

func (b Bot) ActivateProxy() error

func (Bot) Listener

func (b Bot) Listener(port string, ip ...string)

Listener listens to upcoming webhook updates and calls webhookHandler when telegram sends an update.

func (Bot) VerifyBot

func (b Bot) VerifyBot() (Response, error)

VerifyBot verifies the token

type BotCommand

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

type BotCommandScope

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

type BotCommandScopeAllGroupChats

type BotCommandScopeAllGroupChats struct {
	Type string `json:"type"`
}

type BotCommandScopeChat

type BotCommandScopeChat struct {
	Type   string `json:"type"`
	ChatId int    `json:"chat_id"`
}

type BotCommandScopeChatAdministrators

type BotCommandScopeChatAdministrators struct {
	Type   string `json:"type"`
	ChatId int    `json:"chat_id"`
}

type BotCommandScopeChatMember

type BotCommandScopeChatMember struct {
	Type   string `json:"type"`
	ChatId int    `json:"chat_id"`
	UserId int    `json:"user_id"`
}

type BotCommandScopeDefault

type BotCommandScopeDefault struct {
	Type string `json:"type"`
}

type CallbackGame

type CallbackGame struct {
	Active bool
}

CallbackGame is a placeholder, currently holds no information. Use BotFather to set up your game and set Active to true.

type CallbackQuery

type CallbackQuery struct {
	Id              string  `json:"id"`
	Message         Message `json:"message"`
	From            User    `json:"chat"`
	InlineMessageId string  `json:"inline_message_id"`
	ChatInstance    string  `json:"chat_instance"`
	Data            string  `json:"data"`
	GameShortName   string  `json:"game_short_name"`
}

type Chat

type Chat struct {
	Type                  string          `json:"type"`
	Title                 string          `json:"title"`
	Bio                   string          `json:"bio"`
	Photo                 ChatPhoto       `json:"photo"`
	Location              ChatLocation    `json:"location"`
	Description           string          `json:"description"`
	InviteLink            string          `json:"invite_link"`
	PinnedMessage         *Message        `json:"pinned_message"`
	Permissions           ChatPermissions `json:"permissions"`
	SlowModeDelay         int             `json:"slow_mode_delay"`
	MessageAutoDeleteTime int             `json:"message_auto_delete_time"`
	StickerSetName        string          `json:"sticker_set_name"`
	CanSetStickerSet      bool            `json:"can_set_sticker_set"`
	LinkedChatId          int             `json:"linked_chat_id"`
	ReplyAble
}

Chat id is a unique identification number of a Telegram chat (personal or group chat). However, the Telegram User id is a unique identification number of a particular Telegram user. Use Chat id for groups, and User id for a specific user

type ChatInviteLink struct {
	InviteLink  string `json:"invite_link"`
	Creator     User   `json:"creator"`
	IsPrimary   bool   `json:"is_primary"`
	IsRevoked   bool   `json:"is_revoked"`
	ExpireDate  int    `json:"expire_date"`
	MemberLimit int    `json:"member_limit"`
}

type ChatLocation

type ChatLocation struct {
	Address  string   `json:"address"`
	Location Location `json:"location"`
}

type ChatMemberAdministrator

type ChatMemberAdministrator struct {
	Status              string `json:"status"`
	User                User   `json:"user"`
	IsAnonymous         bool   `json:"is_anonymous"`
	CustomTitle         string `json:"custom_title"`
	CanBeEdited         bool   `json:"can_be_edited"`
	CanManageChat       bool   `json:"can_manage_chat"`
	CanDeleteMessages   bool   `json:"can_delete_messages"`
	CanManageVoiceChats bool   `json:"can_manage_voice_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"`
	CanEditMessages     bool   `json:"can_edit_messages"`
	CanPinMessages      bool   `json:"can_pin_messages"`
}

type ChatMemberBanned

type ChatMemberBanned struct {
	Status    string `json:"status"`
	User      User   `json:"user"`
	UntilDate bool   `json:"until_date"`
}

type ChatMemberLeft

type ChatMemberLeft struct {
	Status string `json:"status"`
	User   User   `json:"user"`
}

type ChatMemberMember

type ChatMemberMember struct {
	Status string `json:"status"`
	User   User   `json:"user"`
}

type ChatMemberOwner

type ChatMemberOwner struct {
	Status      string `json:"status"`
	User        User   `json:"user"`
	IsAnonymous bool   `json:"is_anonymous"`
	CustomTitle string `json:"custom_title"`
}

type ChatMemberRestricted

type ChatMemberRestricted struct {
	Status                string `json:"status"`
	User                  User   `json:"user"`
	IsMember              bool   `json:"is_member"`
	CanChangeInfo         bool   `json:"can_change_info"`
	CanInviteUsers        bool   `json:"can_invite_users"`
	CanPinMessages        bool   `json:"can_pin_messages"`
	CanSendMessages       bool   `json:"can_send_messages"`
	CanSendMediaMessages  bool   `json:"can_send_media_messages"`
	CanSendPolls          bool   `json:"can_send_polls"`
	CanSendOtherMessages  bool   `json:"can_send_other_messages"`
	CanAddWebPagePreviews bool   `json:"can_add_web_page_previews"`
	UntilDate             bool   `json:"until_date"`
}

type ChatPermissions

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

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"`
}

type Contact

type Contact struct {
	PhoneNumber string `json:"phone_number"`
	FirstName   string `json:"first_name"`
	LastName    string `json:"last_name"`
	UserId      int    `json:"user_id"`
	// Additional data about the contact in the form of a vCard
	Vcard string `json:"vcard"`
}

type ContactData

type ContactData struct {
	ChatId int `json:"chat_id"`
	Contact
	DisableNotification      bool `json:"disable_notification"`
	ReplyToMessageId         int  `json:"reply_to_message_id"`
	AllowSendingWithoutReply bool `json:"allow_sending_without_reply"`
	Keyboard
}

ContactData sends phone contacts. On success, the sent Message is returned.

func (ContactData) Check

func (c ContactData) Check() error

func (ContactData) Send

func (c ContactData) Send(b Bot) (Response, error)

type CopyMessageData

type CopyMessageData struct {
	// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
	ChatId int `json:"chat_id"`
	// Unique identifier for the chat where the original message was sent
	// (or channel username in the format @channelusername)
	FromChatId int `json:"from_chat_id"`
	// Message identifier in the chat specified in from_chat_id
	MessageId                int             `json:"message_id"`
	Caption                  string          `json:"caption"`
	ParseMode                string          `json:"parse_mode"`
	CaptionEntities          []MessageEntity `json:"caption_entities"`
	DisableNotification      bool            `json:"disable_notification"`
	ReplyToMessageId         int             `json:"reply_to_message_id"`
	AllowSendingWithoutReply bool            `json:"allow_sending_without_reply"`
	Keyboard
}

CopyMessageData copies messages of any kind. Service messages and invoice messages can't be copied. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageId of the sent message on success.

func (CopyMessageData) Check

func (c CopyMessageData) Check() error

func (CopyMessageData) Send

func (c CopyMessageData) Send(b Bot) (Response, error)

type CreateChatInviteLinkData

type CreateChatInviteLinkData struct {
	ChatId      int `json:"chat_id"`
	ExpireDate  int `json:"expire_date"`
	MemberLimit int `json:"member_limit"`
}

CreateChatInviteLinkData creates an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object.

func (CreateChatInviteLinkData) Check

func (c CreateChatInviteLinkData) Check() error

func (CreateChatInviteLinkData) Send

type CreateNewStickerSetData

type CreateNewStickerSetData struct {
	UserId        int          `json:"user_id"`
	Name          string       `json:"name"`
	Title         string       `json:"title"`
	Emojis        string       `json:"emojis"`
	PngSticker    any          `json:"png_sticker"`
	TgsSticker    *os.File     `json:"tgs_sticker"`
	WebmSticker   *os.File     `json:"webm_sticker"`
	ContainsMasks bool         `json:"contains_masks"`
	MaskPosition  MaskPosition `json:"mask_position"`
}

CreateNewStickerSetData creates a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. You must use exactly one of the fields PngSticker, TgsSticker, or WebmSticker. Returns True on success.

func (CreateNewStickerSetData) Check

func (c CreateNewStickerSetData) Check() error

func (CreateNewStickerSetData) Send

type DeleteChatPhotoData

type DeleteChatPhotoData struct {
	ChatId int `json:"chat_id"`
}

DeleteChatPhotoData deletes a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

func (DeleteChatPhotoData) Check

func (d DeleteChatPhotoData) Check() error

func (DeleteChatPhotoData) Send

func (d DeleteChatPhotoData) Send(b Bot) (Response, error)

type DeleteChatStickerSetData

type DeleteChatStickerSetData struct {
	ChatId int `json:"chat_id"`
}

DeleteChatStickerSetData deletes a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field Chat.CanSetStickerSet optionally returned in GetChatData requests to check if the bot can use this method. Returns True on success.

func (DeleteChatStickerSetData) Check

func (d DeleteChatStickerSetData) Check() error

func (DeleteChatStickerSetData) Send

type DeleteMessageData

type DeleteMessageData struct {
	ChatId    int `json:"chat_id"`
	MessageId int `json:"message_id"`
}

DeleteMessageData deletes a message, including service messages, with the following limitations: - A message can only be deleted if it was sent less than 48 hours ago. - A dice message in a private chat can only be deleted if it was sent more than 24 hours ago. - Bots can delete outgoing messages in private chats, groups, and supergroups. - Bots can delete incoming messages in private chats. - Bots granted can_post_messages permissions can delete outgoing messages in channels. - If the bot is an administrator of a group, it can delete any message there. - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there. Returns true on success.

func (DeleteMessageData) Check

func (d DeleteMessageData) Check() error

func (DeleteMessageData) Send

func (d DeleteMessageData) Send(b Bot) (Response, error)

type DeleteMyCommandsData

type DeleteMyCommandsData struct {
	// Scope describing scope of users for which the commands are relevant. Defaults to "default".
	Scope        BotCommandScope `json:"scope"`
	LanguageCode string          `json:"language_code"`
}

DeleteMyCommandsData deletes the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns True on success.

func (DeleteMyCommandsData) Check

func (d DeleteMyCommandsData) Check() error

func (DeleteMyCommandsData) Send

func (d DeleteMyCommandsData) Send(b Bot) (Response, error)

type DeleteStickerFromSetData

type DeleteStickerFromSetData struct {
	Sticker string `json:"sticker"`
}

DeleteStickerFromSetData deletes a sticker from a set created by the bot. Returns True on success.

func (DeleteStickerFromSetData) Check

func (d DeleteStickerFromSetData) Check() error

func (DeleteStickerFromSetData) Send

type Dice

type Dice struct {
	Emoji string `json:"emoji"`
	Value int    `json:"value"`
}

type DiceData

type DiceData struct {
	ChatId int `json:"chat_id"`
	// Emoji on which the dice throw animation is based.
	// Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”.
	// Dice can have values 1-6 for “🎲”, “🎯” and “🎳”,
	// values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”.
	// Defaults to “🎲”
	Emoji                    string `json:"emoji"`
	DisableNotification      bool   `json:"disable_notification"`
	ReplyToMessageId         int    `json:"reply_to_message_id"`
	AllowSendingWithoutReply bool   `json:"allow_sending_without_reply"`
	Keyboard
}

DiceData sends an animated emoji that will display a random value. On success, the sent Message is returned.

func (DiceData) Check

func (d DiceData) Check() error

func (DiceData) Send

func (d DiceData) Send(b Bot) (Response, error)

type Document

type Document struct {
	FileId       string    `json:"file_Id"`
	FileUniqueId string    `json:"file_unique_id"`
	Thumb        PhotoSize `json:"thumb"`
	FileName     string    `json:"file_name"`
	MimeType     string    `json:"mime_type"`
	FileSize     int       `json:"file_size"`
}

type DocumentData

type DocumentData struct {
	ChatId int `json:"chat_id"`
	// file to send. Pass a file_id as string to send an audio file that exists on the Telegram
	// servers (recommended), pass an HTTP URL as a string for Telegram to get a file from the Internet,
	// or upload a new video using os.Open(<file_name>).
	Document                    any             `json:"document"`
	Caption                     string          `json:"caption"`
	DisableContentTypeDetection bool            `json:"disable_content_type_detection"`
	ParseMode                   string          `json:"parse_mode"`
	CaptionEntities             []MessageEntity `json:"caption_entities"`
	DisableNotification         bool            `json:"disable_notification"`
	ReplyToMessageId            int             `json:"reply_to_message_id"`
	AllowSendingWithoutReply    bool            `json:"allow_sending_without_reply"`
	Keyboard
}

DocumentData sends general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.

func (DocumentData) Check

func (d DocumentData) Check() error

func (DocumentData) Send

func (d DocumentData) Send(b Bot) (Response, error)

type EditChatInviteLinkData

type EditChatInviteLinkData struct {
	ChatId      int    `json:"chat_id"`
	InviteLink  string `json:"invite_link"`
	ExpireDate  int    `json:"expire_date"`
	MemberLimit int    `json:"member_limit"`
}

EditChatInviteLinkData edits a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.

func (EditChatInviteLinkData) Check

func (e EditChatInviteLinkData) Check() error

func (EditChatInviteLinkData) Send

type EditMessageCaptionData

type EditMessageCaptionData struct {
	ChatId          int             `json:"chat_id"`
	MessageId       int             `json:"message_id"`
	InlineMessageId string          `json:"inline_message_id"`
	Caption         string          `json:"caption"`
	ParseMode       string          `json:"parse_mode"`
	CaptionEntities []MessageEntity `json:"caption_entities"`
	InlineKeyboard
}

EditMessageCaptionData edits captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

func (EditMessageCaptionData) Check

func (e EditMessageCaptionData) Check() error

func (EditMessageCaptionData) Send

type EditMessageMediaData

type EditMessageMediaData struct {
	// Required if ChatId and MessageId are not specified. Identifier of the inline message
	InlineMessageId string `json:"inline_message_id"`
	// pass InputMediaPhoto, InputMediaVideo, InputMediaDocument, InputMediaAudio or InputMediaAnimation
	Media InputMedia `json:"media"`
	// Required if InlineMessageId is not specified.
	// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
	ChatId int `json:"chat_id"`
	// Required if InlineMessageId is not specified. Identifier of the message to edit
	MessageId int `json:"message_id"`
	// Do Not change this field. It automatically will be set by EditMessageMediaData.Send
	// using returnFile of InputMedia
	Files []*os.File
	InlineKeyboard
}

EditMessageMediaData edits animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

func (EditMessageMediaData) Check

func (e EditMessageMediaData) Check() error

func (EditMessageMediaData) Send

func (e EditMessageMediaData) Send(b Bot) (Response, error)

type EditMessageReplyMarkupData

type EditMessageReplyMarkupData struct {
	ChatId          int    `json:"chat_id"`
	MessageId       int    `json:"message_id"`
	InlineMessageId string `json:"inline_message_id"`
	InlineKeyboard
}

EditMessageReplyMarkupData edits only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

func (EditMessageReplyMarkupData) Check

func (EditMessageReplyMarkupData) Send

type EditMessageTextData

type EditMessageTextData struct {
	Text                  string          `json:"text"`
	InlineMessageId       string          `json:"inline_message_id"`
	ChatId                int             `json:"chat_id"`
	MessageId             int             `json:"message_id"`
	ParseMode             string          `json:"parse_mode"`
	Entities              []MessageEntity `json:"entities"`
	DisableWebPagePreview bool            `json:"disable_web_page_preview"`
	InlineKeyboard
}

EditMessageTextData edits text and Game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

func (EditMessageTextData) Check

func (e EditMessageTextData) Check() error

func (EditMessageTextData) Send

func (e EditMessageTextData) Send(b Bot) (Response, error)

type EncryptedCredentials

type EncryptedCredentials struct {
	// Base64-encoded encrypted JSON-serialized data with unique user's payload,
	// data hashes and secrets required for EncryptedPassportElement decryption and authentication
	Data string `json:"data"`
	// Base64-encoded data hash for data authentication
	Hash string `json:"hash"`
	// Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption
	Secret string `json:"secret"`
}

type EncryptedPassportElement

type EncryptedPassportElement struct {
	Type        string         `json:"type"`
	Data        string         `json:"data"`
	PhoneNumber string         `json:"phone_number"`
	Email       string         `json:"email"`
	Files       []PassportFile `json:"files"`
	FrontSide   PassportFile   `json:"front_side"`
	ReverseSide PassportFile   `json:"reverse_side"`
	Selfie      PassportFile   `json:"selfie"`
	Translation []PassportFile `json:"translation"`
	Hash        string         `json:"hash"`
}

type ExportChatInviteLinkData

type ExportChatInviteLinkData struct {
	ChatId int `json:"chat_id"`
}

ExportChatInviteLinkData generates a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success.

func (ExportChatInviteLinkData) Check

func (e ExportChatInviteLinkData) Check() error

func (ExportChatInviteLinkData) Send

type File

type File struct {
	// Identifier for this file, which can be used to download or reuse the file
	FileId string `json:"file_id"`
	// Unique identifier for this file, which is supposed to be the same over time and for different bots.
	// Can't be used to download or reuse the file.
	FileUniqueId string `json:"file_unique_id"`
	// file size in bytes, if known. Optional
	FileSize int `json:"file_size"`
	// file path. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file. Optional
	FilePath string `json:"file_path"`
}

type ForceReply

type ForceReply struct {
	IsForceReply          bool   `json:"force_reply"`
	InputFieldPlaceholder string `json:"input_field_placeholder"`
	Selective             bool   `json:"selective"`
}

func (*ForceReply) SetForceReply

func (t *ForceReply) SetForceReply(selective bool, inputFieldPlaceholder string)

type ForwardMessageData

type ForwardMessageData struct {
	// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
	ChatId int `json:"chat_id"`
	// Unique identifier for the chat where the original message was
	// sent (or channel username in the format @channelusername)
	FromChatId int `json:"from_chat_id"`
	// message identifier in the chat specified in from_chat_id
	MessageId           int  `json:"message_id"`
	DisableNotification bool `json:"disable_notification"`
	ProtectContent      bool `json:"protect_content"`
}

ForwardMessageData forwards messages of any kind. Service messages can't be forwarded. On success, the sent Message is returned.

func (ForwardMessageData) Check

func (f ForwardMessageData) Check() error

func (ForwardMessageData) Send

func (f ForwardMessageData) Send(b Bot) (Response, error)

type Game

type Game struct {
	Title        string          `json:"title"`
	Description  string          `json:"description"`
	Photo        []PhotoSize     `json:"photo"`
	Text         string          `json:"text"`
	TextEntities []MessageEntity `json:"text_entities"`
	Animation    Animation       `json:"animation"`
}

type GameHighScore

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

type GetChatAdministratorsData

type GetChatAdministratorsData struct {
	ChatId int `json:"chat_id"`
}

GetChatAdministratorsData gets a list of administrators in a chat. On success, returns an array of ChatMember (https://core.telegram.org/bots/api#chatmember) objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.

func (GetChatAdministratorsData) Check

func (g GetChatAdministratorsData) Check() error

func (GetChatAdministratorsData) Send

type GetChatData

type GetChatData struct {
	ChatId int `json:"chat_id"`
}

GetChatData gets 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.). Returns a Chat object on success.

func (GetChatData) Check

func (g GetChatData) Check() error

func (GetChatData) Send

func (g GetChatData) Send(b Bot) (Response, error)

type GetChatMemberCountData

type GetChatMemberCountData struct {
	ChatId int `json:"chat_id"`
}

GetChatMemberCountData gets the number of members in a chat. Returns Int on success.

func (GetChatMemberCountData) Check

func (g GetChatMemberCountData) Check() error

func (GetChatMemberCountData) Send

type GetChatMemberData

type GetChatMemberData struct {
	ChatId int `json:"chat_id"`
	UserId int `json:"user_id"`
}

GetChatMemberData gets information about a member of a chat. Returns a ChatMember (https://core.telegram.org/bots/api#chatmember) object on success.

func (GetChatMemberData) Check

func (g GetChatMemberData) Check() error

func (GetChatMemberData) Send

func (g GetChatMemberData) Send(b Bot) (Response, error)

type GetFileData

type GetFileData struct {
	FileId string `json:"file_id"`
}

GetFileData gets basic info about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. 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 (GetFileData) Check

func (g GetFileData) Check() error

func (GetFileData) Send

func (g GetFileData) Send(b Bot) (Response, error)

type GetGameHighScoresData

type GetGameHighScoresData struct {
	UserId          int    `json:"user_id"`
	ChatId          int    `json:"chat_id"`
	MessageId       int    `json:"message_id"`
	InlineMessageId string `json:"inline_message_id"`
}

GetGameHighScoresData Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. On success, returns an Array of GameHighScore objects. This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and his neighbors are not among them. Please note that this behavior is subject to change.

func (GetGameHighScoresData) Check

func (g GetGameHighScoresData) Check() error

func (GetGameHighScoresData) Send

func (g GetGameHighScoresData) Send(b Bot) (Response, error)

type GetMyCommandsData

type GetMyCommandsData struct {
	// Scope describing scope of users for which the commands are relevant. Defaults to "default".
	Scope        BotCommandScope `json:"scope"`
	LanguageCode string          `json:"language_code"`
}

GetMyCommandsData gets the current list of the bot's commands for the given scope and user language. Returns Array of BotCommand on success. If commands aren't set, an empty list is returned.

func (GetMyCommandsData) Check

func (g GetMyCommandsData) Check() error

func (GetMyCommandsData) Send

func (g GetMyCommandsData) Send(b Bot) (Response, error)

type GetStickerSetData

type GetStickerSetData struct {
	Name string `json:"name"`
}

GetStickerSetData gets a sticker set. On success, a StickerSet object is returned.

func (GetStickerSetData) Check

func (g GetStickerSetData) Check() error

func (GetStickerSetData) Send

func (g GetStickerSetData) Send(b Bot) (Response, error)

type GetUserProfilePhotosData

type GetUserProfilePhotosData struct {
	UserId int `json:"user_id"`
	// Sequential number of the first photo to be returned.
	// By default, all photos are returned.
	Offset int `json:"offset"`
	// Limits the number of photos to be retrieved.
	// Values between 1-100 are accepted. Defaults to 100.
	Limit int `json:"limit"`
}

GetUserProfilePhotosData gets a list of profile pictures for a user. Returns a UserProfilePhotos object.

func (GetUserProfilePhotosData) Check

func (u GetUserProfilePhotosData) Check() error

func (GetUserProfilePhotosData) Send

type InlineButton

type InlineButton struct {
	// Label text on the button
	Text string `json:"text"`
	// Optional. HTTP or tg:// url to be opened
	// when button is pressed
	Url      string   `json:"url"`
	LoginUrl LoginUrl `json:"login_url"`
	// Optional. Data to be sent in a callback query
	// to the bot when button is pressed
	CallbackData string `json:"callback_data"`
	// Optional. If set, pressing the button will prompt the user to select one of their chats,
	// open that chat and insert the bot's username and the specified inline query in the input field.
	// Can be empty, in which case just the bot's username will be inserted.
	// Note: This offers an easy way for users to start using your bot in inline mode
	// when they are currently in a private chat with it.
	// Especially useful when combined with switch_pm… actions – in this case the user will be
	// automatically returned to the chat they switched from, skipping the chat selection screen.
	SwitchInlineQuery string `json:"switch_inline_query"`
	// Optional. If set, pressing the button will insert the bot's username and the specified
	// inline query in the current chat's input field.
	// Can be empty, in which case only the bot's username will be inserted.
	// This offers a quick way for the user to open your bot in inline mode
	// in the same chat – good for selecting something from multiple options.
	SwitchInlineQueryCurrentChat string       `json:"switch_inline_query_current_chat"`
	CallbackGame                 CallbackGame `json:"callback_game"`
	// Optional. Specify True, to send a Pay button.
	// NOTE: This type of button must always be the first button in the first row.
	Pay bool `json:"pay"`
}

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

type InlineKeyboard

type InlineKeyboard struct {
	Buttons [][]InlineButton `json:"inline_keyboard"`
}

func (*InlineKeyboard) AddInlineButtons

func (i *InlineKeyboard) AddInlineButtons(horizontal bool, a ...InlineButton) error

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"`
	Location Location `json:"location"`
}

func (InlineQuery) Answer

func (i InlineQuery) Answer(b Bot, data AnswerInlineQueryData) (response Response, err error)

type InlineQueryResultArticle

type InlineQueryResultArticle struct {
	Type                string         `json:"type"`
	Id                  string         `json:"id"`
	Title               string         `json:"title"`
	InputMessageContent MessageContent `json:"input_message_content"`
	Url                 string         `json:"url"`
	HideUrl             bool           `json:"hide_url"`
	Description         string         `json:"description"`
	ThumbUrl            string         `json:"thumb_url"`
	ThumbWidth          int            `json:"thumb_width"`
	ThumbHeight         int            `json:"thumb_height"`
	InlineKeyboard
}

type InlineQueryResultAudio

type InlineQueryResultAudio struct {
	Type                string          `json:"type"`
	Id                  string          `json:"id"`
	AudioUrl            string          `json:"audio_url"`
	AudioFileId         string          `json:"audio_file_id"`
	Title               string          `json:"title"`
	Caption             string          `json:"caption"`
	ParseMode           string          `json:"parse_mode"`
	CaptionEntities     []MessageEntity `json:"caption_entities"`
	Performer           string          `json:"performer"`
	AudioDuration       int             `json:"audio_duration"`
	InputMessageContent MessageContent  `json:"input_message_content"`
	InlineKeyboard
}

type InlineQueryResultContact

type InlineQueryResultContact struct {
	Type                string         `json:"type"`
	Id                  string         `json:"id"`
	PhoneNumber         string         `json:"phone_number"`
	FirstName           string         `json:"first_name"`
	LastName            string         `json:"last_name"`
	Vcard               string         `json:"vcard"`
	InputMessageContent MessageContent `json:"input_message_content"`
	ThumbUrl            string         `json:"thumb_url"`
	ThumbWidth          int            `json:"thumb_width"`
	ThumbHeight         int            `json:"thumb_height"`
	InlineKeyboard
}

type InlineQueryResultDocument

type InlineQueryResultDocument struct {
	Type                string          `json:"type"`
	Id                  string          `json:"id"`
	Title               string          `json:"title"`
	Caption             string          `json:"caption"`
	ParseMode           string          `json:"parse_mode"`
	CaptionEntities     []MessageEntity `json:"caption_entities"`
	DocumentUrl         string          `json:"document_url"`
	DocumentFileId      string          `json:"document_file_id"`
	MimeType            string          `json:"mime_type"`
	Description         string          `json:"description"`
	InputMessageContent MessageContent  `json:"input_message_content"`
	ThumbUrl            string          `json:"thumb_url"`
	ThumbWidth          int             `json:"thumb_width"`
	ThumbHeight         int             `json:"thumb_height"`
	InlineKeyboard
}

type InlineQueryResultGame

type InlineQueryResultGame struct {
	Type          string `json:"type"`
	Id            string `json:"id"`
	GameShortName string `json:"game_short_name"`
	InlineKeyboard
}

type InlineQueryResultGif

type InlineQueryResultGif struct {
	Type                string          `json:"type"`
	Id                  string          `json:"id"`
	GifUrl              string          `json:"gif_url"`
	GifFileId           string          `json:"gif_File_Id"`
	GifWidth            int             `json:"gif_width"`
	GifHeight           int             `json:"gif_height"`
	GifDuration         int             `json:"gif_duration"`
	ThumbUrl            string          `json:"thumb_url"`
	ThumbMimeType       string          `json:"thumb_mime_type"`
	Title               string          `json:"title"`
	Caption             string          `json:"caption"`
	ParseMode           string          `json:"parse_mode"`
	CaptionEntities     []MessageEntity `json:"caption_entities"`
	InputMessageContent MessageContent  `json:"input_message_content"`
	InlineKeyboard
}

type InlineQueryResultLocation

type InlineQueryResultLocation struct {
	Type                string         `json:"type"`
	Id                  string         `json:"id"`
	Title               string         `json:"title"`
	InputMessageContent MessageContent `json:"input_message_content"`
	ThumbUrl            string         `json:"thumb_url"`
	ThumbWidth          int            `json:"thumb_width"`
	ThumbHeight         int            `json:"thumb_height"`
	Location
	InlineKeyboard
}

type InlineQueryResultMpeg4Gif

type InlineQueryResultMpeg4Gif struct {
	Type                string          `json:"type"`
	Id                  string          `json:"id"`
	Mpeg4Url            string          `json:"mpeg4_url"`
	Mpeg4FileId         string          `json:"mpeg4_file_id"`
	Mpeg4Width          int             `json:"mpeg4_width"`
	Mpeg4Height         int             `json:"mpeg4_height"`
	Mpeg4Duration       int             `json:"mpeg4_duration"`
	ThumbUrl            string          `json:"thumb_url"`
	ThumbMimeType       string          `json:"thumb_mime_type"`
	Title               string          `json:"title"`
	Caption             string          `json:"caption"`
	ParseMode           string          `json:"parse_mode"`
	CaptionEntities     []MessageEntity `json:"caption_entities"`
	InputMessageContent MessageContent  `json:"input_message_content"`
	InlineKeyboard
}

type InlineQueryResultPhoto

type InlineQueryResultPhoto struct {
	Type                string          `json:"type"`
	Id                  string          `json:"id"`
	PhotoUrl            string          `json:"photo_url"`
	PhotoFileId         string          `json:"photo_file_id"`
	ThumbUrl            string          `json:"thumb_url"`
	PhotoWidth          int             `json:"photo_width"`
	PhotoHeight         int             `json:"photo_height"`
	Title               string          `json:"title"`
	Description         string          `json:"description"`
	Caption             string          `json:"caption"`
	ParseMode           string          `json:"parse_mode"`
	CaptionEntities     []MessageEntity `json:"caption_entities"`
	InputMessageContent MessageContent  `json:"input_message_content"`
	InlineKeyboard
}

type InlineQueryResultSticker

type InlineQueryResultSticker struct {
	Type                string         `json:"type"`
	Id                  string         `json:"id"`
	StickerFileId       string         `json:"sticker_file_id"`
	InputMessageContent MessageContent `json:"input_message_content"`
	InlineKeyboard
}

type InlineQueryResultVenue

type InlineQueryResultVenue struct {
	Type                string         `json:"type"`
	Id                  string         `json:"id"`
	Latitude            float64        `json:"latitude"`
	Longitude           float64        `json:"longitude"`
	Title               string         `json:"title"`
	Address             string         `json:"address"`
	FoursquareId        string         `json:"foursquare_id"`
	FoursquareType      string         `json:"foursquare_type"`
	GooglePlaceId       string         `json:"google_place_id"`
	GooglePlaceType     string         `json:"google_place_type"`
	InputMessageContent MessageContent `json:"input_message_content"`
	ThumbUrl            string         `json:"thumb_url"`
	ThumbWidth          int            `json:"thumb_width"`
	ThumbHeight         int            `json:"thumb_height"`
	InlineKeyboard
}

type InlineQueryResultVideo

type InlineQueryResultVideo struct {
	Type                string          `json:"type"`
	Id                  string          `json:"id"`
	VideoUrl            string          `json:"video_url"`
	VideoFileId         string          `json:"video_file_id"`
	MimeType            string          `json:"mime_type"`
	ThumbUrl            string          `json:"thumb_url"`
	Title               string          `json:"title"`
	Caption             string          `json:"caption"`
	ParseMode           string          `json:"parse_mode"`
	CaptionEntities     []MessageEntity `json:"caption_entities"`
	VideoWidth          int             `json:"video_width"`
	VideoHeight         int             `json:"video_height"`
	VideoDuration       int             `json:"video_duration"`
	Description         string          `json:"description"`
	InputMessageContent MessageContent  `json:"input_message_content"`
	InlineKeyboard
}

type InlineQueryResultVoice

type InlineQueryResultVoice struct {
	Type                string          `json:"type"`
	Id                  string          `json:"id"`
	VoiceUrl            string          `json:"voice_url"`
	VoiceFileId         string          `json:"voice_file_id"`
	Title               string          `json:"title"`
	Caption             string          `json:"caption"`
	ParseMode           string          `json:"parse_mode"`
	CaptionEntities     []MessageEntity `json:"caption_entities"`
	VoiceDuration       int             `json:"voice_duration"`
	InputMessageContent MessageContent  `json:"input_message_content"`
	InlineKeyboard
}

type InputContactMessageContent

type InputContactMessageContent struct {
	PhoneNumber string `json:"phone_number"`
	FirstName   string `json:"first_name"`
	LastName    string `json:"last_name"`
	Vcard       string `json:"vcard"`
}

type InputEmptyContent

type InputEmptyContent struct {
}

type InputInvoiceMessageContent

type InputInvoiceMessageContent struct {
	Title                     string         `json:"title"`
	Description               string         `json:"description"`
	Payload                   string         `json:"payload"`
	ProviderToken             string         `json:"provider_token"`
	Currency                  string         `json:"currency"`
	Prices                    []LabeledPrice `json:"prices"`
	MaxTipAmount              int            `json:"max_tip_amount"`
	SuggestedTipAmounts       []int          `json:"suggested_tip_amounts"`
	ProviderData              string         `json:"provider_data"`
	PhotoUrl                  string         `json:"photo_url"`
	PhotoSize                 int            `json:"photo_size"`
	PhotoWidth                int            `json:"photo_width"`
	PhotoHeight               int            `json:"photo_height"`
	NeedName                  bool           `json:"need_name"`
	NeedPhoneNumber           bool           `json:"need_phone_number"`
	NeedEmail                 bool           `json:"need_email"`
	NeedShippingAddress       bool           `json:"need_shipping_address"`
	SendPhoneNumberToProvider bool           `json:"send_phone_number_to_provider"`
	SendEmailToProvider       bool           `json:"send_email_to_provider"`
	IsFlexible                bool           `json:"is_flexible"`
}

type InputLocationMessageContent

type InputLocationMessageContent struct {
	Location
}

type InputMedia

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

type InputMediaAnimation

type InputMediaAnimation struct {
	// Type of the result, must be "animation"
	Type string `json:"type"`
	// Pass a file_id to send a file that exists on the Telegram servers (recommended),
	// pass an HTTP URL for Telegram to get a file from the Internet or pass a *os.File
	Media any `json:"media"`
	// Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing
	Caption         string          `json:"caption"`
	ParseMode       string          `json:"parse_mode"`
	CaptionEntities []MessageEntity `json:"caption_entities"`
	Width           int             `json:"width"`
	Height          int             `json:"height"`
}

type InputMediaAudio

type InputMediaAudio struct {
	// Type of the result, must be "audio"
	Type string `json:"type"`
	// Pass a file_id to send a file that exists on the Telegram servers (recommended),
	// pass an HTTP URL for Telegram to get a file from the Internet or pass a *os.File
	Media any `json:"media"`
	// Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing
	Caption         string          `json:"caption"`
	ParseMode       string          `json:"parse_mode"`
	CaptionEntities []MessageEntity `json:"caption_entities"`
	Duration        int             `json:"duration"`
	Performer       string          `json:"performer"`
	Tile            string          `json:"tile"`
}

type InputMediaDocument

type InputMediaDocument struct {
	// Type of the result, must be "document"
	Type string `json:"type"`
	// Pass a file_id to send a file that exists on the Telegram servers (recommended),
	// pass an HTTP URL for Telegram to get a file from the Internet or pass a *os.File
	Media any `json:"media"`
	// Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing
	Caption         string          `json:"caption"`
	ParseMode       string          `json:"parse_mode"`
	CaptionEntities []MessageEntity `json:"caption_entities"`
	// Optional. Disables automatic server-side content type detection for files uploaded using
	// multipart/form-data. Always true, if the document is sent as part of an album.
	DisableContentTypeDetection bool `json:"disable_content_type_detection"`
}

type InputMediaPhoto

type InputMediaPhoto struct {
	// Type of the result, must be "photo"
	Type string `json:"type"`
	// Pass a file_id to send a file that exists on the Telegram servers (recommended),
	// pass an HTTP URL for Telegram to get a file from the Internet or pass a *os.File
	Media any `json:"media"`
	// Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing
	Caption         string          `json:"caption"`
	ParseMode       string          `json:"parse_mode"`
	CaptionEntities []MessageEntity `json:"caption_entities"`
}

type InputMediaVideo

type InputMediaVideo struct {
	// Type of the result, must be "video"
	Type string `json:"type"`
	// Pass a file_id to send a file that exists on the Telegram servers (recommended),
	// pass an HTTP URL for Telegram to get a file from the Internet or pass a *os.File
	Media any `json:"media"`
	// Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing
	Caption           string          `json:"caption"`
	ParseMode         string          `json:"parse_mode"`
	Width             int             `json:"width"`
	Height            int             `json:"height"`
	Duration          int             `json:"duration"`
	SupportsStreaming bool            `json:"supports_streaming"`
	CaptionEntities   []MessageEntity `json:"caption_entities"`
}

type InputTextMessageContent

type InputTextMessageContent struct {
	MessageText           string          `json:"message_text"`
	ParseMode             string          `json:"parse_mode"`
	Entities              []MessageEntity `json:"entities"`
	DisableWebPagePreview bool            `json:"disable_web_page_preview"`
}

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"`
	FoursquareType  string  `json:"foursquare_type"`
	GooglePlaceId   string  `json:"google_place_id"`
	GooglePlaceType string  `json:"google_place_type"`
}

type Invoice

type Invoice struct {
	Title          string `json:"title"`
	Description    string `json:"description"`
	StartParameter string `json:"start_parameter"`
	Currency       string `json:"currency"`
	TotalAmount    int    `json:"total_amount"`
}

type Keyboard

type Keyboard struct {
	ReplyMarkup any `json:"reply_markup"`
}

func (*Keyboard) ForceReply

func (k *Keyboard) ForceReply(selective bool, inputFieldPlaceholder string)

func (*Keyboard) RemoveReplyKeyboard

func (k *Keyboard) RemoveReplyKeyboard(selective bool)

RemoveReplyKeyboard removes reply keyboard. Set selective to true if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the text of the Message object;

  1. if the bot's message is a reply (has reply_to_message_id), sender of the original message.

Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet.

func (*Keyboard) SetInlineKeyboard

func (k *Keyboard) SetInlineKeyboard(horizontal bool, a ...InlineButton) error

func (*Keyboard) SetReplyKeyboard

func (k *Keyboard) SetReplyKeyboard(optionalParams ReplyKeyboardOP, a ...ReplyButton) error

SetReplyKeyboard adds reply keyboard to message. optionalParams is optional and you can pass an empty ReplyKeyboardOP

type KeyboardButtonPollType

type KeyboardButtonPollType struct {
	// Optional. If quiz is passed, the user will be allowed to create only polls in the quiz mode.
	// If regular is passed, only regular polls will be allowed.
	// Otherwise, the user will be allowed to create a poll of any type.
	Type string `json:"type"`
}

type LabeledPrice

type LabeledPrice struct {
	Label  string `json:"label"`
	Amount int    `json:"amount"`
}

type LeaveChatData

type LeaveChatData struct {
	ChatId int `json:"chat_id"`
}

LeaveChatData leaves a group, supergroup or channel for your bot. Returns True on success.

func (LeaveChatData) Check

func (l LeaveChatData) Check() error

func (LeaveChatData) Send

func (l LeaveChatData) Send(b Bot) (Response, error)

type Location

type Location struct {
	Longitude            float64 `json:"longitude"`
	Latitude             float64 `json:"latitude"`
	HorizontalAccuracy   float64 `json:"horizontal_accuracy"`
	LivePeriod           int     `json:"live_period"`
	Heading              int     `json:"heading"`
	ProximityAlertRadius int     `json:"proximity_alert_radius"`
}

type LocationData

type LocationData struct {
	ChatId int `json:"chat_id"`
	Location
	DisableNotification      bool `json:"disable_notification"`
	ReplyToMessageId         int  `json:"reply_to_message_id"`
	AllowSendingWithoutReply bool `json:"allow_sending_without_reply"`
	Keyboard
}

LocationData sends point on the map. On success, the sent Message is returned.

func (LocationData) Check

func (l LocationData) Check() error

func (LocationData) Send

func (l LocationData) Send(b Bot) (Response, error)

type LoginUrl

type LoginUrl struct {
	Url                string `json:"url"`
	ForwardText        string `json:"forward_text"`
	BotUsername        string `json:"bot_username"`
	RequestWriteAccess bool   `json:"request_write_access"`
}

type MaskPosition

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

type MediaGroupData

type MediaGroupData struct {
	ChatId int          `json:"chat_id"`
	Media  []InputMedia `json:"media"`
	// leave this field. it will be set automatically.
	Files                    []*os.File
	ReplyToMessageId         int  `json:"reply_to_message_id"`
	AllowSendingWithoutReply bool `json:"allow_sending_without_reply"`
}

MediaGroupData sends a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned.

func (MediaGroupData) Check

func (m MediaGroupData) Check() error

func (MediaGroupData) Send

func (m MediaGroupData) Send(b Bot) (Response, error)

type Message

type Message struct {
	MessageId             int               `json:"message_id"`
	User                  User              `json:"from"`
	Chat                  Chat              `json:"chat"`
	SenderChat            Chat              `json:"sender_chat"`
	ForwardFrom           User              `json:"forward_from"`
	ForwardFromChat       Chat              `json:"forward_from_chat"`
	ForwardSignature      string            `json:"forward_signature"`
	ForwardSenderName     string            `json:"forward_sender_name"`
	ForwardDate           int               `json:"forward_date"`
	IsAutomaticForward    bool              `json:"is_automatic_forward"`
	ReplyToMessage        *Message          `json:"reply_to_message"`
	ViaBot                User              `json:"via_bot"`
	EditDate              int               `json:"edit_date"`
	HasProtectedContent   bool              `json:"has_protected_content"`
	MediaGroupId          string            `json:"media_group_id"`
	AuthorSignature       string            `json:"author_signature"`
	Text                  string            `json:"text"`
	Entities              []MessageEntity   `json:"entities"`
	Animation             Animation         `json:"animation"`
	Photo                 []PhotoSize       `json:"photo"`
	Audio                 Audio             `json:"audio"`
	Document              Document          `json:"document"`
	Sticker               Sticker           `json:"sticker"`
	Video                 Video             `json:"video"`
	VideoNote             VideoNote         `json:"video_note"`
	Voice                 Voice             `json:"voice"`
	Caption               string            `json:"caption"`
	CaptionEntities       []MessageEntity   `json:"caption_entities"`
	Contact               Contact           `json:"contact"`
	Dice                  Dice              `json:"dice"`
	Game                  Game              `json:"game"`
	Date                  int               `json:"date"`
	ReplyMarkup           InlineKeyboard    `json:"reply_markup"`
	Poll                  Poll              `json:"poll"`
	Venue                 Venue             `json:"venue"`
	Location              Location          `json:"location"`
	LeftChatMember        User              `json:"left_chat_member"`
	NewChatPhoto          []PhotoSize       `json:"new_chat_photo"`
	NewChatTitle          string            `json:"new_chat_title"`
	NewChatMembers        []User            `json:"new_chat_members"`
	DeleteChatPhoto       bool              `json:"delete_chat_photo"`
	GroupChatCreated      bool              `json:"group_chat_created"`
	SupergroupChatCreated bool              `json:"supergroup_chat_created"`
	ChannelChatCreated    bool              `json:"channel_chat_created"`
	MigrateToChatId       int               `json:"migrate_to_chat_id"`
	MigrateFromChatId     int               `json:"migrate_from_chat_id"`
	PinnedMessage         *Message          `json:"pinned_message"`
	PassportData          PasswordData      `json:"passport_data"`
	Invoice               Invoice           `json:"invoice"`
	SuccessfulPayment     SuccessfulPayment `json:"successful_payment"`
	ConnectedWebsite      string            `json:"connected_website"`
}

func (Message) TypeIndicator

func (m Message) TypeIndicator() string

TypeIndicator function returns the type of message.

type MessageContent

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

type MessageEntity

type MessageEntity struct {
	Type string
	// contains filtered or unexported fields
}

type Method

type Method interface {
	// Check is used in Request
	Check() error
	// Send Sends requests to telegram server using Request
	Send(b Bot) (Response, error)
}

type OrderInfo

type OrderInfo struct {
	Name            string          `json:"name"`
	PhoneNumber     string          `json:"phone_number"`
	Email           string          `json:"email"`
	ShippingAddress ShippingAddress `json:"shipping_address"`
}

type PassportBase

type PassportBase struct {
	Source  string `json:"source"`
	Type    string `json:"type"`
	Message string `json:"message"`
}

type PassportElementErrorDataField

type PassportElementErrorDataField struct {
	PassportBase
	FieldName string `json:"field_name"`
	DataHash  string `json:"data_hash"`
}

type PassportElementErrorFile

type PassportElementErrorFile struct {
	PassportBase
	FileHash string `json:"file_hash"`
}

type PassportElementErrorFiles

type PassportElementErrorFiles struct {
	PassportBase
	FileHashes []string `json:"file_hashes"`
}

type PassportElementErrorFrontSide

type PassportElementErrorFrontSide struct {
	PassportBase
	FileHash string `json:"file_hash"`
}

type PassportElementErrorReverseSide

type PassportElementErrorReverseSide struct {
	PassportBase
	FileHash string `json:"file_hash"`
}

type PassportElementErrorSelfie

type PassportElementErrorSelfie struct {
	PassportBase
	FileHash string `json:"file_hash"`
}

type PassportElementErrorTranslationFile

type PassportElementErrorTranslationFile struct {
	PassportBase
	FileHash string `json:"file_hash"`
}

type PassportElementErrorTranslationFiles

type PassportElementErrorTranslationFiles struct {
	PassportBase
	FileHashes []string `json:"file_hashes"`
}

type PassportElementErrorUnspecified

type PassportElementErrorUnspecified struct {
	PassportBase
	ElementHash string `json:"element_hash"`
}

type PassportFile

type PassportFile struct {
	FileId       string `json:"file_id"`
	FileUniqueId string `json:"file_unique_id"`
	FileSize     int    `json:"file_size"`
	FileDate     int    `json:"file_date"`
}

type PasswordData

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

type PhotoData

type PhotoData struct {
	// photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended),
	// pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new
	// video using os.Open(<file_name>). The photo must be at most 10 MB in size.
	// The photo's width and height must not exceed 10000 in total.
	// Width and height ratio must be at most 20.
	Photo                    any             `json:"photo"`
	ChatId                   int             `json:"chat_id"`
	ParseMode                string          `json:"parse_mode"`
	Caption                  string          `json:"caption"`
	CaptionEntities          []MessageEntity `json:"caption_entities"`
	DisableNotification      bool            `json:"disable_notification"`
	ReplyToMessageId         int             `json:"reply_to_message_id"`
	AllowSendingWithoutReply bool            `json:"allow_sending_without_reply"`
	Keyboard
}

PhotoData sends photos. On success, the sent Message is returned.

func (PhotoData) Check

func (p PhotoData) Check() error

func (PhotoData) Send

func (p PhotoData) Send(b Bot) (Response, error)

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     int    `json:"file_size"`
}

type PinChatMessageData

type PinChatMessageData struct {
	ChatId              int  `json:"chat_id"`
	MessageId           int  `json:"message_id"`
	DisableNotification bool `json:"disable_notification"`
}

PinChatMessageData adds a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.

func (PinChatMessageData) Check

func (p PinChatMessageData) Check() error

func (PinChatMessageData) Send

func (p PinChatMessageData) Send(b Bot) (Response, error)

type Poll

type Poll struct {
	Id              string       `json:"id"`
	Question        string       `json:"question"`
	Options         []PollOption `json:"options"`
	TotalVoterCount int          `json:"total_voter_count"`
	IsAnonymous     bool         `json:"is_anonymous,"`
	CloseDate       int          `json:"close_date"`
	// Pass True, if the poll needs to be immediately closed.
	// This can be useful for poll preview.
	IsClosed                 bool            `json:"is_closed"`
	Type                     string          `json:"type"`
	AllowSendingWithoutReply bool            `json:"allow_sending_without_reply"`
	CorrectOptionId          int             `json:"correct_option_id"`
	Explanation              string          `json:"explanation"`
	ExplanationEntities      []MessageEntity `json:"explanation_entities"`
	// Amount of time in seconds the poll will be active after
	// creation, 5-600. Can't be used together with close_date.
	OpenPeriod int `json:"open_period"`
}

type PollData

type PollData struct {
	ChatId      int      `json:"chat_id"`
	Question    string   `json:"question"`
	Options     []string `json:"options"`
	IsAnonymous bool     `json:"is_anonymous"`
	// Poll type, “quiz” or “regular”, defaults to “regular”
	Type string `json:"type"`
	// True, if the poll allows multiple answers,
	// ignored for polls in quiz mode, defaults to False
	AllowsMultipleAnswers bool `json:"allows_multiple_answers"`
	// 0-based identifier of the correct answer option,
	// required for polls in quiz mode
	CorrectOptionId int `json:"correct_option_id"`
	// Text that is shown when a user chooses an
	// incorrect answer or taps on the lamp icon in a
	// quiz-style poll, 0-200 characters with at most 2 line
	// feeds after entities parsing
	Explanation          string          `json:"explanation"`
	ExplanationParseMode string          `json:"explanation_parse_mode"`
	ExplanationEntities  []MessageEntity `json:"explanation_entities"`
	// Amount of time in seconds the poll will be active after
	// creation, 5-600. Can't be used together with close_date.
	OpenPeriod int `json:"open_period"`
	// Point in time (Unix timestamp) when the poll will
	// be automatically closed. Must be at least 5 and no more
	// than 600 seconds in the future.
	// Can't be used together with open_period.
	CloseDate int `json:"close_date"`
	// Pass True, if the poll needs to be immediately closed.
	// This can be useful for poll preview.
	IsClosed                 bool `json:"is_closed"`
	DisableNotification      bool `json:"disable_notification"`
	ReplyToMessageId         int  `json:"reply_to_message_id"`
	AllowSendingWithoutReply bool `json:"allow_sending_without_reply"`
	Keyboard
}

PollData sends a native poll. On success, the sent Message is returned.

func (PollData) Check

func (p PollData) Check() error

func (PollData) Send

func (p PollData) Send(b Bot) (Response, error)

type PollOption

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

type PromoteChatMemberData

type PromoteChatMemberData struct {
	ChatId int `json:"chat_id"`
	UserId int `json:"user_id"`
	// Pass True, if the administrator's presence in the chat is hidden.
	IsAnonymous bool `json:"is_anonymous"`
	// Pass True, if the administrator can access the chat event log, chat statistics,
	// message statistics in channels, see channel members, see anonymous administrators
	// in supergroups and ignore slow mode. Implied by any other administrator privilege.
	CanManageChat bool `json:"can_manage_chat"`
	// Pass True, if the administrator can create channel posts, channels only.
	CanPostMessages bool `json:"can_post_messages"`
	// Pass True, if the administrator can edit messages of other users and can pin messages, channels only.
	CanEditMessages bool `json:"can_edit_messages"`
	// Pass True, if the administrator can delete messages of other users.
	CanDeleteMessages bool `json:"can_delete_messages"`
	// Pass True, if the administrator can manage voice chats.
	CanManageVoiceChats bool `json:"can_manage_voice_chats"`
	// Pass True, if the administrator can restrict, ban or unban chat members.
	CanRestrictMembers bool `json:"can_restrict_members"`
	// Pass True, if the administrator can add new administrators with a subset of their own privileges
	// or demote administrators that he has promoted, directly or indirectly
	// (promoted by administrators that were appointed by him)
	CanPromoteMembers bool `json:"can_promote_members"`
	// Pass True, if the administrator can change chat title, photo and other settings
	CanChangeInfo bool `json:"can_change_info"`
	// Pass True, if the administrator can invite new users to the chat
	CanInviteUsers bool `json:"can_invite_users"`
	// Pass True, if the administrator can pin messages, supergroups only
	CanPinMessages bool `json:"can_pin_messages"`
}

PromoteChatMemberData promotes or demotes a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success.

func (PromoteChatMemberData) Check

func (p PromoteChatMemberData) Check() error

func (PromoteChatMemberData) Send

func (p PromoteChatMemberData) Send(b Bot) (Response, error)

type QueryAnswer

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

type ReplyAble

type ReplyAble struct {
	Id        int    `json:"id"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Username  string `json:"username"`
}

type ReplyButton

type ReplyButton struct {
	// Text of the button. If none of the optional fields are used,
	// it will be sent as a message when the button is pressed
	Text string `json:"text"`
	// Optional. If True, the user's phone number will be sent as a contact when the button is pressed.
	// Available in private chats only
	RequestContact bool `json:"request_contact"`
	// Optional. If True, the user's current location will be sent when the button is pressed.
	// Available in private chats only
	RequestLocation bool `json:"request_location"`
	// Optional. If specified, the user will be asked to create a poll and send it to the bot
	// when the button is pressed. Available in private chats only
	RequestPoll KeyboardButtonPollType `json:"request_poll"`
}

ReplyButton represents one button of a reply keyboard.

type ReplyKeyboard

type ReplyKeyboard struct {
	Keyboard              [][]ReplyButton `json:"keyboard"`
	OneTimeKeyboard       bool            `json:"one_time_keyboard"`
	ResizeKeyboard        bool            `json:"resize_keyboard"`
	InputFieldPlaceholder string          `json:"input_field_placeholder"`
	Selective             bool            `json:"selective"`
}

func (*ReplyKeyboard) AddReplyButtons

func (r *ReplyKeyboard) AddReplyButtons(optionalParams ReplyKeyboardOP, a ...ReplyButton) error

type ReplyKeyboardOP

type ReplyKeyboardOP struct {
	Horizontal            bool   `json:"horizontal"`
	OneTimeKeyboard       bool   `json:"one_time_keyboard"`
	ResizeKeyboard        bool   `json:"resize_keyboard"`
	InputFieldPlaceholder string `json:"input_field_placeholder"`
	Selective             bool   `json:"selective"`
}

type ReplyKeyboardRemove

type ReplyKeyboardRemove struct {
	RemoveKeyboard bool `json:"remove_keyboard"`
	Selective      bool `json:"selective"`
}

func (*ReplyKeyboardRemove) Remove

func (r *ReplyKeyboardRemove) Remove(selective bool)

Remove sets ReplyKeyboardRemove fields. Set selective to true if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the text of the Message object;

  1. if the bot's message is a reply (has reply_to_message_id), sender of the original message.

Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven't voted yet.

type Response

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

func Request

func Request(method string, bot Bot, data Method, response Response) (Response, error)

type ResponseImpl

type ResponseImpl struct {
	Ok          bool   `json:"ok"`
	ErrorCode   int    `json:"error_code"`
	Description string `json:"description"`
	Result      any    `json:"result"`
}

type RestrictChatMemberData

type RestrictChatMemberData struct {
	ChatId      int             `json:"chat_id"`
	UserId      int             `json:"user_id"`
	Permissions ChatPermissions `json:"permissions"`
	UntilDate   int             `json:"until_date"`
}

RestrictChatMemberData restricts a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.

func (RestrictChatMemberData) Check

func (r RestrictChatMemberData) Check() error

func (RestrictChatMemberData) Send

type RevokeChatInviteLinkData

type RevokeChatInviteLinkData struct {
	ChatId     int    `json:"chat_id"`
	InviteLink string `json:"invite_link"`
}

RevokeChatInviteLinkData revokes an invitation link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.

func (RevokeChatInviteLinkData) Check

func (r RevokeChatInviteLinkData) Check() error

func (RevokeChatInviteLinkData) Send

type SendChatActionData

type SendChatActionData struct {
	ChatId int    `json:"chat_id"`
	Action string `json:"action"`
}

SendChatActionData tells 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). for more info visit https://core.telegram.org/bots/api#sendchataction Returns True on success.

func (SendChatActionData) Check

func (s SendChatActionData) Check() error

func (SendChatActionData) Send

func (s SendChatActionData) Send(b Bot) (Response, error)

type SendGameData

type SendGameData struct {
	ChatId                   int    `json:"chat_id"`
	GameShortName            string `json:"game_short_name"`
	DisableNotification      bool   `json:"disable_notification"`
	ProtectContent           bool   `json:"protect_content"`
	ReplyToMessageId         int    `json:"reply_to_message_id"`
	AllowSendingWithoutReply bool   `json:"allow_sending_without_reply"`
	InlineKeyboard
}

SendGameData sends a game. On success, the sent Message is returned.

func (SendGameData) Check

func (s SendGameData) Check() error

func (SendGameData) Send

func (s SendGameData) Send(b Bot) (Response, error)

type SendInvoiceData

type SendInvoiceData struct {
	ChatId                    int            `json:"chat_id"`
	Title                     string         `json:"title"`
	Description               string         `json:"description"`
	Payload                   string         `json:"payload"`
	ProviderToken             string         `json:"provider_token"`
	Currency                  string         `json:"currency"`
	Prices                    []LabeledPrice `json:"prices"`
	MaxTipAmount              int            `json:"max_tip_amount"`
	SuggestedTipAmounts       []int          `json:"suggested_tip_amounts"`
	StartParameter            string         `json:"start_parameter"`
	ProviderData              string         `json:"provider_data"`
	PhotoUrl                  string         `json:"photo_url"`
	PhotoSize                 int            `json:"photo_size"`
	PhotoWidth                int            `json:"photo_width"`
	PhotoHeight               int            `json:"photo_height"`
	NeedName                  bool           `json:"need_name"`
	NeedPhoneNumber           bool           `json:"need_phone_number"`
	NeedEmail                 bool           `json:"need_email"`
	NeedShippingAddress       bool           `json:"need_shipping_address"`
	SendPhoneNumberToProvider bool           `json:"send_phone_number_to_provider"`
	SendEmailToProvider       bool           `json:"send_email_to_provider"`
	IsFlexible                bool           `json:"is_flexible"`
	DisableNotification       bool           `json:"disable_notification"`
	ProtectContent            bool           `json:"protect_content"`
	ReplyToMessageId          int            `json:"reply_to_message_id"`
	AllowSendingWithoutReply  bool           `json:"allow_sending_without_reply"`
	InlineKeyboard
}

SendInvoiceData sends invoices. On success, the sent Message is returned.

func (SendInvoiceData) Check

func (s SendInvoiceData) Check() error

func (SendInvoiceData) Send

func (s SendInvoiceData) Send(b Bot) (Response, error)

type SendStickerData

type SendStickerData struct {
	ChatId                   int `json:"chat_id"`
	Sticker                  `json:"sticker"`
	DisableNotification      bool `json:"disable_notification"`
	ReplyToMessageId         int  `json:"reply_To_Message_Id"`
	AllowSendingWithoutReply bool `json:"allow_sending_without_reply"`
	Keyboard
}

SendStickerData sends static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned.

func (SendStickerData) Check

func (s SendStickerData) Check() error

func (SendStickerData) Send

func (s SendStickerData) Send(b Bot) (Response, error)

type SetChatAdministratorCustomTitleData

type SetChatAdministratorCustomTitleData struct {
	ChatId      int    `json:"chat_id"`
	UserId      int    `json:"user_id"`
	CustomTitle string `json:"custom_title"`
}

SetChatAdministratorCustomTitleData sets a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.

func (SetChatAdministratorCustomTitleData) Check

func (SetChatAdministratorCustomTitleData) Send

type SetChatDescriptionData

type SetChatDescriptionData struct {
	ChatId      int    `json:"chat_id"`
	Description string `json:"description"`
}

SetChatDescriptionData changes the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

func (SetChatDescriptionData) Check

func (s SetChatDescriptionData) Check() error

func (SetChatDescriptionData) Send

type SetChatPermissionsData

type SetChatPermissionsData struct {
	ChatId      int             `json:"chat_id"`
	Permissions ChatPermissions `json:"permissions"`
}

SetChatPermissionsData sets default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success.

func (SetChatPermissionsData) Check

func (s SetChatPermissionsData) Check() error

func (SetChatPermissionsData) Send

type SetChatPhotoData

type SetChatPhotoData struct {
	ChatId int      `json:"chat_id"`
	Photo  *os.File `json:"photo"`
}

SetChatPhotoData sets a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

func (SetChatPhotoData) Check

func (s SetChatPhotoData) Check() error

func (SetChatPhotoData) Send

func (s SetChatPhotoData) Send(b Bot) (Response, error)

type SetChatStickerSetData

type SetChatStickerSetData struct {
	ChatId         int    `json:"chat_id"`
	StickerSetName string `json:"sticker_set_name"`
}

SetChatStickerSetData sets a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field Chat.CanSetStickerSet optionally returned in GetChatData requests to check if the bot can use this method. Returns True on success.

func (SetChatStickerSetData) Check

func (s SetChatStickerSetData) Check() error

func (SetChatStickerSetData) Send

func (s SetChatStickerSetData) Send(b Bot) (Response, error)

type SetChatTitleData

type SetChatTitleData struct {
	ChatId int    `json:"chat_id"`
	Title  string `json:"title"`
}

SetChatTitleData changes the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

func (SetChatTitleData) Check

func (s SetChatTitleData) Check() error

func (SetChatTitleData) Send

func (s SetChatTitleData) Send(b Bot) (Response, error)

type SetGameScoreData

type SetGameScoreData struct {
	UserId             int    `json:"user_id"`
	Score              int    `json:"score"`
	Force              bool   `json:"force"`
	DisableEditMessage bool   `json:"disable_edit_message"`
	ChatId             int    `json:"chat_id"`
	MessageId          int    `json:"message_id"`
	InlineMessageId    string `json:"inline_message_id"`
}

SetGameScoreData sets the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.

func (SetGameScoreData) Check

func (s SetGameScoreData) Check() error

func (SetGameScoreData) Send

func (s SetGameScoreData) Send(b Bot) (Response, error)

type SetMyCommandsData

type SetMyCommandsData struct {
	Commands []BotCommand `json:"commands"`
	// Scope describing scope of users for which the commands are relevant. Defaults to "default".
	Scope        BotCommandScope `json:"scope"`
	LanguageCode string          `json:"language_code"`
}

SetMyCommandsData changes the list of the bot's commands. See https://core.telegram.org/bots#commands for more details about bot commands. Returns True on success.

func (SetMyCommandsData) Check

func (s SetMyCommandsData) Check() error

func (SetMyCommandsData) Send

func (s SetMyCommandsData) Send(b Bot) (Response, error)

type SetPassportDataErrors

type SetPassportDataErrors struct {
	// user identifier
	ChatId int `json:"user_id"`
	// an array describing the errors
	Errors []passport `json:"errors"`
}

func (SetPassportDataErrors) Check

func (s SetPassportDataErrors) Check() error

func (SetPassportDataErrors) Send

func (s SetPassportDataErrors) Send(b Bot) (response Response, err error)

type SetStickerPositionInSetData

type SetStickerPositionInSetData struct {
	Sticker  string `json:"sticker"`
	Position int    `json:"position"`
}

SetStickerPositionInSetData moves a sticker in a set created by the bot to a specific position.

func (SetStickerPositionInSetData) Check

func (SetStickerPositionInSetData) Send

type SetStickerSetThumbData

type SetStickerSetThumbData struct {
	UserId int    `json:"user_id"`
	Name   string `json:"name"`
	Thumb  any    `json:"thumb"`
}

SetStickerSetThumbData sets the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only. Video thumbnails can be set only for video sticker sets only. Returns True on success.

func (SetStickerSetThumbData) Check

func (s SetStickerSetThumbData) Check() error

func (SetStickerSetThumbData) Send

type SetWebhookData

type SetWebhookData struct {
	// HTTPS url to send updates to. Use an empty string to remove webhook integration
	Url                string   `json:"url"`
	Certificate        *os.File `json:"certificate"`
	IpAddress          string   `json:"ip_address"`
	MaxConnections     int      `json:"max_connections"`
	AllowedUpdates     []string `json:"allowed_updates"`
	DropPendingUpdates bool     `json:"drop_pending_updates"`
}

SetWebhookData specifies an url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, telegram will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. If you'd like to make sure that the Webhook request comes from Telegram, we recommend using a secret path in the URL, e.g. https://www.example.com/<token>. Since nobody else knows your bot's token, you can be pretty sure it's us.

func (SetWebhookData) Check

func (s SetWebhookData) Check() error

func (SetWebhookData) Send

func (s SetWebhookData) Send(b Bot) (Response, error)

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"`
}

type ShippingOptions

type ShippingOptions struct {
	Id     string         `json:"id"`
	Title  string         `json:"title"`
	Prices []LabeledPrice `json:"prices"`
}

type Sticker

type Sticker struct {
	FileId       string       `json:"file_id"`
	FileUniqueId string       `json:"file_unique_id"`
	Width        int          `json:"width"`
	Height       int          `json:"height"`
	IsAnimated   bool         `json:"is_animated"`
	Thumb        PhotoSize    `json:"thumb"`
	Emoji        string       `json:"emoji"`
	SetName      string       `json:"set_name"`
	MaskPosition MaskPosition `json:"mask_position"`
	FileSize     int          `json:"file_size"`
}

type StickerSet

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"`
	Thumb         PhotoSize `json:"thumb"`
}

type StopPollData

type StopPollData struct {
	ChatId    int `json:"chat_id"`
	MessageId int `json:"message_id"`
	InlineKeyboard
}

StopPollData stops a poll which was sent by the bot. On success, the stopped Poll is returned.

func (StopPollData) Check

func (s StopPollData) Check() error

func (StopPollData) Send

func (s StopPollData) Send(b Bot) (Response, error)

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"`
	OrderInfo               OrderInfo `json:"order_info"`
	TelegramPaymentChargeId string    `json:"telegram_payment_charge_id"`
	ProviderPaymentChargeId string    `json:"provider_payment_charge_id"`
}

type TextData

type TextData struct {
	Text                     string          `json:"text"`
	ChatId                   int             `json:"chat_id"`
	ParseMode                string          `json:"parse_mode"`
	Entities                 []MessageEntity `json:"entities"`
	DisableWebPagePreview    bool            `json:"disable_web_page_preview"`
	DisableNotification      bool            `json:"disable_notification"`
	ReplyToMessageId         int             `json:"reply_to_message_id"`
	AllowSendingWithoutReply bool            `json:"allow_sending_without_reply"`
	Keyboard
}

TextData sends text messages. On success, the sent Message is returned.

func (TextData) Check

func (t TextData) Check() error

func (TextData) Send

func (t TextData) Send(b Bot) (Response, error)

type UnbanChatMemberData

type UnbanChatMemberData struct {
	ChatId       int  `json:"chat_id"`
	UserId       int  `json:"user_id"`
	OnlyIfBanned bool `json:"only_if_banned"`
}

UnbanChatMemberData unbans a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don't want this, use the parameter only_if_banned. Returns True on success.

func (UnbanChatMemberData) Check

func (u UnbanChatMemberData) Check() error

func (UnbanChatMemberData) Send

func (u UnbanChatMemberData) Send(b Bot) (Response, error)

type UnpinAllChatMessagesData

type UnpinAllChatMessagesData struct {
	ChatId int `json:"chat_id"`
}

UnpinAllChatMessagesData clears the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.

func (UnpinAllChatMessagesData) Check

func (u UnpinAllChatMessagesData) Check() error

func (UnpinAllChatMessagesData) Send

type UnpinChatMessageData

type UnpinChatMessageData struct {
	ChatId    int `json:"chat_id"`
	MessageId int `json:"message_id"`
}

UnpinChatMessageData removes a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns True on success.

func (UnpinChatMessageData) Check

func (u UnpinChatMessageData) Check() error

func (UnpinChatMessageData) Send

func (u UnpinChatMessageData) Send(b Bot) (Response, error)

type Update

type Update struct {
	UpdateId      int           `json:"update_id"`
	Message       Message       `json:"message"`
	InlineQuery   InlineQuery   `json:"inline_query"`
	CallbackQuery CallbackQuery `json:"callback_query"`
	Poll          Poll          `json:"poll"`
}

Update from webhook

func (Update) String

func (u Update) String() string

type UploadStickerFileData

type UploadStickerFileData struct {
	UserId     int      `json:"user_id"`
	PngSticker *os.File `json:"png_sticker"`
}

UploadStickerFileData uploads a .PNG file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success.

func (UploadStickerFileData) Check

func (u UploadStickerFileData) Check() error

func (UploadStickerFileData) Send

func (u UploadStickerFileData) Send(b Bot) (Response, error)

type User

type User struct {
	// SupportsInlineQueries shows if Bot supports inline queries
	// This field is only for bots
	SupportsInlineQueries   bool   `json:"supports_inline_queries"`
	LanguageCode            string `json:"language_code"`
	IsBot                   bool   `json:"is_bot"`
	CanReadAllGroupMessages bool   `json:"can_read_all_group_messages"`
	CanJoinGroups           bool   `json:"can_join_groups"`
	ReplyAble
}

User id is a unique identification number of a particular Telegram user. However, the Telegram Chat id is a unique identification number of a Telegram chat (personal or group chat). Use Chat id for groups, and User id for a specific user

type UserProfilePhotos

type UserProfilePhotos struct {
	// Total number of profile pictures the target user has
	TotalCount int           `json:"total_count"`
	Photos     [][]PhotoSize `json:"photos"`
}

type Venue

type Venue struct {
	Location
	Title           string `json:"title"`
	Address         string `json:"address"`
	FoursquareId    string `json:"foursquare_id"`
	FoursquareType  string `json:"foursquare_type"`
	GooglePlaceId   string `json:"google_place_id"`
	GooglePlaceType string `json:"google_place_type"`
}

type Video

type Video struct {
	FileId       string    `json:"file_Id"`
	FileUniqueId string    `json:"file_unique_id"`
	Duration     int       `json:"duration"`
	Width        int       `json:"width"`
	Height       int       `json:"height"`
	Thumb        PhotoSize `json:"thumb"`
	FileName     string    `json:"file_name"`
	MimeType     string    `json:"mime_type"`
	FileSize     int       `json:"file_size"`
}

type VideoData

type VideoData struct {
	ChatId int `json:"chat_id"`
	// video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended),
	// pass an HTTP URL as a String for Telegram to get a video from the Internet, or
	// upload a new video using os.Open(<file_name>).
	Video                    any             `json:"video"`
	Duration                 int             `json:"duration"`
	Width                    int             `json:"width"`
	Height                   int             `json:"height"`
	Caption                  string          `json:"caption"`
	ParseMode                string          `json:"parse_mode"`
	CaptionEntities          []MessageEntity `json:"caption_entities"`
	SupportsStreaming        bool            `json:"supports_streaming"`
	DisableNotification      bool            `json:"disable_notification"`
	ReplyToMessageId         int             `json:"reply_to_message_id"`
	AllowSendingWithoutReply bool            `json:"allow_sending_without_reply"`
	Keyboard
}

VideoData sends video files, Telegram clients support mp4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.

func (VideoData) Check

func (v VideoData) Check() error

func (VideoData) Send

func (v VideoData) Send(b Bot) (Response, error)

type VideoNote

type VideoNote struct {
	FileId       string    `json:"file_Id"`
	FileUniqueId string    `json:"file_unique_id"`
	Length       int       `json:"length"`
	Duration     int       `json:"duration"`
	Thumb        PhotoSize `json:"thumb"`
	FileSize     int       `json:"file_size"`
}

type VideoNoteData

type VideoNoteData struct {
	ChatId                   int  `json:"chat_id"`
	VideoNote                any  `json:"videoNote"`
	Duration                 int  `json:"duration"`
	Length                   int  `json:"length"`
	DisableNotification      bool `json:"disable_notification"`
	ReplyToMessageId         int  `json:"reply_to_message_id"`
	AllowSendingWithoutReply bool `json:"allow_sending_without_reply"`
	Keyboard
}

VideoNoteData sends video messages. As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. On success, the sent Message is returned.

func (VideoNoteData) Check

func (v VideoNoteData) Check() error

func (VideoNoteData) Send

func (v VideoNoteData) Send(b Bot) (Response, error)

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"`
	FileSize     int    `json:"file_size"`
}

type VoiceData

type VoiceData struct {
	ChatId int `json:"chat_id"`
	// audio file to send. Pass a file_id as string to send an audio file that exists on the Telegram
	// servers (recommended), pass an HTTP URL as a string for Telegram to get an audio file from the Internet,
	// or upload a new video using os.Open(<file_name>).
	Voice                    any             `json:"voice"`
	Duration                 int             `json:"duration"`
	Caption                  string          `json:"caption"`
	ParseMode                string          `json:"parse_mode"`
	CaptionEntities          []MessageEntity `json:"caption_entities"`
	DisableNotification      bool            `json:"disable_notification"`
	ReplyToMessageId         int             `json:"reply_to_message_id"`
	AllowSendingWithoutReply bool            `json:"allow_sending_without_reply"`
	Keyboard
}

VoiceData sends 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). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.

func (VoiceData) Check

func (v VoiceData) Check() error

func (VoiceData) Send

func (v VoiceData) Send(b Bot) (Response, error)

Jump to

Keyboard shortcuts

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