1
0
Fork 0

👽 Maybe API v5.0 upgrade?

This commit is contained in:
Maxim Lebedev 2020-11-05 13:28:32 +05:00
parent d76ec735d4
commit 3db46d87c0
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
13 changed files with 899 additions and 314 deletions

4
bot.go
View File

@ -271,11 +271,11 @@ func (b *Bot) NewLongPollingChannel(params *GetUpdates) UpdatesChannel {
}
for _, update := range updates {
if update.UpdateID < params.Offset {
if update.ID < params.Offset {
continue
}
params.Offset = update.UpdateID + 1
params.Offset = update.ID + 1
b.Updates <- update
}
}

View File

@ -1,9 +1,7 @@
package telegram
import "github.com/Masterminds/semver"
// Version represents current version of Telegram API supported by this package
var Version = semver.MustParse("4.9.0") //nolint: gochecknoglobals
const Version = "5.0.0"
// Action represents available and supported status actions of bot
const (
@ -27,7 +25,8 @@ const (
ChatSuperGroup string = "supergroup"
)
// Command represents global commands which should be supported by any bot. You can user IsCommandEqual method of Message for checking.
// Command represents global commands which should be supported by any bot. You can user IsCommandEqual method of
// Message for checking.
//
// See: https://core.telegram.org/bots#global-commands
const (
@ -62,6 +61,8 @@ const (
MethodAnswerInlineQuery string = "answerInlineQuery"
MethodAnswerPreCheckoutQuery string = "answerPreCheckoutQuery"
MethodAnswerShippingQuery string = "answerShippingQuery"
MethodClose string = "close"
MethodCopyMessage string = "copyMessage"
MethodCreateNewStickerSet string = "createNewStickerSet"
MethodDeleteChatPhoto string = "deleteChatPhoto"
MethodDeleteChatStickerSet string = "deleteChatStickerSet"
@ -89,6 +90,7 @@ const (
MethodGetWebhookInfo string = "getWebhookInfo"
MethodKickChatMember string = "kickChatMember"
MethodLeaveChat string = "leaveChat"
MethodLogOut string = "logOut"
MethodPinChatMessage string = "pinChatMessage"
MethodPromoteChatMember string = "promoteChatMember"
MethodRestrictChatMember string = "restrictChatMember"
@ -125,6 +127,7 @@ const (
MethodStopMessageLiveLocation string = "stopMessageLiveLocation"
MethodStopPoll string = "stopPoll"
MethodUnbanChatMember string = "unbanChatMember"
MethodUnpinAllChatMessages string = "unpinAllChatMessages"
MethodUnpinChatMessage string = "unpinChatMessage"
MethodUploadStickerFile string = "uploadStickerFile"
)
@ -228,7 +231,16 @@ const (
// Emoji represents emoji supported by SendDice method
const (
EmojiGameDie string = "🎲"
EmojiDart string = "🎯"
EmojiBasketball string = "🏀"
EmojiBasketball string = "🏀" // 1-5
EmojiDart string = "🎯" // 1-6
EmojiGameDie string = "🎲" // 1-6
EmojiSlotMachine string = "🎰" // 1-64
EmojiSoccer string = "⚽" // 1-5
)
const (
// FromAnonymous is a User ID for messages from anonymous group administrators.
FromAnonymous int = 1087968824 // @GroupAnonymousBot
// FromForwarder is a User ID for messages automatically forwarded to the discussion group.
FromForwarder int = 777000
)

View File

@ -1,7 +1,8 @@
package telegram
type (
// Game represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers.
// Game represents a game. Use BotFather to create and edit games, their short names will act as unique
// identifiers.
Game struct {
// Title of the game
Title string `json:"title"`
@ -9,7 +10,9 @@ type (
// Description of the game
Description string `json:"description"`
// Brief description of the game or high scores included in the game message. Can be automatically edited to include current high scores for the game when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters.
// Brief description of the game or high scores included in the game message. Can be automatically
// edited to include current high scores for the game when the bot calls setGameScore, or manually
// edited using editMessageText. 0-4096 characters.
Text string `json:"text,omitempty"`
// Photo that will be displayed in the game message in chats.
@ -42,7 +45,8 @@ type (
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
// Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
// Short name of the game, serves as the unique identifier for the game. Set up your games via
// BotFather.
GameShortName string `json:"game_short_name"`
// Sends the message silently. Users will receive a notification with no sound.
@ -51,7 +55,11 @@ type (
// If the message is a reply, ID of the original message.
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
// A JSON-serialized object for an inline keyboard. If empty, one Play game_title button will be shown. If not empty, the first button must launch the game.
// Pass True, if the message should be sent even if the specified replied-to message is not found
AllowSendingWithoutReply bool `json:"allow_sending_without_reply,omitempty"`
// A JSON-serialized object for an inline keyboard. If empty, one Play game_title button will be
// shown. If not empty, the first button must launch the game.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
@ -66,7 +74,8 @@ type (
// Required if inline_message_id is not specified. Identifier of the sent message
MessageID int `json:"message_id,omitempty"`
// Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters
// Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or
// banning cheaters
Force bool `json:"force,omitempty"`
// Pass True, if the game message should not be automatically edited to include the current scoreboard
@ -124,7 +133,9 @@ func NewGameScore(userID int, score int) SetGameScore {
}
}
// SetGameScore set the score of the specified user in a game. On success, if the message was sent by the bot, returns the edited Message, otherwise returns True. Returns an error, if the new score is not greater than the user's current score in the chat and force is False.
// SetGameScore set the score of the specified user in a game. On success, if the message was sent by the bot, returns
// the edited Message, otherwise returns True. Returns an error, if the new score is not greater than the user's
// current score in the chat and force is False.
func (b Bot) SetGameScore(p SetGameScore) (*Message, error) {
src, err := b.Do(MethodSetGameScore, p)
if err != nil {
@ -139,7 +150,8 @@ func (b Bot) SetGameScore(p SetGameScore) (*Message, error) {
return result, nil
}
// GetGameHighScores get data for high score tables. Will return the score of the specified user and several of his neighbors in a game. On success, returns an Array of GameHighScore objects.
// GetGameHighScores get data for high score tables. Will return the score of the specified user and several of his
// neighbors in a game. On success, returns an Array of GameHighScore objects.
func (b Bot) GetGameHighScores(p GetGameHighScores) ([]*GameHighScore, error) {
src, err := b.Do(MethodGetGameHighScores, p)
if err != nil {

11
go.mod
View File

@ -3,15 +3,16 @@ module gitlab.com/toby3d/telegram
go 1.12
require (
github.com/Masterminds/semver v1.5.0
github.com/andybalholm/brotli v1.0.1 // indirect
github.com/fasthttp/router v1.3.2
github.com/json-iterator/go v1.1.9
github.com/json-iterator/go v1.1.10
github.com/kirillDanshin/dlog v0.0.0-20170728000807-97d876b12bf9
github.com/kirillDanshin/myutils v0.0.0-20160713214838-182269b1fbcc // indirect
github.com/klauspost/compress v1.11.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/stretchr/testify v1.3.0
github.com/valyala/fasthttp v1.16.0
golang.org/x/text v0.3.2
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
github.com/valyala/fasthttp v1.17.0
golang.org/x/text v0.3.4
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
)

27
go.sum
View File

@ -1,7 +1,7 @@
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4=
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc=
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@ -9,14 +9,16 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/fasthttp/router v1.3.2 h1:n9r5QNuJi5z5Sp2vp/0SrawogTjGfYFqTOyP/R8ehNI=
github.com/fasthttp/router v1.3.2/go.mod h1:athTSKMdel0Qhh3W4nB8qn+EPYuyj6YZMUo6ZcXWTgc=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/kirillDanshin/dlog v0.0.0-20170728000807-97d876b12bf9 h1:mA7k8E2Vrmyj5CW/D1XZBFmohVNi7jf757vibGwzRbo=
github.com/kirillDanshin/dlog v0.0.0-20170728000807-97d876b12bf9/go.mod h1:l8CN7iyX1k2xlsTYVTpCtwBPcxThf/jLWDGVcF6T/bM=
github.com/kirillDanshin/myutils v0.0.0-20160713214838-182269b1fbcc h1:OkOhOn3WBUmfATC1NsA3rBlgHGkjk0KGnR5akl/8uXc=
github.com/kirillDanshin/myutils v0.0.0-20160713214838-182269b1fbcc/go.mod h1:Bt95qRxLvpdmASW9s2tTxGdQ5ma4o4n8QFhCvzCew/M=
github.com/klauspost/compress v1.10.7 h1:7rix8v8GpI3ZBb0nSozFRgbtXKv+hOe+qfEpZqybrAg=
github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.11.2 h1:MiK62aErc3gIiVEtyzKfeOHgW7atJb5g/KNX5m3c2nQ=
github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@ -34,15 +36,24 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.16.0 h1:9zAqOYLl8Tuy3E5R6ckzGDJ1g8+pw15oQp2iL9Jl6gQ=
github.com/valyala/fasthttp v1.16.0/go.mod h1:YOKImeEosDdBPnxc0gy7INqi3m1zK6A+xl6TwOBhHCA=
github.com/valyala/fasthttp v1.17.0 h1:P8/koH4aSnJ4xbd0cUUFEGQs3jQqIxoDDyRQrUiAkqg=
github.com/valyala/fasthttp v1.17.0/go.mod h1:jjraHZVbKOXftJfsOYoAjaeygpj5hr8ermTRJNroD7A=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201016165138-7b1cca2348c0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

319
inline.go
View File

@ -1,7 +1,8 @@
package telegram
type (
// InlineQuery represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results.
// InlineQuery represents an incoming inline query. When the user sends an empty query, your bot could return
// some default or trending results.
InlineQuery struct {
// Unique identifier for this query
ID string `json:"id"`
@ -60,7 +61,9 @@ type (
ThumbHeight int `json:"thumb_height,omitempty"`
}
// InlineQueryResultPhoto represents a link to a photo. By default, this photo will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.
// InlineQueryResultPhoto represents a link to a photo. By default, this photo will be sent by the user with
// optional caption. Alternatively, you can use input_message_content to send a message with the specified
// content instead of the photo.
InlineQueryResultPhoto struct {
// Type of the result, must be photo
Type string `json:"type"`
@ -74,6 +77,12 @@ type (
// URL of the thumbnail for the photo
ThumbURL string `json:"thumb_url"`
// Width of the photo
PhotoWidth int `json:"photo_width,omitempty"`
// Height of the photo
PhotoHeight int `json:"photo_height,omitempty"`
// Title for the result
Title string `json:"title,omitempty"`
@ -83,14 +92,12 @@ type (
// Caption of the photo to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline
// URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Width of the photo
PhotoWidth int `json:"photo_width,omitempty"`
// Height of the photo
PhotoHeight int `json:"photo_height,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
@ -99,7 +106,9 @@ type (
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultGif represents a link to an animated GIF file. By default, this animated GIF file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
// InlineQueryResultGif represents a link to an animated GIF file. By default, this animated GIF file will be
// sent by the user with optional caption. Alternatively, you can use input_message_content to send a message
// with the specified content instead of the animation.
InlineQueryResultGif struct {
// Type of the result, must be gif
Type string `json:"type"`
@ -110,6 +119,15 @@ type (
// A valid URL for the GIF file. File size must not exceed 1MB
GifURL string `json:"gif_url"`
// Width of the GIF
GifWidth int `json:"gif_width,omitempty"`
// Height of the GIF
GifHeight int `json:"gif_height,omitempty"`
// Duration of the GIF
GifDuration int `json:"gif_duration,omitempty"`
// URL of the static thumbnail for the result (jpeg or gif)
ThumbURL string `json:"thumb_url"`
@ -123,17 +141,12 @@ type (
// Caption of the GIF file to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline
// URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Width of the GIF
GifWidth int `json:"gif_width,omitempty"`
// Height of the GIF
GifHeight int `json:"gif_height,omitempty"`
// Duration of the GIF
GifDuration int `json:"gif_duration,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
@ -142,7 +155,9 @@ type (
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultMpeg4Gif represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default, this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
// InlineQueryResultMpeg4Gif represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By
// default, this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can
// use input_message_content to send a message with the specified content instead of the animation.
InlineQueryResultMpeg4Gif struct {
// Type of the result, must be mpeg4_gif
Type string `json:"type"`
@ -153,6 +168,15 @@ type (
// A valid URL for the MP4 file. File size must not exceed 1MB
Mpeg4URL string `json:"mpeg4_url"`
// Video width
Mpeg4Width int `json:"mpeg4_width,omitempty"`
// Video height
Mpeg4Height int `json:"mpeg4_height,omitempty"`
// Video duration
Mpeg4Duration int `json:"mpeg4_duration,omitempty"`
// URL of the static thumbnail (jpeg or gif) for the result
ThumbURL string `json:"thumb_url"`
@ -166,18 +190,12 @@ type (
// Caption of the MPEG-4 file to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Video width
Mpeg4Width int `json:"mpeg4_width,omitempty"`
// Video height
Mpeg4Height int `json:"mpeg4_height,omitempty"`
// Video duration
Mpeg4Duration int `json:"mpeg4_duration,omitempty"`
// Mode for parsing entities in the caption. See formatting options for more details.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
@ -185,9 +203,12 @@ type (
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultVideo represents a link to a page containing an embedded video player or a video file. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video.
// InlineQueryResultVideo represents a link to a page containing an embedded video player or a video file.
// By default, this video file will be sent by the user with an optional caption. Alternatively, you can use
// input_message_content to send a message with the specified content instead of the video.
//
// If an InlineQueryResultVideo message contains an embedded video (e.g., YouTube), you must replace its content using input_message_content.
// If an InlineQueryResultVideo message contains an embedded video (e.g., YouTube), you must replace its
// content using input_message_content.
InlineQueryResultVideo struct {
// Type of the result, must be video
Type string `json:"type"`
@ -210,11 +231,12 @@ type (
// Caption of the video to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline
// URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Short description of the result
Description string `json:"description,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Video width
VideoWidth int `json:"video_width,omitempty"`
@ -225,14 +247,20 @@ type (
// Video duration in seconds
VideoDuration int `json:"video_duration,omitempty"`
// Short description of the result
Description string `json:"description,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the video. This field is required if InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video).
// Content of the message to be sent instead of the video. This field is required if
// InlineQueryResultVideo is used to send an HTML-page as a result (e.g., a YouTube video).
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultAudio represents a link to an mp3 audio file. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio.
// InlineQueryResultAudio represents a link to an mp3 audio file. By default, this audio file will be sent by
// the user. Alternatively, you can use input_message_content to send a message with the specified content
// instead of the audio.
InlineQueryResultAudio struct {
// Type of the result, must be audio
Type string `json:"type"`
@ -249,9 +277,13 @@ type (
// Caption, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline
// URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Performer
Performer string `json:"performer,omitempty"`
@ -265,7 +297,9 @@ type (
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultVoice represents a link to a voice recording in an .ogg container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message.
// InlineQueryResultVoice represents a link to a voice recording in an .ogg container encoded with OPUS.
// By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content
// to send a message with the specified content instead of the the voice message.
InlineQueryResultVoice struct {
// Type of the result, must be voice
Type string `json:"type"`
@ -282,9 +316,13 @@ type (
// Caption, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline
// URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Recording duration in seconds
VoiceDuration int `json:"voice_duration,omitempty"`
@ -295,7 +333,9 @@ type (
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultDocument represents a link to a file. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only .PDF and .ZIP files can be sent using this method.
// InlineQueryResultDocument represents a link to a file. By default, this file will be sent by the user with
// an optional caption. Alternatively, you can use input_message_content to send a message with the specified
// content instead of the file. Currently, only .PDF and .ZIP files can be sent using this method.
InlineQueryResultDocument struct {
// Type of the result, must be document
Type string `json:"type"`
@ -309,9 +349,13 @@ type (
// Caption of the document to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline
// URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// A valid URL for the file
DocumentURL string `json:"document_url"`
@ -337,7 +381,9 @@ type (
ThumbHeight int `json:"thumb_height,omitempty"`
}
// InlineQueryResultLocation represents a location on a map. By default, the location will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the location.
// InlineQueryResultLocation represents a location on a map. By default, the location will be sent by the
// user. Alternatively, you can use input_message_content to send a message with the specified content instead
// of the location.
InlineQueryResultLocation struct {
// Type of the result, must be location
Type string `json:"type"`
@ -345,24 +391,38 @@ type (
// Unique identifier for this result, 1-64 Bytes
ID string `json:"id"`
// Location title
Title string `json:"title"`
// Url of the thumbnail for the result
ThumbURL string `json:"thumb_url,omitempty"`
// Location latitude in degrees
Latitude float32 `json:"latitude"`
// Location longitude in degrees
Longitude float32 `json:"longitude"`
// Location title
Title string `json:"title"`
// The radius of uncertainty for the location, measured in meters; 0-1500
HorizontalAccuracy float32 `json:"horizontal_accuracy,omitempty"`
// Period in seconds for which the location can be updated, should be between 60 and 86400.
LivePeriod int `json:"live_period,omitempty"`
// For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360
// if specified.
Heading int `json:"heading,omitempty"`
// For live locations, a maximum distance for proximity alerts about approaching another chat member,
// in meters. Must be between 1 and 100000 if specified.
ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the location
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
// Url of the thumbnail for the result
ThumbURL string `json:"thumb_url,omitempty"`
// Thumbnail width
ThumbWidth int `json:"thumb_width,omitempty"`
@ -370,7 +430,8 @@ type (
ThumbHeight int `json:"thumb_height,omitempty"`
}
// InlineQueryResultVenue represents a venue. By default, the venue will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the venue.
// InlineQueryResultVenue represents a venue. By default, the venue will be sent by the user. Alternatively,
// you can use input_message_content to send a message with the specified content instead of the venue.
InlineQueryResultVenue struct {
// Type of the result, must be venue
Type string `json:"type"`
@ -378,6 +439,12 @@ type (
// Unique identifier for this result, 1-64 Bytes
ID string `json:"id"`
// Latitude of the venue location in degrees
Latitude float32 `json:"latitude"`
// Longitude of the venue location in degrees
Longitude float32 `json:"longitude"`
// Title of the venue
Title string `json:"title"`
@ -387,17 +454,15 @@ type (
// Foursquare identifier of the venue if known
FoursquareID string `json:"foursquare_id,omitempty"`
// Foursquare type of the venue, if known. (For example, "arts_entertainment/default", "arts_entertainment/aquarium" or "food/icecream".)
// Foursquare type of the venue, if known. (For example, "arts_entertainment/default",
// "arts_entertainment/aquarium" or "food/icecream".)
FoursquareType string `json:"foursquare_type,omitempty"`
// Url of the thumbnail for the result
ThumbURL string `json:"thumb_url,omitempty"`
// Google Places identifier of the venue
GooglePlaceID string `json:"google_place_id,omitempty"`
// Latitude of the venue location in degrees
Latitude float32 `json:"latitude"`
// Longitude of the venue location in degrees
Longitude float32 `json:"longitude"`
// Google Places type of the venue.
GooglePlaceType string `json:"google_place_type,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
@ -405,6 +470,9 @@ type (
// Content of the message to be sent instead of the venue
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
// Url of the thumbnail for the result
ThumbURL string `json:"thumb_url,omitempty"`
// Thumbnail width
ThumbWidth int `json:"thumb_width,omitempty"`
@ -412,7 +480,9 @@ type (
ThumbHeight int `json:"thumb_height,omitempty"`
}
// InlineQueryResultContact represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the contact.
// InlineQueryResultContact represents a contact with a phone number. By default, this contact will be sent by
// the user. Alternatively, you can use input_message_content to send a message with the specified content
// instead of the contact.
InlineQueryResultContact struct {
// Type of the result, must be contact
Type string `json:"type"`
@ -463,7 +533,9 @@ type (
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// InlineQueryResultCachedPhoto represents a link to a photo stored on the Telegram servers. By default, this photo will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.
// InlineQueryResultCachedPhoto represents a link to a photo stored on the Telegram servers. By default, this
// photo will be sent by the user with an optional caption. Alternatively, you can use input_message_content
// to send a message with the specified content instead of the photo.
InlineQueryResultCachedPhoto struct {
// Type of the result, must be photo
Type string `json:"type"`
@ -483,9 +555,13 @@ type (
// Caption of the photo to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline
// URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
@ -493,7 +569,9 @@ type (
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedGif represents a link to an animated GIF file stored on the Telegram servers. By default, this animated GIF file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with specified content instead of the animation.
// InlineQueryResultCachedGif represents a link to an animated GIF file stored on the Telegram servers.
// By default, this animated GIF file will be sent by the user with an optional caption. Alternatively, you
// can use input_message_content to send a message with specified content instead of the animation.
InlineQueryResultCachedGif struct {
// Type of the result, must be gif
Type string `json:"type"`
@ -510,9 +588,13 @@ type (
// Caption of the GIF file to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline
// URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
@ -520,7 +602,10 @@ type (
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedMpeg4Gif represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers. By default, this animated MPEG-4 file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.
// InlineQueryResultCachedMpeg4Gif represents a link to a video animation (H.264/MPEG-4 AVC video without
// sound) stored on the Telegram servers. By default, this animated MPEG-4 file will be sent by the user with
// an optional caption. Alternatively, you can use input_message_content to send a message with the specified
// content instead of the animation.
InlineQueryResultCachedMpeg4Gif struct {
// Type of the result, must be mpeg4_gif
Type string `json:"type"`
@ -537,9 +622,13 @@ type (
// Caption of the MPEG-4 file to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline
// URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
@ -547,7 +636,9 @@ type (
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedSticker represents a link to a sticker stored on the Telegram servers. By default, this sticker will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the sticker.
// InlineQueryResultCachedSticker represents a link to a sticker stored on the Telegram servers. By default,
// this sticker will be sent by the user. Alternatively, you can use input_message_content to send a message
// with the specified content instead of the sticker.
InlineQueryResultCachedSticker struct {
// Type of the result, must be sticker
Type string `json:"type"`
@ -565,7 +656,9 @@ type (
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedDocument represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file.
// InlineQueryResultCachedDocument represents a link to a file stored on the Telegram servers. By default,
// this file will be sent by the user with an optional caption. Alternatively, you can use
// input_message_content to send a message with the specified content instead of the file.
InlineQueryResultCachedDocument struct {
// Type of the result, must be document
Type string `json:"type"`
@ -585,9 +678,13 @@ type (
// Caption of the document to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline
// URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
@ -595,7 +692,9 @@ type (
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedVideo represents a link to a video file stored on the Telegram servers. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video.
// InlineQueryResultCachedVideo represents a link to a video file stored on the Telegram servers. By default,
// this video file will be sent by the user with an optional caption. Alternatively, you can use
// input_message_content to send a message with the specified content instead of the video.
InlineQueryResultCachedVideo struct {
// Type of the result, must be video
Type string `json:"type"`
@ -615,9 +714,13 @@ type (
// Caption of the video to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline
// URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
@ -625,7 +728,9 @@ type (
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedVoice represents a link to a voice message stored on the Telegram servers. By default, this voice message will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the voice message.
// InlineQueryResultCachedVoice represents a link to a voice message stored on the Telegram servers. By
// default, this voice message will be sent by the user. Alternatively, you can use input_message_content to
// send a message with the specified content instead of the voice message.
InlineQueryResultCachedVoice struct {
// Type of the result, must be voice
Type string `json:"type"`
@ -642,9 +747,13 @@ type (
// Caption, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline
// URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
@ -652,7 +761,9 @@ type (
InputMessageContent InputMessageContent `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedAudio represents a link to an mp3 audio file stored on the Telegram servers. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio.
// InlineQueryResultCachedAudio represents a link to an mp3 audio file stored on the Telegram servers. By
// default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send
// a message with the specified content instead of the audio.
InlineQueryResultCachedAudio struct {
// Type of the result, must be audio
Type string `json:"type"`
@ -666,9 +777,13 @@ type (
// Caption, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline
// URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
@ -681,19 +796,25 @@ type (
isInputMessageContent()
}
// InputTextMessageContent represents the content of a text message to be sent as the result of an inline query.
// InputTextMessageContent represents the content of a text message to be sent as the result of an inline
// query.
InputTextMessageContent struct {
// Text of the message to be sent, 1-4096 characters
MessageText string `json:"message_text"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline
// URLs in your bot's message.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Disables link previews for links in the sent message
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
}
// InputLocationMessageContent represents the content of a location message to be sent as the result of an inline query.
// InputLocationMessageContent represents the content of a location message to be sent as the result of an
// inline query.
InputLocationMessageContent struct {
// Latitude of the location in degrees
Latitude float32 `json:"latitude"`
@ -701,11 +822,23 @@ type (
// Longitude of the location in degrees
Longitude float32 `json:"longitude"`
// The radius of uncertainty for the location, measured in meters; 0-1500
HorizontalAccuracy float32 `json:"horizontal_accuracy,omitempty"`
// Period in seconds for which the location can be updated, should be between 60 and 86400.
LivePeriod int `json:"live_period,omitempty"`
// For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360
// if specified.
Heading int `json:"heading,omitempty"`
// For live locations, a maximum distance for proximity alerts about approaching another chat member,
// in meters. Must be between 1 and 100000 if specified.
ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
}
// InputVenueMessageContent represents the content of a venue message to be sent as the result of an inline query.
// InputVenueMessageContent represents the content of a venue message to be sent as the result of an inline
// query.
InputVenueMessageContent struct {
// Latitude of the location in degrees
Latitude float32 `json:"latitude"`
@ -722,11 +855,19 @@ type (
// Foursquare identifier of the venue, if known
FoursquareID string `json:"foursquare_id,omitempty"`
// Foursquare type of the venue, if known. (For example, "arts_entertainment/default", "arts_entertainment/aquarium" or "food/icecream".)
// Foursquare type of the venue, if known. (For example, "arts_entertainment/default",
// "arts_entertainment/aquarium" or "food/icecream".)
FoursquareType string `json:"foursquare_type,omitempty"`
// Google Places identifier of the venue
GooglePlaceId string `json:"google_place_id,omitempty"`
// Google Places type of the venue.
GooglePlaceType string `json:"google_place_type,omitempty"`
}
// InputContactMessageContent represents the content of a contact message to be sent as the result of an inline query.
// InputContactMessageContent represents the content of a contact message to be sent as the result of an
// inline query.
InputContactMessageContent struct {
// Contact's phone number
PhoneNumber string `json:"phone_number"`
@ -741,12 +882,14 @@ type (
VCard string `json:"vcard,omitempty"`
}
// ChosenInlineResult represents a result of an inline query that was chosen by the user and sent to their chat partner.
// ChosenInlineResult represents a result of an inline query that was chosen by the user and sent to their
// chat partner.
ChosenInlineResult struct {
// The unique identifier for the result that was chosen
ResultID string `json:"result_id"`
// Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. Will be also received in callback queries and can be used to edit the message.
// Identifier of the sent inline message. Available only if there is an inline keyboard attached to
// the message. Will be also received in callback queries and can be used to edit the message.
InlineMessageID string `json:"inline_message_id,omitempty"`
// The query that was used to obtain the result
@ -764,22 +907,28 @@ type (
// Unique identifier for the answered query
InlineQueryID string `json:"inline_query_id"`
// Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you dont support pagination. Offset length cant exceed 64 bytes.
// Pass the offset that a client should send in the next query with the same text to receive more
// results. Pass an empty string if there are no more results or if you dont support pagination.
// Offset length cant exceed 64 bytes.
NextOffset string `json:"next_offset,omitempty"`
// If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
// If passed, clients will display a button with specified text that switches the user to a private
// chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
SwitchPrivateMessageText string `json:"switch_pm_text,omitempty"`
// Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.
// Deep-linking parameter for the /start message sent to the bot when user presses the switch button.
// 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.
SwitchPrivateMessageParameter string `json:"switch_pm_parameter,omitempty"`
// A JSON-serialized array of results for the inline query
Results []InlineQueryResult `json:"results"`
// The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
// The maximum amount of time in seconds that the result of the inline query may be cached on the
// server. Defaults to 300.
CacheTime int `json:"cache_time,omitempty"`
// Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
// Pass True, if results may be cached on the server side only for the user that sent the query. By
// default, results may be returned to any user who sends the same query
IsPersonal bool `json:"is_personal,omitempty"`
}

File diff suppressed because it is too large Load Diff

View File

@ -202,6 +202,9 @@ type (
// Sends the message silently. Users will receive a notification with no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// Pass True, if the message should be sent even if the specified replied-to message is not found
AllowSendingWithoutReply bool `json:"allow_sending_without_reply,omitempty"`
// A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}

View File

@ -77,8 +77,7 @@ type (
// SendStickerParameters represents data for SetSticker method.
SendSticker struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
ChatID ChatID `json:"chat_id"`
// Sticker to send
Sticker *InputFile `json:"sticker"`
@ -89,6 +88,9 @@ type (
// If the message is a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
// Pass True, if the message should be sent even if the specified replied-to message is not found
AllowSendingWithoutReply bool `json:"allow_sending_without_reply,omitempty"`
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"`
}
@ -189,7 +191,7 @@ type (
}
)
func NewSticker(chatID int64, sticker *InputFile) SendSticker {
func NewSticker(chatID ChatID, sticker *InputFile) SendSticker {
return SendSticker{
ChatID: chatID,
Sticker: sticker,

186
types.go
View File

@ -4,6 +4,7 @@ import (
"encoding/json"
"os"
"path/filepath"
"strconv"
"strings"
"time"
@ -12,6 +13,12 @@ import (
)
type (
// ChatID is a unique identifier for the target chat or username of the target channel
ChatID struct {
ID int64 `json:"-"`
Username string `json:"-"` // @channelUsername
}
// Response represents a response from the Telegram API with the result stored raw. If ok equals true, the request was successful, and the result of the query can be found in the result field. In case of an unsuccessful request, ok equals false, and the error is explained in the error field.
Response struct {
Description string `json:"description,omitempty"`
@ -104,6 +111,11 @@ type (
// Sender, empty for messages sent to channels
From *User `json:"from,omitempty"`
// Sender of the message, sent on behalf of a chat. The channel itself for channel messages. The
// supergroup itself for messages from anonymous group administrators. The linked channel for messages
// automatically forwarded to the discussion group
SenderChat *Chat `json:"sender_chat,omitempty"`
// Date the message was sent in Unix time
Date int64 `json:"date"`
@ -149,8 +161,9 @@ type (
// For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text
Entities []*MessageEntity `json:"entities,omitempty"`
// For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Message is an animation, information about the animation. For backward compatibility, when this
// field is set, the document field will also be set
Animation *Animation `json:"animation,omitempty"`
// Message is an audio file, information about the file
Audio *Audio `json:"audio,omitempty"`
@ -158,12 +171,6 @@ type (
// Message is a general file, information about the file
Document *Document `json:"document,omitempty"`
// Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set
Animation *Animation `json:"animation,omitempty"`
// Message is a game, information about the game.
Game *Game `json:"game,omitempty"`
// Message is a photo, available sizes of the photo
Photo Photo `json:"photo,omitempty"`
@ -173,29 +180,36 @@ type (
// Message is a video, information about the video
Video *Video `json:"video,omitempty"`
// Message is a voice message, information about the file
Voice *Voice `json:"voice,omitempty"`
// Message is a video note, information about the video message
VideoNote *VideoNote `json:"video_note,omitempty"`
// Message is a voice message, information about the file
Voice *Voice `json:"voice,omitempty"`
// Caption for the document, photo or video, 0-200 characters
Caption string `json:"caption,omitempty"`
// For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear
// in the caption
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Message is a shared contact, information about the contact
Contact *Contact `json:"contact,omitempty"`
// Message is a shared location, information about the location
Location *Location `json:"location,omitempty"`
// Message is a dice with random value from 1 to 6
Dice *Dice `json:"dice,omitempty"`
// Message is a venue, information about the venue
Venue *Venue `json:"venue,omitempty"`
// Message is a game, information about the game.
Game *Game `json:"game,omitempty"`
// Message is a native poll, information about the poll
Poll *Poll `json:"poll,omitempty"`
// Message is a dice with random value from 1 to 6
Dice *Dice `json:"dice,omitempty"`
// Message is a venue, information about the venue
Venue *Venue `json:"venue,omitempty"`
// Message is a shared location, information about the location
Location *Location `json:"location,omitempty"`
// New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
NewChatMembers []*User `json:"new_chat_members,omitempty"`
@ -242,10 +256,20 @@ type (
// Telegram Passport data
PassportData *PassportData `json:"passport_data,omitempty"`
// Service message. A user in the chat triggered another user's proximity alert while sharing Live
// Location.
ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered,omitempty"`
// Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// MessageID represents a unique message identifier.
MessageID struct {
// Unique message identifier
MessageID int `json:"message_id"`
}
// MessageEntity represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
MessageEntity struct {
// Type of the entity. Can be mention (@username), hashtag, bot_command, url, email, bold (bold text), italic (italic text), code (monowidth string), pre (monowidth block), text_link (for clickable text URLs), text_mention (for users without usernames)
@ -302,6 +326,9 @@ type (
// Title of the audio as defined by sender or by audio tags
Title string `json:"title,omitempty"`
// Original filename as defined by sender
FileName string `json:"file_name,omitempty"`
// MIME type of the file as defined by sender
MimeType string `json:"mime_type,omitempty"`
@ -353,6 +380,9 @@ type (
// Video thumbnail
Thumb *PhotoSize `json:"thumb,omitempty"`
// Original filename as defined by sender
FileName string `json:"file_name,omitempty"`
// Mime type of a file as defined by sender
MimeType string `json:"mime_type,omitempty"`
@ -454,6 +484,20 @@ type (
// Latitude as defined by sender
Latitude float32 `json:"latitude"`
// The radius of uncertainty for the location, measured in meters; 0-1500
HorizontalAccuracy float32 `json:"horizontal_accuracy,omitempty"`
// Time relative to the message sending date, during which the location can be updated, in seconds.
// For active live locations only.
LivePeriod int `json:"live_period,omitempty"` // TODO(toby3d): change to time.Duration?
// The direction in which user is moving, in degrees; 1-360. For active live locations only.
Heading int `json:"heading,omitempty"`
// Maximum distance for proximity alerts about approaching another chat member, in meters. For sent
// live locations only.
ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
}
// Venue represents a venue.
@ -472,11 +516,17 @@ type (
// Foursquare type of the venue. (For example, "arts_entertainment/default", "arts_entertainment/aquarium" or "food/icecream".)
FoursquareType string `json:"foursquare_type,omitempty"`
// Google Places identifier of the venue
GooglePlaceID string `json:"google_place_id,omitempty"`
// Google Places type of the venue.
GooglePlaceType string `json:"google_place_type,omitempty"`
}
// This object contains information about one answer option in a poll.
PollOption struct {
// Option text, 1-100 characters
// Option text, 1-300 characters
Text string `json:"text"`
// Number of users that voted for this option
@ -539,16 +589,29 @@ type (
CloseDate int64 `json:"close_date,omitempty"`
}
// Dice represents a dice with random value from 1 to 6 for currently supported base emoji. (Yes, we're aware
// of the “proper” singular of die. But it's awkward, and we decided to help it change. One dice at a time!)
// Dice represents an animated emoji that displays a random value.
Dice struct {
// Emoji on which the dice throw animation is based
Emoji string `json:"emoji"`
// Value of the dice, 1-6
// Value of the dice, 1-6 for “🎲” and “🎯” base emoji, 1-5 for “🏀” and “⚽” base emoji, 1-64 for
// “🎰” base emoji
Value int `json:"value"`
}
// ProximityAlertTriggered represents the content of a service message, sent whenever a user in the chat
// triggers a proximity alert set by another user.
ProximityAlertTriggered struct {
// User that triggered the alert
Traveler *User `json:"traveler"`
// User that set the alert
Watcher *User `json:"watcher"`
// The distance between the users
Distance int `json:"distance"`
}
// UserProfilePhotos represent a user's profile pictures.
UserProfilePhotos struct {
// Total number of profile pictures the target user has
@ -746,8 +809,8 @@ type (
// Owner and administrators only. Custom title for this user
CustomTitle string `json:"custom_title,omitempty"`
// Restictred and kicked only. Date when restrictions will be lifted for this user, unix time
UntilDate int64 `json:"until_date,omitempty"`
// Owner and administrators only. True, if the user's presence in the chat is hidden
IsAnonymous bool `json:"is_anonymous,omitempty"`
// Administrators only. True, if the bot is allowed to edit administrator privileges of that user
CanBeEdited bool `json:"can_be_edited,omitempty"`
@ -771,7 +834,11 @@ type (
// Restricted only. True, if the user is a member of the chat at the moment of the request
IsMember bool `json:"is_member,omitempty"`
// Actions that a non-administrator user is allowed to take in a chat.
ChatPermissions
// Restictred and kicked only. Date when restrictions will be lifted for this user, unix time
UntilDate int64 `json:"until_date,omitempty"`
}
// ChatPermissions describes actions that a non-administrator user is allowed to take in a chat.
@ -801,6 +868,15 @@ type (
CanPinMessages bool `json:"can_pin_messages,omitempty"`
}
// ChatLocation represents a location to which a chat is connected.
ChatLocation struct {
// The location to which the supergroup is connected. Can't be a live location.
Location Location `json:"location"`
// Location address; 1-64 characters, as defined by the chat owner
Address string `json:"address"`
}
// BotCommand represents a bot command.
BotCommand struct {
// Text of the command, 1-32 characters. Can contain only lowercase English letters, digits and
@ -843,6 +919,9 @@ type (
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
}
// InputMediaVideo represents a video to be sent.
@ -853,12 +932,23 @@ type (
// File to send. 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 "attach://<file_attach_name>" to upload a new one using multipart/form-data under <file_attach_name> name.
Media *InputFile `json:"media"`
// Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported
// server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's
// width and height should not exceed 320. Ignored if the file is not uploaded using
// multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can
// pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under
// <file_attach_name>.
Thumb InputFile `json:"thumb,omitempty"`
// Caption of the video to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Video width
Width int `json:"width,omitempty"`
@ -890,6 +980,9 @@ type (
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Animation width
Width int `json:"width,omitempty"`
@ -917,6 +1010,9 @@ type (
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// Duration of the audio in seconds
Duration int `json:"duration,omitempty"`
@ -943,6 +1039,13 @@ type (
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// 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,omitempty"`
}
// InputFile represents the contents of a file to be uploaded. Must be poste using multipart/form-data in the usual way that files are uploaded via the browser.
@ -984,6 +1087,12 @@ func (u User) HasLastName() bool { return u.LastName != "" }
// HaveUsername checks what the current user has a username.
func (u User) HasUsername() bool { return u.Username != "" }
// IsAnonymous checks what the current user is a anonymous group admin.
func (u User) IsAnonymous() bool { return u.ID == FromAnonymous }
// IsChannel checks what the current user is a channel, which message is automatically forwarded to a discussion group.
func (u User) IsForwarder() bool { return u.ID == FromForwarder }
// IsPrivate checks that the current chat is a private chat with single user.
func (c Chat) IsPrivate() bool { return strings.EqualFold(c.Type, ChatPrivate) }
@ -1459,8 +1568,12 @@ func (m *InputMediaAnimation) GetMedia() *InputFile { return m.Media }
func (m *InputMediaAudio) GetMedia() *InputFile { return m.Media }
func (InputMediaAudio) isAlbumMedia() {}
func (m *InputMediaDocument) GetMedia() *InputFile { return m.Media }
func (InputMediaDocument) isAlbumMedia() {}
func (m *InputMediaPhoto) GetMedia() *InputFile { return m.Media }
func (InputMediaPhoto) isAlbumMedia() {}
@ -1475,6 +1588,7 @@ func (f InputFile) IsURI() bool { return f.URI != nil }
func (f InputFile) IsAttachment() bool { return f.Attachment != nil }
// MarshalJSON marshals InputFile into single JSON value.
func (f InputFile) MarshalJSON() ([]byte, error) {
switch {
case f.IsFileID():
@ -1499,4 +1613,28 @@ func (f InputFile) MarshalJSON() ([]byte, error) {
}
// CloseTime parse CloseDate and returns time.Time.
func (p Poll) CloseTime() time.Time { return time.Unix(p.CloseDate, 0) }
func (p Poll) CloseTime() time.Time {
return time.Unix(p.CloseDate, 0)
}
// MarshalJSON marshals ChatID into single JSON value.
func (c ChatID) MarshalJSON() ([]byte, error) {
switch {
case c.ID != 0:
return strconv.AppendInt(nil, c.ID, 10), nil
case c.Username != "":
return []byte(c.Username), nil
default:
return nil, nil
}
}
func (c ChatID) String() string {
if c.ID != 0 {
return strconv.FormatInt(c.ID, 10)
}
return c.Username
}
// TODO(toby3d): create method for checking what message from AnonymousGroupBot or this is a auto channel repost

View File

@ -4,6 +4,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strconv"
"testing"
"time"
@ -2144,3 +2145,34 @@ func TestPollCloseTime(t *testing.T) {
assert.Equal(t, now, p.CloseTime())
}
func TestChatIDMarshalJSON(t *testing.T) {
for _, tc := range []struct {
name string
input ChatID
expResult []byte
}{{
name: "chat id",
input: ChatID{ID: 123456},
expResult: strconv.AppendInt(nil, 123456, 10),
}, {
name: "channel username",
input: ChatID{Username: "@toby3dMe"},
expResult: []byte("@toby3dMe"),
}, {
name: "prefer id",
input: ChatID{ID: 123456, Username: "@toby3dMe"},
expResult: strconv.AppendInt(nil, 123456, 10),
}, {
name: "empty",
input: ChatID{},
expResult: nil,
}} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
result, err := tc.input.MarshalJSON()
assert.NoError(t, err)
assert.Equal(t, tc.expResult, result)
})
}
}

View File

@ -1,6 +1,7 @@
package telegram
import (
"net"
"strconv"
"strings"
"time"
@ -14,7 +15,7 @@ type (
// At most one of the optional parameters can be present in any given update.
Update struct {
// The updates unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if youre using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order.
UpdateID int `json:"update_id"`
ID int `json:"update_id"`
// New incoming message of any kind — text, photo, sticker, etc.
Message *Message `json:"message,omitempty"`
@ -56,15 +57,19 @@ type (
// Webhook URL, may be empty if webhook is not set up
URL string `json:"url"`
// Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook
LastErrorMessage string `json:"last_error_message,omitempty"`
// True, if a custom certificate was provided for webhook certificate checks
HasCustomCertificate bool `json:"has_custom_certificate"`
// Number of updates awaiting delivery
PendingUpdateCount int `json:"pending_update_count"`
// Currently used webhook IP address
IpAddress net.IP `json:"ip_address,omitempty"`
// Error message in human-readable format for the most recent error that happened when trying to
// deliver an update via webhook
LastErrorMessage string `json:"last_error_message,omitempty"`
// Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery
MaxConnections int `json:"max_connections,omitempty"`
@ -100,6 +105,10 @@ type (
// Upload your public key certificate so that the root certificate in use can be checked. See our self-signed guide for details.
Certificate InputFile `json:"certificate,omitempty"`
// The fixed IP address which will be used to send webhook requests instead of the IP address resolved
// through DNS
IpAddress net.IP `json:"ip_address,omitempty"`
// Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bots server, and higher values to increase your bots throughput.
MaxConnections int `json:"max_connections,omitempty"`
@ -107,6 +116,14 @@ type (
//
// Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time.
AllowedUpdates []string `json:"allowed_updates,omitempty"`
// Pass True to drop all pending updates
DropPendingUpdates bool `json:"drop_pending_updates,omitempty"`
}
DeleteWebhook struct {
// Pass True to drop all pending updates
DropPendingUpdates bool `json:"drop_pending_updates,omitempty"`
}
// UpdatesChannel represents channel for incoming updates.
@ -134,9 +151,11 @@ func (b Bot) GetUpdates(p *GetUpdates) ([]*Update, error) {
func (b Bot) SetWebhook(p SetWebhook) (ok bool, err error) {
if p.Certificate.IsAttachment() {
_, err := b.Upload(MethodSetWebhook, map[string]string{
"allowed_updates": strings.Join(p.AllowedUpdates, ","),
"max_connections": strconv.Itoa(p.MaxConnections),
"url": p.URL,
"url": p.URL,
"ip_address": p.IpAddress.String(),
"max_connections": strconv.Itoa(p.MaxConnections),
"allowed_updates": strings.Join(p.AllowedUpdates, ","),
"drop_pending_updates": strconv.FormatBool(p.DropPendingUpdates),
}, &p.Certificate)
return err == nil, err
@ -155,8 +174,8 @@ func (b Bot) SetWebhook(p SetWebhook) (ok bool, err error) {
}
// DeleteWebhook remove webhook integration if you decide to switch back to getUpdates. Returns True on success. Requires no parameters.
func (b Bot) DeleteWebhook() (ok bool, err error) {
src, err := b.Do(MethodDeleteWebhook, nil)
func (b Bot) DeleteWebhook(p DeleteWebhook) (ok bool, err error) {
src, err := b.Do(MethodDeleteWebhook, p)
if err != nil {
return ok, err
}

View File

@ -3,8 +3,7 @@ package telegram
type (
// EditMessageTextParameters represents data for EditMessageText method.
EditMessageText struct {
// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
ChatID int64 `json:"chat_id,omitempty"`
ChatID ChatID `json:"chat_id,omitempty"`
// Required if inline_message_id is not specified. Identifier of the sent message
MessageID int `json:"message_id,omitempty"`
@ -18,6 +17,9 @@ type (
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
Entities []*MessageEntity `json:"entities,omitempty"`
// Disables link previews for links in this message
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
@ -27,8 +29,7 @@ type (
// EditMessageCaptionParameters represents data for EditMessageCaption method.
EditMessageCaption struct {
// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
ChatID int64 `json:"chat_id,omitempty"`
ChatID ChatID `json:"chat_id,omitempty"`
// Required if inline_message_id is not specified. Identifier of the sent message
MessageID int `json:"message_id,omitempty"`
@ -42,14 +43,16 @@ type (
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// List of special entities that appear in the caption, which can be specified instead of parse_mode
CaptionEntities []*MessageEntity `json:"caption_entities,omitempty"`
// A JSON-serialized object for an inline keyboard.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// EditMessageMediaParameters represents data for EditMessageMedia method.
EditMessageMedia struct {
// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
ChatID int64 `json:"chat_id,omitempty"`
ChatID ChatID `json:"chat_id,omitempty"`
// Required if inline_message_id is not specified. Identifier of the sent message
MessageID int `json:"message_id,omitempty"`
@ -66,8 +69,7 @@ type (
// EditMessageReplyMarkupParameters represents data for EditMessageReplyMarkup method.
EditMessageReplyMarkup struct {
// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
ChatID int64 `json:"chat_id,omitempty"`
ChatID ChatID `json:"chat_id,omitempty"`
// Required if inline_message_id is not specified. Identifier of the sent message
MessageID int `json:"message_id,omitempty"`
@ -80,8 +82,7 @@ type (
}
StopPoll struct {
// Unique identifier for the target chat. A native poll can't be sent to a private chat.
ChatID int64 `json:"chat_id"`
ChatID ChatID `json:"chat_id"`
// Identifier of the original message with the poll
MessageID int `json:"message_id"`
@ -92,8 +93,7 @@ type (
// DeleteMessageParameters represents data for DeleteMessage method.
DeleteMessage struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
ChatID ChatID `json:"chat_id"`
// Identifier of the message to delete
MessageID int `json:"message_id"`
@ -105,7 +105,7 @@ func NewEditText(text string) EditMessageText {
}
// EditMessageText edit text and game messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
func (b Bot) EditMessageText(p *EditMessageText) (*Message, error) {
func (b Bot) EditMessageText(p EditMessageText) (*Message, error) {
src, err := b.Do(MethodEditMessageText, p)
if err != nil {
return nil, err
@ -120,7 +120,7 @@ func (b Bot) EditMessageText(p *EditMessageText) (*Message, error) {
}
// EditMessageCaption edit captions of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
func (b Bot) EditMessageCaption(p *EditMessageCaption) (*Message, error) {
func (b Bot) EditMessageCaption(p EditMessageCaption) (*Message, error) {
src, err := b.Do(MethodEditMessageCaption, p)
if err != nil {
return nil, err
@ -135,7 +135,9 @@ func (b Bot) EditMessageCaption(p *EditMessageCaption) (*Message, error) {
}
func NewEditMedia(media InputMedia) EditMessageMedia {
return EditMessageMedia{Media: media}
return EditMessageMedia{
Media: media,
}
}
// EditMessageMedia edit audio, document, photo, or video messages. If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded. Use previously uploaded file via its file_id or specify a URL. On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.
@ -168,8 +170,11 @@ func (b Bot) EditMessageReplyMarkup(p EditMessageReplyMarkup) (*Message, error)
return result, nil
}
func NewStopPoll(chatID int64, messageID int) StopPoll {
return StopPoll{ChatID: chatID, MessageID: messageID}
func NewStopPoll(chatID ChatID, messageID int) StopPoll {
return StopPoll{
ChatID: chatID,
MessageID: messageID,
}
}
// StopPoll stop a poll which was sent by the bot. On success, the stopped Poll with the final results is returned.
@ -197,8 +202,8 @@ func (b Bot) StopPoll(p StopPoll) (*Poll, error) {
// - 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 (b Bot) DeleteMessage(cid int64, mid int) (ok bool, err error) {
src, err := b.Do(MethodDeleteMessage, DeleteMessage{ChatID: cid, MessageID: mid})
func (b Bot) DeleteMessage(p DeleteMessage) (ok bool, err error) {
src, err := b.Do(MethodDeleteMessage, p)
if err != nil {
return ok, err
}