From aab898e7c0cdb21626ac1e5830977e9ee78762cc Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Tue, 9 Mar 2021 19:15:28 +0500 Subject: [PATCH] :alien: Updated code to v5.1 --- const.go | 14 ++-- games.go | 12 +-- go.mod | 7 +- go.sum | 29 ++++--- methods.go | 196 +++++++++++++++++++++++++++++++++---------- passport.go | 6 +- payments.go | 2 +- stickers.go | 18 ++-- types.go | 98 ++++++++++++++++++++-- updates.go | 12 ++- updating_messages.go | 14 ++-- 11 files changed, 308 insertions(+), 100 deletions(-) diff --git a/const.go b/const.go index 819eed8..6e78f96 100644 --- a/const.go +++ b/const.go @@ -1,7 +1,7 @@ package telegram // Version represents current version of Telegram API supported by this package -const Version = "5.0.0" +const Version string = "5.1.0" // Action represents available and supported status actions of bot const ( @@ -63,12 +63,14 @@ const ( MethodAnswerShippingQuery string = "answerShippingQuery" MethodClose string = "close" MethodCopyMessage string = "copyMessage" + MethodCreateChatInviteLink string = "createChatInviteLink" MethodCreateNewStickerSet string = "createNewStickerSet" MethodDeleteChatPhoto string = "deleteChatPhoto" MethodDeleteChatStickerSet string = "deleteChatStickerSet" MethodDeleteMessage string = "deleteMessage" MethodDeleteStickerFromSet string = "deleteStickerFromSet" MethodDeleteWebhook string = "deleteWebhook" + MethodEditChatInviteLink string = "editChatInviteLink" MethodEditMessageCaption string = "editMessageCaption" MethodEditMessageLiveLocation string = "editMessageLiveLocation" MethodEditMessageMedia string = "editMessageMedia" @@ -94,6 +96,7 @@ const ( MethodPinChatMessage string = "pinChatMessage" MethodPromoteChatMember string = "promoteChatMember" MethodRestrictChatMember string = "restrictChatMember" + MethodRevokeChatInviteLink string = "revokeChatInviteLink" MethodSendAnimation string = "sendAnimation" MethodSendAudio string = "sendAudio" MethodSendChatAction string = "sendChatAction" @@ -219,8 +222,8 @@ const ( // Default represents a default values for some helpers const ( - DefaultAudioSeparator = " – " - DefaultAudioTitle = "[untitled]" + DefaultAudioSeparator string = " – " + DefaultAudioTitle string = "[untitled]" ) // Poll represents a poll types @@ -232,6 +235,7 @@ const ( // Emoji represents emoji supported by SendDice method const ( EmojiBasketball string = "🏀" // 1-5 + EmojiBowling string = "🎳" // 1-6 EmojiDart string = "🎯" // 1-6 EmojiGameDie string = "🎲" // 1-6 EmojiSlotMachine string = "🎰" // 1-64 @@ -240,7 +244,7 @@ const ( const ( // FromAnonymous is a User ID for messages from anonymous group administrators. - FromAnonymous int = 1087968824 // @GroupAnonymousBot + FromAnonymous int64 = 1087968824 // @GroupAnonymousBot // FromForwarder is a User ID for messages automatically forwarded to the discussion group. - FromForwarder int = 777000 + FromForwarder int64 = 777000 ) diff --git a/games.go b/games.go index 3c6b3c7..421ebe6 100644 --- a/games.go +++ b/games.go @@ -53,7 +53,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message. - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -66,13 +66,13 @@ type ( // SetGameScoreParameters represents data for SetGameScore method. SetGameScore struct { // User identifier - UserID int `json:"user_id"` + UserID int64 `json:"user_id"` // New score, must be non-negative Score int `json:"score"` // Required if inline_message_id is not specified. Identifier of the sent message - MessageID int `json:"message_id,omitempty"` + MessageID int64 `json:"message_id,omitempty"` // Pass True, if the high score is allowed to decrease. This can be useful when fixing mistakes or // banning cheaters @@ -91,10 +91,10 @@ type ( // GetGameHighScoresParameters represents data for GetGameHighScores method. GetGameHighScores struct { // Target user id - UserID int `json:"user_id"` + UserID int64 `json:"user_id"` // Required if inline_message_id is not specified. Identifier of the sent message - MessageID int `json:"message_id,omitempty"` + MessageID int64 `json:"message_id,omitempty"` // Required if inline_message_id is not specified. Unique identifier for the target chat ChatID int64 `json:"chat_id,omitempty"` @@ -126,7 +126,7 @@ func (b Bot) SendGame(p SendGame) (*Message, error) { return result, nil } -func NewGameScore(userID int, score int) SetGameScore { +func NewGameScore(userID int64, score int) SetGameScore { return SetGameScore{ UserID: userID, Score: score, diff --git a/go.mod b/go.mod index b15102b..1b445d7 100644 --- a/go.mod +++ b/go.mod @@ -3,16 +3,15 @@ module gitlab.com/toby3d/telegram/v5 go 1.12 require ( - github.com/andybalholm/brotli v1.0.1 // indirect github.com/fasthttp/router v1.3.2 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/klauspost/compress v1.11.12 // 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.17.0 - golang.org/x/text v0.3.4 + github.com/valyala/fasthttp v1.22.0 + golang.org/x/text v0.3.5 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 ) diff --git a/go.sum b/go.sum index b630dec..69c0e48 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ -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= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -15,10 +13,10 @@ github.com/kirillDanshin/dlog v0.0.0-20170728000807-97d876b12bf9 h1:mA7k8E2Vrmyj 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/klauspost/compress v1.11.8/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.11.12 h1:famVnQVu7QwryBN4jNseQdUKES71ZAOnB6UQQJPZvqk= +github.com/klauspost/compress v1.11.12/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,26 +32,27 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= 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/fasthttp v1.22.0 h1:OpwH5KDOJ9cS2bq8fD+KfT4IrksK0llvkHf4MZx42jQ= +github.com/valyala/fasthttp v1.22.0/go.mod h1:0mw2RjXGOzxf4NL2jni3gUQ7LfjjUSiG5sskOUUSEpU= 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/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= 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/net v0.0.0-20210226101413-39120d07d75e/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 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-20191026070338-33540a1f6037/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/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -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/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= +golang.org/x/text v0.3.5/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-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/methods.go b/methods.go index 3ed61d2..11e22cc 100644 --- a/methods.go +++ b/methods.go @@ -26,7 +26,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -46,7 +46,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // Message identifier in the chat specified in from_chat_id - MessageID int `json:"message_id"` + MessageID int64 `json:"message_id"` } // CopyMessage represents data for CopyMessage method. @@ -57,7 +57,7 @@ type ( FromChatID ChatID `json:"from_chat_id"` // Message identifier in the chat specified in from_chat_id - MessageID int `json:"message_id"` + MessageID int64 `json:"message_id"` // New caption for media, 0-1024 characters after entities parsing. If not specified, the original // caption is kept @@ -74,7 +74,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -104,7 +104,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -145,7 +145,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -185,7 +185,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -229,7 +229,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -270,7 +270,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -302,7 +302,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -331,7 +331,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -351,7 +351,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty" form:"disable_notification"` // If the messages are a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty" form:"reply_to_message_id"` + ReplyToMessageID int64 `json:"reply_to_message_id,omitempty" form:"reply_to_message_id"` // 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" form:"reply_to_message_id"` @@ -386,7 +386,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -401,7 +401,7 @@ type ( 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"` + MessageID int64 `json:"message_id,omitempty"` // Required if chat_id and message_id are not specified. Identifier of the inline message InlineMessageID string `json:"inline_message_id,omitempty"` @@ -431,7 +431,7 @@ type ( ChatID ChatID `json:"chat_id,omitempty"` // Required if inline_message_id is not specified. Identifier of the message with live location to stop - MessageID int `json:"message_id,omitempty"` + MessageID int64 `json:"message_id,omitempty"` // Required if chat_id and message_id are not specified. Identifier of the inline message InlineMessageID string `json:"inline_message_id,omitempty"` @@ -473,7 +473,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -502,7 +502,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -531,7 +531,7 @@ type ( AllowsMultipleAnswers bool `json:"allows_multiple_answers,omitempty"` // 0-based identifier of the correct answer option, required for polls in quiz mode - CorrectOptionID int `json:"correct_option_id,omitempty"` + CorrectOptionID int64 `json:"correct_option_id,omitempty"` // 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 @@ -556,7 +556,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -578,7 +578,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -598,7 +598,7 @@ type ( // GetUserProfilePhotos represents data for GetUserProfilePhotos method. GetUserProfilePhotos struct { // Unique identifier of the target user - UserID int `json:"user_id"` + UserID int64 `json:"user_id"` // Sequential number of the first photo to be returned. By default, all photos are returned. Offset int `json:"offset,omitempty"` @@ -618,10 +618,13 @@ type ( ChatID ChatID `json:"chat_id"` // Unique identifier of the target user - UserID int `json:"user_id"` + UserID int64 `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 UntilDate int64 `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,omitempty"` } // UnbanChatMember represents data for UnbanChatMember method. @@ -629,7 +632,7 @@ type ( ChatID ChatID `json:"chat_id"` // Unique identifier of the target user - UserID int `json:"user_id"` + UserID int64 `json:"user_id"` // Do nothing if the user is not banned OnlyIfBanned bool `json:"only_if_banned,omitempty"` @@ -640,7 +643,7 @@ type ( ChatID ChatID `json:"chat_id"` // Unique identifier of the target user - UserID int `json:"user_id"` + UserID int64 `json:"user_id"` // New user permissions Permissions *ChatPermissions `json:"permissions"` @@ -654,11 +657,16 @@ type ( ChatID ChatID `json:"chat_id"` // Unique identifier of the target user - UserID int `json:"user_id"` + UserID int64 `json:"user_id"` // Pass True, if the administrator's presence in the chat is hidden IsAnonymous bool `json:"is_anonymous,omitempty"` + // Pass True, if the administrator can access the chat event log, chat statistics, message statistics + // in channels, see channel members, see anonymous administrators in supergoups and ignore slow mode. + // Implied by any other administrator privilege + CanManageChat bool `json:"can_manage_chat,omitempty"` + // Pass True, if the administrator can change chat title, photo and other settings CanChangeInfo bool `json:"can_change_info,omitempty"` @@ -671,6 +679,9 @@ type ( // Pass True, if the administrator can delete messages of other users CanDeleteMessages bool `json:"can_delete_messages,omitempty"` + // Pass True, if the administrator can manage voice chats, supergroups only + CanManageVoiceChats bool `json:"can_manage_voice_chats,omitempty"` + // Pass True, if the administrator can invite new users to the chat CanInviteUsers bool `json:"can_invite_users,omitempty"` @@ -691,7 +702,7 @@ type ( ChatID ChatID `json:"chat_id"` // Unique identifier of the target user - UserID int `json:"user_id"` + UserID int64 `json:"user_id"` // New custom title for the administrator; 0-16 characters, emoji are not allowed CustomTitle string `json:"custom_title"` @@ -710,6 +721,41 @@ type ( ChatID ChatID `json:"chat_id"` } + // CreateChatInviteLink represents data for CreateChatInviteLink method. + CreateChatInviteLink struct { + ChatID ChatID `json:"chat_id"` + + // Point in time (Unix timestamp) when the link will expire + ExpireDate int64 `json:"expire_date,omitempty"` + + // Maximum number of users that can be members of the chat simultaneously after joining the chat via + // this invite link; 1-99999 + MemberLimit int `json:"member_limit,omitempty"` + } + + // EditChatInviteLink represents data for EditChatInviteLink method. + EditChatInviteLink struct { + ChatID ChatID `json:"chat_id"` + + // The invite link to edit + InviteLink string `json:"invite_link"` + + // Point in time (Unix timestamp) when the link will expire + ExpireDate int64 `json:"expire_date,omitempty"` + + // Maximum number of users that can be members of the chat simultaneously after joining the chat via + // this invite link; 1-99999 + MemberLimit int `json:"member_limit,omitempty"` + } + + // RevokeChatInviteLink represents data for RevokeChatInviteLink method. + RevokeChatInviteLink struct { + ChatID ChatID `json:"chat_id"` + + // The invite link to revoke + InviteLink string `json:"invite_link"` + } + // SetChatPhoto represents data for SetChatPhoto method. SetChatPhoto struct { ChatID ChatID `json:"chat_id"` @@ -744,7 +790,7 @@ type ( ChatID ChatID `json:"chat_id"` // Identifier of a message to pin - MessageID int `json:"message_id"` + MessageID int64 `json:"message_id"` // Pass true, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels. DisableNotification bool `json:"disable_notification"` @@ -756,7 +802,7 @@ type ( // Identifier of a message to unpin. If not specified, the most recent pinned message (by sending // date) will be unpinned. - MessageID int `json:"messge_id,omitempty"` + MessageID int64 `json:"messge_id,omitempty"` } // UnpinAllChatMessages represents data for UnpinAllChatMessages method. @@ -789,7 +835,7 @@ type ( ChatID ChatID `json:"chat_id"` // Unique identifier of the target user - UserID int `json:"user_id"` + UserID int64 `json:"user_id"` } // SetChatStickerSet represents data for SetChatStickerSet method. @@ -914,7 +960,7 @@ func (b Bot) SendMessage(p SendMessage) (*Message, error) { return result, nil } -func NewForward(fromChatID, toChatID ChatID, messageID int) ForwardMessage { +func NewForward(fromChatID, toChatID ChatID, messageID int64) ForwardMessage { return ForwardMessage{ FromChatID: fromChatID, ChatID: toChatID, @@ -968,7 +1014,7 @@ func (b Bot) SendPhoto(p SendPhoto) (*Message, error) { params["parse_mode"] = p.ParseMode params["allow_sending_without_reply"] = strconv.FormatBool(p.AllowSendingWithoutReply) params["disable_notification"] = strconv.FormatBool(p.DisableNotification) - params["reply_to_message_id"] = strconv.Itoa(p.ReplyToMessageID) + params["reply_to_message_id"] = strconv.FormatInt(p.ReplyToMessageID, 10) var err error if params["photo"], err = b.marshler.MarshalToString(p.Photo); err != nil { @@ -1016,7 +1062,7 @@ func (b Bot) SendAudio(p SendAudio) (*Message, error) { params["performer"] = p.Performer params["title"] = p.Title params["disable_notification"] = strconv.FormatBool(p.DisableNotification) - params["reply_to_message_id"] = strconv.Itoa(p.ReplyToMessageID) + params["reply_to_message_id"] = strconv.FormatInt(p.ReplyToMessageID, 10) var err error if params["audio"], err = b.marshler.MarshalToString(p.Audio); err != nil { @@ -1067,7 +1113,7 @@ func (b Bot) SendDocument(p SendDocument) (*Message, error) { params["caption"] = p.Caption params["parse_mode"] = p.ParseMode params["disable_notification"] = strconv.FormatBool(p.DisableNotification) - params["reply_to_message_id"] = strconv.Itoa(p.ReplyToMessageID) + params["reply_to_message_id"] = strconv.FormatInt(p.ReplyToMessageID, 10) var err error if params["document"], err = b.marshler.MarshalToString(p.Document); err != nil { @@ -1114,7 +1160,7 @@ func (b Bot) SendVideo(p SendVideo) (*Message, error) { params["parse_mode"] = p.ParseMode params["supports_streaming"] = strconv.FormatBool(p.SupportsStreaming) params["disable_notification"] = strconv.FormatBool(p.DisableNotification) - params["reply_to_message_id"] = strconv.Itoa(p.ReplyToMessageID) + params["reply_to_message_id"] = strconv.FormatInt(p.ReplyToMessageID, 10) var err error if params["video"], err = b.marshler.MarshalToString(p.Video); err != nil { @@ -1168,7 +1214,7 @@ func (b Bot) SendAnimation(p SendAnimation) (*Message, error) { params["caption"] = p.Caption params["parse_mode"] = p.ParseMode params["disable_notification"] = strconv.FormatBool(p.DisableNotification) - params["reply_to_message_id"] = strconv.Itoa(p.ReplyToMessageID) + params["reply_to_message_id"] = strconv.FormatInt(p.ReplyToMessageID, 10) var err error if params["animation"], err = b.marshler.MarshalToString(p.Animation); err != nil { @@ -1220,7 +1266,7 @@ func (b Bot) SendVoice(p SendVoice) (*Message, error) { params["caption"] = p.Caption params["parse_mode"] = p.ParseMode params["disable_notification"] = strconv.FormatBool(p.DisableNotification) - params["reply_to_message_id"] = strconv.Itoa(p.ReplyToMessageID) + params["reply_to_message_id"] = strconv.FormatInt(p.ReplyToMessageID, 10) var err error if params["voice"], err = b.marshler.MarshalToString(p.Voice); err != nil { @@ -1263,7 +1309,7 @@ func (b Bot) SendVideoNote(p SendVideoNote) (*Message, error) { params["duration"] = strconv.Itoa(p.Duration) params["length"] = strconv.Itoa(p.Length) params["disable_notification"] = strconv.FormatBool(p.DisableNotification) - params["reply_to_message_id"] = strconv.Itoa(p.ReplyToMessageID) + params["reply_to_message_id"] = strconv.FormatInt(p.ReplyToMessageID, 10) var err error if params["video_note"], err = b.marshler.MarshalToString(p.VideoNote); err != nil { @@ -1330,7 +1376,7 @@ func (b Bot) SendMediaGroup(p SendMediaGroup) ([]*Message, error) { params := make(map[string]string) params["chat_id"] = p.ChatID.String() params["disable_notification"] = strconv.FormatBool(p.DisableNotification) - params["reply_to_message_id"] = strconv.Itoa(p.ReplyToMessageID) + params["reply_to_message_id"] = strconv.FormatInt(p.ReplyToMessageID, 10) params["media"] = "[" + strings.Join(media, ",") + "]" src, err := b.Upload(MethodSendMediaGroup, params, files...) @@ -1547,7 +1593,7 @@ func (b Bot) GetFile(fid string) (*File, error) { return result, nil } -func NewKick(chatID ChatID, userID int) KickChatMember { +func NewKick(chatID ChatID, userID int64) KickChatMember { return KickChatMember{ ChatID: chatID, UserID: userID, @@ -1594,7 +1640,7 @@ func (b Bot) UnbanChatMember(p UnbanChatMember) (ok bool, err error) { return } -func NewRestrict(chatID ChatID, userID int, permissions ChatPermissions) RestrictChatMember { +func NewRestrict(chatID ChatID, userID int64, permissions ChatPermissions) RestrictChatMember { return RestrictChatMember{ ChatID: chatID, UserID: userID, @@ -1621,7 +1667,7 @@ func (b Bot) RestrictChatMember(p RestrictChatMember) (ok bool, err error) { return } -func NewPromote(chatID ChatID, userID int) PromoteChatMember { +func NewPromote(chatID ChatID, userID int64) PromoteChatMember { return PromoteChatMember{ ChatID: chatID, UserID: userID, @@ -1705,6 +1751,72 @@ func (b Bot) ExportChatInviteLink(p ExportChatInviteLink) (string, error) { return result, nil } +// CreateChatInviteLink create 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 admin rights. The link can be revoked using the method +// revokeChatInviteLink. Returns the new invite link as ChatInviteLink object. +func (b Bot) CreateChatInviteLink(p CreateChatInviteLink) (*ChatInviteLink, error) { + src, err := b.Do(MethodCreateChatInviteLink, p) + if err != nil { + return nil, err + } + + resp := new(Response) + if err = b.marshler.Unmarshal(src, resp); err != nil { + return nil, err + } + + result := new(ChatInviteLink) + if err = b.marshler.Unmarshal(resp.Result, result); err != nil { + return nil, err + } + + return result, nil +} + +// EditChatInviteLink method to edit 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 admin rights. Returns the edited invite link as a +// ChatInviteLink object. +func (b Bot) EditChatInviteLink(p EditChatInviteLink) (*ChatInviteLink, error) { + src, err := b.Do(MethodEditChatInviteLink, p) + if err != nil { + return nil, err + } + + resp := new(Response) + if err = b.marshler.Unmarshal(src, resp); err != nil { + return nil, err + } + + result := new(ChatInviteLink) + if err = b.marshler.Unmarshal(resp.Result, result); err != nil { + return nil, err + } + + return result, nil +} + +// RevokeChatInviteLink method to revoke an invite 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 admin rights. Returns the revoked invite link as ChatInviteLink object. +func (b Bot) RevokeChatInviteLink(p RevokeChatInviteLink) (*ChatInviteLink, error) { + src, err := b.Do(MethodRevokeChatInviteLink, p) + if err != nil { + return nil, err + } + + resp := new(Response) + if err = b.marshler.Unmarshal(src, resp); err != nil { + return nil, err + } + + result := new(ChatInviteLink) + if err = b.marshler.Unmarshal(resp.Result, result); err != nil { + return nil, err + } + + return result, nil +} + // SetChatPhoto set 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 admin rights. Returns True on success. func (b Bot) SetChatPhoto(cid int64, photo *InputFile) (ok bool, err error) { params := make(map[string]string) @@ -1793,7 +1905,7 @@ func (b Bot) SetChatDescription(p SetChatDescription) (ok bool, err error) { return } -func NewPin(chatID ChatID, messageID int) PinChatMessage { +func NewPin(chatID ChatID, messageID int64) PinChatMessage { return PinChatMessage{ ChatID: chatID, MessageID: messageID, diff --git a/passport.go b/passport.go index 43e8a09..61e7330 100644 --- a/passport.go +++ b/passport.go @@ -230,7 +230,7 @@ type ( SetPassportDataErrors struct { // User identifier - UserID int `json:"user_id"` + UserID int64 `json:"user_id"` // A JSON-serialized array describing the errors Errors []PassportElementError `json:"errors"` @@ -239,7 +239,7 @@ type ( // AuthParameters represent a Telegram Passport auth parameters for SDK. Auth struct { // Unique identifier for the b. You can get it from bot token. For example, for the bot token 1234567:4TT8bAc8GHUspu3ERYn-KGcvsvGB9u_n4ddy, the bot id is 1234567. - BotID int `json:"bot_id"` + BotID int64 `json:"bot_id"` // A JSON-serialized object describing the data you want to request Scope *PassportScope `json:"scope"` @@ -530,7 +530,7 @@ var ErrNotEqual = errors.New("credentials hash and credentials data hash is not // SetPassportDataErrors informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. // // Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues. -func (b Bot) SetPassportDataErrors(uid int, errors ...PassportElementError) (ok bool, err error) { +func (b Bot) SetPassportDataErrors(uid int64, errors ...PassportElementError) (ok bool, err error) { src, err := b.Do(MethodSetPassportDataErrors, SetPassportDataErrors{ UserID: uid, Errors: errors, }) diff --git a/payments.go b/payments.go index c87d715..00b8c64 100644 --- a/payments.go +++ b/payments.go @@ -182,7 +182,7 @@ type ( PhotoHeight int `json:"photo_height,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"` // Pass True, if you require the user's full name to complete the order NeedName bool `json:"need_name,omitempty"` diff --git a/stickers.go b/stickers.go index dfa27a1..6ce1f51 100644 --- a/stickers.go +++ b/stickers.go @@ -86,7 +86,7 @@ type ( DisableNotification bool `json:"disable_notification,omitempty"` // If the message is a reply, ID of the original message - ReplyToMessageID int `json:"reply_to_message_id,omitempty"` + ReplyToMessageID int64 `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"` @@ -103,7 +103,7 @@ type ( UploadStickerFile struct { // User identifier of sticker file owner - UserID int `json:"user_id"` + UserID int64 `json:"user_id"` // Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. PNGSticker *InputFile `json:"png_sticker"` @@ -111,7 +111,7 @@ type ( CreateNewStickerSet struct { // User identifier of created sticker set owner - UserID int `json:"user_id"` + UserID int64 `json:"user_id"` // Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_”. is case insensitive. 1-64 characters. Name string `json:"name"` @@ -138,7 +138,7 @@ type ( AddStickerToSet struct { // User identifier of sticker set owner - UserID int `json:"user_id"` + UserID int64 `json:"user_id"` // Sticker set name Name string `json:"name"` @@ -178,7 +178,7 @@ type ( Name string `json:"name"` // User identifier of the sticker set owner - UserID int `json:"user_id"` + UserID int64 `json:"user_id"` // A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height // exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; @@ -251,7 +251,7 @@ func (b Bot) UploadStickerFile(uid int, sticker *InputFile) (*File, error) { return result, nil } -func NewStickerSet(userID int, name, title string, pngSticker *InputFile, emojis ...string) CreateNewStickerSet { +func NewStickerSet(userID int64, name, title string, pngSticker *InputFile, emojis ...string) CreateNewStickerSet { return CreateNewStickerSet{ UserID: userID, Name: name, @@ -264,7 +264,7 @@ func NewStickerSet(userID int, name, title string, pngSticker *InputFile, emojis // CreateNewStickerSet create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success. func (b *Bot) CreateNewStickerSet(p CreateNewStickerSet) (ok bool, err error) { params := make(map[string]string) - params["user_id"] = strconv.Itoa(p.UserID) + params["user_id"] = strconv.FormatInt(p.UserID, 10) params["name"] = p.Name params["title"] = p.Title params["emojis"] = p.Emojis @@ -298,7 +298,7 @@ func (b *Bot) CreateNewStickerSet(p CreateNewStickerSet) (ok bool, err error) { // AddStickerToSet add a new sticker to a set created by the b. Returns True on success. func (b *Bot) AddStickerToSet(p AddStickerToSet) (ok bool, err error) { params := make(map[string]string) - params["user_id"] = strconv.Itoa(p.UserID) + params["user_id"] = strconv.FormatInt(p.UserID, 10) params["name"] = p.Name params["emojis"] = p.Emojis @@ -363,7 +363,7 @@ func (b *Bot) DeleteStickerFromSet(sticker string) (ok bool, err error) { func (b *Bot) SetStickerSetThumb(p SetStickerSetThumb) (ok bool, err error) { params := make(map[string]string) params["name"] = p.Name - params["user_id"] = strconv.Itoa(p.UserID) + params["user_id"] = strconv.FormatInt(p.UserID, 10) if params["thumb"], err = b.marshler.MarshalToString(p.Thumb); err != nil { return diff --git a/types.go b/types.go index f85d315..8f7b52c 100644 --- a/types.go +++ b/types.go @@ -31,7 +31,7 @@ type ( // User represents a Telegram user or bot. User struct { // Unique identifier for this user or bot - ID int `json:"id"` + ID int64 `json:"id"` // True, if this user is a bot IsBot bool `json:"is_bot"` @@ -106,7 +106,7 @@ type ( // Message represents a message. Message struct { // Unique message identifier inside this chat - ID int `json:"message_id"` + ID int64 `json:"message_id"` // Sender, empty for messages sent to channels From *User `json:"from,omitempty"` @@ -129,7 +129,7 @@ type ( ForwardFromChat *Chat `json:"forward_from_chat,omitempty"` // For messages forwarded from channels, identifier of the original message in the channel - ForwardFromMessageID int `json:"forward_from_message_id,omitempty"` + ForwardFromMessageID int64 `json:"forward_from_message_id,omitempty"` // For messages forwarded from channels, signature of the post author if present ForwardSignature string `json:"forward_signature,omitempty"` @@ -235,6 +235,9 @@ type ( // Service message: the channel has been created. This field can‘t be received in a message coming through updates, because bot can’t be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel. ChannelChatCreated bool `json:"channel_chat_created,omitempty"` + // Service message: auto-delete timer settings changed in the chat + MessageAutoDeleteTimerChanged *MessageAutoDeleteTimerChanged `json:"message_auto_delete_timer_changed,omitempty"` + // The group has been migrated to a supergroup with the specified identifier. MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"` @@ -260,6 +263,15 @@ type ( // Location. ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered,omitempty"` + // Service message: voice chat started + VoiceChatStarted *VoiceChatStarted `json:"voice_chat_started,omitempty"` + + // Service message: voice chat ended + VoiceChatEnded *VoiceChatEnded `json:"voice_chat_ended,omitempty"` + + // Service message: new participants invited to a voice chat + VoiceChatParticipantsInvited *VoiceChatParticipantsInvited `json:"voice_chat_participants_invited,omitempty"` + // Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` } @@ -267,7 +279,7 @@ type ( // MessageID represents a unique message identifier. MessageID struct { // Unique message identifier - MessageID int `json:"message_id"` + MessageID int64 `json:"message_id"` } // MessageEntity represents one special entity in a text message. For example, hashtags, usernames, URLs, etc. @@ -471,7 +483,7 @@ type ( LastName string `json:"last_name,omitempty"` // Contact's user identifier in Telegram - UserID int `json:"user_id,omitempty"` + UserID int64 `json:"user_id,omitempty"` // Additional data about the contact in the form of a vCard VCard string `json:"vcard,omitempty"` @@ -573,7 +585,7 @@ type ( AllowsMultipleAnswers bool `json:"allows_multiple_answers"` // 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot. - CorrectOptionID int `json:"correct_option_id,omitempty"` + CorrectOptionID int64 `json:"correct_option_id,omitempty"` // 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 @@ -612,6 +624,28 @@ type ( Distance int `json:"distance"` } + // MessageAutoDeleteTimerChanged represents a service message about a change in auto-delete timer settings. + MessageAutoDeleteTimerChanged struct { + // New auto-delete time for messages in the chat + MessageAutoDeleteTime int `json:"message_auto_delete_time"` + } + + // VoiceChatStarted represents a service message about a voice chat started in the chat. Currently holds no + // information. + VoiceChatStarted struct{} + + // VoiceChatEnded represents a service message about a voice chat ended in the chat. + VoiceChatEnded struct { + // Voice chat duration; in seconds + Duration int64 `json:"duration"` + } + + // VoiceChatParticipantsInvited represents a service message about new members invited to a voice chat. + VoiceChatParticipantsInvited struct { + // New members that were invited to the voice chat + Users []*User `json:"users,omitempty"` + } + // UserProfilePhotos represent a user's profile pictures. UserProfilePhotos struct { // Total number of profile pictures the target user has @@ -798,6 +832,29 @@ type ( BigFileUniqueID string `json:"big_file_unique_id"` } + // ChatInviteLink represents an invite link for a chat. + ChatInviteLink struct { + // The invite link. If the link was created by another chat administrator, then the second part of the + // link will be replaced with “…”. + InviteLink string `json:"invite_link"` + + // Creator of the link + Creator *User `json:"creator"` + + // True, if the link is primary + IsPrimary bool `json:"is_primary"` + + // True, if the link is revoked + IsRevoked bool `json:"is_revoked"` + + // Optional. Point in time (Unix timestamp) when the link will expire or has been expired + ExpireDate int64 `json:"expire_date,omitempty"` + + // Optional. Maximum number of users that can be members of the chat simultaneously after joining the + // chat via this invite link; 1-99999 + MemberLimit int `json:"member_limit,omitempty"` + } + // ChatMember contains information about one member of a chat. ChatMember struct { // Information about the user @@ -815,6 +872,11 @@ type ( // Administrators only. True, if the bot is allowed to edit administrator privileges of that user CanBeEdited bool `json:"can_be_edited,omitempty"` + // Administrators only. True, if the administrator can access the chat event log, chat statistics, + // message statistics in channels, see channel members, see anonymous administrators in supergoups and + // ignore slow mode. Implied by any other administrator privilege + CanManageChat bool `json:"can_manage_chat,omitempty"` + // Administrators only. True, if the administrator can post in the channel, channels only CanPostMessages bool `json:"can_post_messages,omitempty"` @@ -824,6 +886,9 @@ type ( // Administrators only. True, if the administrator can delete messages of other users CanDeleteMessages bool `json:"can_delete_messages,omitempty"` + // Administrators only. True, if the administrator can manage voice chats + CanManageVoiceChats bool `json:"can_manage_voice_chats,omitempty"` + // Administrators only. True, if the administrator can restrict, ban or // unban chat members CanRestrictMembers bool `json:"can_restrict_members,omitempty"` @@ -841,6 +906,27 @@ type ( UntilDate int64 `json:"until_date,omitempty"` } + // ChatMemberUpdated represents changes in the status of a chat member. + ChatMemberUpdated struct { + // Chat the user belongs to. + Chat *Chat `json:"chat"` + + // Performer of the action, which resulted in the change. + From *User `json:"from"` + + // Date the change was done in Unix time. + Date int64 `json:"date"` + + // Previous information about the chat member. + OldChatMember *ChatMember `json:"old_chat_member"` + + // New information about the chat member. + NewChatMember *ChatMember `json:"new_chat_member"` + + // Chat invite link, which was used by the user to join the chat; for joining by invite link events only. + InviteLink *ChatInviteLink `json:"invite_link,omitempty"` + } + // ChatPermissions describes actions that a non-administrator user is allowed to take in a chat. ChatPermissions struct { // True, if the user is allowed to send text messages, contacts, locations and venues diff --git a/updates.go b/updates.go index 1068358..2e33a7a 100644 --- a/updates.go +++ b/updates.go @@ -15,7 +15,7 @@ type ( // At most one of the optional parameters can be present in any given update. Update struct { // The update‘s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. - ID int `json:"update_id"` + ID int64 `json:"update_id"` // New incoming message of any kind — text, photo, sticker, etc. Message *Message `json:"message,omitempty"` @@ -50,6 +50,14 @@ type ( // A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were // sent by the bot itself. PollAnswer *PollAnswer `json:"poll_answer,omitempty"` + + // The bot's chat member status was updated in a chat. For private chats, this update is received only + // when the bot is blocked or unblocked by the user. + MyChatMember *ChatMemberUpdated `json:"my_chat_member,omitempty"` + + // A chat member's status was updated in a chat. The bot must be an administrator in the chat and must + // explicitly specify “chat_member” in the list of allowed_updates to receive these updates. + ChatMember *ChatMemberUpdated `json:"chat_member,omitempty"` } // WebhookInfo contains information about the current status of a webhook. @@ -83,7 +91,7 @@ type ( // GetUpdatesParameters represents data for GetUpdates method. GetUpdates struct { // Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten. - Offset int `json:"offset,omitempty"` + Offset int64 `json:"offset,omitempty"` // Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100. Limit int `json:"limit,omitempty"` diff --git a/updating_messages.go b/updating_messages.go index 8b99b86..f809826 100644 --- a/updating_messages.go +++ b/updating_messages.go @@ -6,7 +6,7 @@ type ( 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"` + MessageID int64 `json:"message_id,omitempty"` // Required if chat_id and message_id are not specified. Identifier of the inline message InlineMessageID string `json:"inline_message_id,omitempty"` @@ -32,7 +32,7 @@ type ( 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"` + MessageID int64 `json:"message_id,omitempty"` // Required if chat_id and message_id are not specified. Identifier of the inline message InlineMessageID string `json:"inline_message_id,omitempty"` @@ -55,7 +55,7 @@ type ( 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"` + MessageID int64 `json:"message_id,omitempty"` // Required if chat_id and message_id are not specified. Identifier of the inline message InlineMessageID string `json:"inline_message_id,omitempty"` @@ -72,7 +72,7 @@ type ( 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"` + MessageID int64 `json:"message_id,omitempty"` // Required if chat_id and message_id are not specified. Identifier of the inline message InlineMessageID string `json:"inline_message_id,omitempty"` @@ -85,7 +85,7 @@ type ( ChatID ChatID `json:"chat_id"` // Identifier of the original message with the poll - MessageID int `json:"message_id"` + MessageID int64 `json:"message_id"` // A JSON-serialized object for a new message inline keyboard. ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` @@ -96,7 +96,7 @@ type ( ChatID ChatID `json:"chat_id"` // Identifier of the message to delete - MessageID int `json:"message_id"` + MessageID int64 `json:"message_id"` } ) @@ -170,7 +170,7 @@ func (b Bot) EditMessageReplyMarkup(p EditMessageReplyMarkup) (*Message, error) return result, nil } -func NewStopPoll(chatID ChatID, messageID int) StopPoll { +func NewStopPoll(chatID ChatID, messageID int64) StopPoll { return StopPoll{ ChatID: chatID, MessageID: messageID,