diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..aed7258 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +botdoc/_testdata/*.html linguist-generated diff --git a/_oas/openapi.json b/_oas/openapi.json index 244ad5e..356930e 100644 --- a/_oas/openapi.json +++ b/_oas/openapi.json @@ -761,7 +761,7 @@ }, "responses": { "200": { - "$ref": "#/components/responses/Result" + "$ref": "#/components/responses/ResultFile" }, "default": { "$ref": "#/components/responses/Error" @@ -846,7 +846,7 @@ }, "responses": { "200": { - "$ref": "#/components/responses/Result" + "$ref": "#/components/responses/ResultStickerSet" }, "default": { "$ref": "#/components/responses/Error" @@ -2346,6 +2346,9 @@ }, "location": { "$ref": "#/components/schemas/ChatLocation" + }, + "all_members_are_administrators": { + "type": "boolean" } }, "required": [ @@ -5516,6 +5519,15 @@ }, "reply_markup": { "$ref": "#/components/schemas/InlineKeyboardMarkup" + }, + "new_chat_member": { + "$ref": "#/components/schemas/User" + }, + "new_chat_participant": { + "$ref": "#/components/schemas/User" + }, + "left_chat_participant": { + "$ref": "#/components/schemas/User" } }, "required": [ @@ -6610,6 +6622,21 @@ "ok" ] }, + "ResultStickerSet": { + "type": "object", + "properties": { + "result": { + "$ref": "#/components/schemas/StickerSet" + }, + "ok": { + "type": "boolean", + "default": true + } + }, + "required": [ + "ok" + ] + }, "ResultString": { "type": "object", "properties": { @@ -6685,6 +6712,22 @@ "ok" ] }, + "SendReplyMarkup": { + "oneOf": [ + { + "$ref": "#/components/schemas/InlineKeyboardMarkup" + }, + { + "$ref": "#/components/schemas/ReplyKeyboardMarkup" + }, + { + "$ref": "#/components/schemas/ReplyKeyboardRemove" + }, + { + "$ref": "#/components/schemas/ForceReply" + } + ] + }, "ShippingAddress": { "description": "This object represents a shipping address.", "type": "object", @@ -7553,21 +7596,7 @@ "type": "boolean" }, "reply_markup": { - "description": "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", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -8370,21 +8399,7 @@ "type": "boolean" }, "reply_markup": { - "description": "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", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -8450,21 +8465,7 @@ "type": "boolean" }, "reply_markup": { - "description": "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", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -8526,21 +8527,7 @@ "type": "boolean" }, "reply_markup": { - "description": "Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove keyboard or to force a reply from the user", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -8573,21 +8560,7 @@ "type": "boolean" }, "reply_markup": { - "description": "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", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -8642,21 +8615,7 @@ "type": "boolean" }, "reply_markup": { - "description": "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", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -8881,21 +8840,7 @@ "type": "boolean" }, "reply_markup": { - "description": "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", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -8999,21 +8944,7 @@ "type": "boolean" }, "reply_markup": { - "description": "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", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -9061,21 +8992,7 @@ "type": "boolean" }, "reply_markup": { - "description": "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", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -9160,21 +9077,7 @@ "type": "boolean" }, "reply_markup": { - "description": "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", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -9207,21 +9110,7 @@ "type": "boolean" }, "reply_markup": { - "description": "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", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -9281,21 +9170,7 @@ "type": "boolean" }, "reply_markup": { - "description": "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", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -9372,21 +9247,7 @@ "type": "boolean" }, "reply_markup": { - "description": "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", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -9432,21 +9293,7 @@ "type": "boolean" }, "reply_markup": { - "description": "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", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -9500,21 +9347,7 @@ "type": "boolean" }, "reply_markup": { - "description": "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", - "oneOf": [ - { - "$ref": "#/components/schemas/InlineKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardMarkup" - }, - { - "$ref": "#/components/schemas/ReplyKeyboardRemove" - }, - { - "$ref": "#/components/schemas/ForceReply" - } - ] + "$ref": "#/components/schemas/SendReplyMarkup" } }, "required": [ @@ -10094,6 +9927,16 @@ } } }, + "ResultStickerSet": { + "description": "Result of method invocation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ResultStickerSet" + } + } + } + }, "ResultString": { "description": "Result of method invocation", "content": { diff --git a/botdoc/botdoc.go b/botdoc/botdoc.go index 59c3e9b..6b8513a 100644 --- a/botdoc/botdoc.go +++ b/botdoc/botdoc.go @@ -288,8 +288,9 @@ func Extract(doc *goquery.Document) (a API) { }) const ( retPrefix = `on success, the` - retPrefix2 = `returns a` - retPrefix3 = `returns the` + retPrefix2 = `on success, a` + retPrefix3 = `returns a` + retPrefix4 = `returns the` retArrayPrefix = `an array of` retArrayPrefix2 = `returns array of` retSuffix = ` is returned` @@ -308,6 +309,7 @@ func Extract(doc *goquery.Document) (a API) { retPrefix, retPrefix2, retPrefix3, + retPrefix4, ) if prefix == retArrayPrefix || prefix == retArrayPrefix2 { // Do not cut prefix, if we do ParseType will be unable to detect an array clause. diff --git a/botdoc/oas.go b/botdoc/oas.go index 79a1116..dc23659 100644 --- a/botdoc/oas.go +++ b/botdoc/oas.go @@ -108,6 +108,8 @@ func (a API) typeOAS(f Field) *ogen.Schema { p.Ref = "#/components/schemas/ID" case "String or String": p.Type = "string" + case "InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply": + p.Ref = "#/components/schemas/SendReplyMarkup" default: for _, s := range t.Sum { p.OneOf = append(p.OneOf, a.typeOAS(Field{Type: s})) @@ -237,6 +239,14 @@ Schemas: c.Schemas["ResultInt"] = resultFor(&ogen.Schema{ Type: "integer", }) + c.Schemas["SendReplyMarkup"] = &ogen.Schema{ + OneOf: []*ogen.Schema{ + {Ref: "#/components/schemas/InlineKeyboardMarkup"}, + {Ref: "#/components/schemas/ReplyKeyboardMarkup"}, + {Ref: "#/components/schemas/ReplyKeyboardRemove"}, + {Ref: "#/components/schemas/ForceReply"}, + }, + } addResponse := func(name, ref, description string) { c.Responses[name] = &ogen.Response{ Description: description, @@ -459,6 +469,7 @@ Schemas: } p["/"+m.Name] = item } + addMissedProperties(c.Schemas) return &ogen.Spec{ OpenAPI: "3.0.3", Info: ogen.Info{ @@ -477,3 +488,33 @@ Schemas: Components: c, }, nil } + +func addMissedProperties(schemas map[string]*ogen.Schema) { + add := func(name string, props ...ogen.Property) { + schemas[name].Properties = append(schemas[name].Properties, props...) + } + + add("Chat", ogen.Property{ + Name: "all_members_are_administrators", + Schema: &ogen.Schema{ + Type: "boolean", + }, + }) + // Seems like legacy fields. + add("Message", ogen.Property{ + Name: "new_chat_member", + Schema: &ogen.Schema{ + Ref: "#/components/schemas/User", + }, + }, ogen.Property{ + Name: "new_chat_participant", + Schema: &ogen.Schema{ + Ref: "#/components/schemas/User", + }, + }, ogen.Property{ + Name: "left_chat_participant", + Schema: &ogen.Schema{ + Ref: "#/components/schemas/User", + }, + }) +} diff --git a/botdoc/opts.go b/botdoc/opts.go index f0f90d8..8f51ee7 100644 --- a/botdoc/opts.go +++ b/botdoc/opts.go @@ -14,6 +14,7 @@ var ( "BotCommand", "GameHighScore", "WebhookInfo", + "StickerSet", "UserProfilePhotos", "ChatMember", "ChatInviteLink", diff --git a/cmd/botapi/main.go b/cmd/botapi/main.go index 1524a0a..4ef31a8 100644 --- a/cmd/botapi/main.go +++ b/cmd/botapi/main.go @@ -123,7 +123,7 @@ func run(ctx context.Context) error { log.Info("New request") if err := p.Do(r.Context(), token, func(client *botapi.BotAPI) error { - r.URL.Path = method + r.URL.Path = botapi.CorrectMethod(method) oas.NewServer(client).ServeHTTP(w, r) return nil }); err != nil { diff --git a/go.mod b/go.mod index 74fbf60..790abe1 100644 --- a/go.mod +++ b/go.mod @@ -8,8 +8,8 @@ require ( github.com/go-faster/errors v0.5.0 github.com/go-faster/jx v0.25.0 github.com/google/uuid v1.3.0 - github.com/gotd/td v0.54.0-alpha.3 - github.com/ogen-go/ogen v0.0.0-20211211145630-e16dcf3319e7 + github.com/gotd/td v0.54.0-alpha.3.0.20211223161344-410f74c24790 + github.com/ogen-go/ogen v0.5.0 github.com/stretchr/testify v1.7.0 go.etcd.io/bbolt v1.3.6 go.opentelemetry.io/otel v1.3.0 diff --git a/go.sum b/go.sum index 91969c7..420f04d 100644 --- a/go.sum +++ b/go.sum @@ -69,8 +69,8 @@ github.com/gotd/ige v0.2.2 h1:XQ9dJZwBfDnOGSTxKXBGP4gMud3Qku2ekScRjDWWfEk= github.com/gotd/ige v0.2.2/go.mod h1:tuCRb+Y5Y3eNTo3ypIfNpQ4MFjrnONiL2jN2AKZXmb0= github.com/gotd/neo v0.1.4 h1:av+c/4R+3B/eAlr+Bz++q+/DOuGKz+sfwJXmPXRbU/s= github.com/gotd/neo v0.1.4/go.mod h1:9A2a4bn9zL6FADufBdt7tZt+WMhvZoc5gWXihOPoiBQ= -github.com/gotd/td v0.54.0-alpha.3 h1:FH1kKwzYXawdUZYDoLGlCPQG/feeBhGK4NvW2XN0Vqs= -github.com/gotd/td v0.54.0-alpha.3/go.mod h1:Ce9Z+p9SqI6W+N9mwIQ+IqHEdNIif5khUmydmWkDB44= +github.com/gotd/td v0.54.0-alpha.3.0.20211223161344-410f74c24790 h1:ezm4m/JqEHu69qOttyaj/G1QXq3bZJGUaT+CrjBFBh8= +github.com/gotd/td v0.54.0-alpha.3.0.20211223161344-410f74c24790/go.mod h1:Ce9Z+p9SqI6W+N9mwIQ+IqHEdNIif5khUmydmWkDB44= github.com/gotd/tl v0.4.0/go.mod h1:CMIcjPWFS4qxxJ+1Ce7U/ilbtPrkoVo/t8uhN5Y/D7c= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -104,8 +104,8 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/ogen-go/ogen v0.0.0-20211211145630-e16dcf3319e7 h1:mlNw+mPfGr6UDw7atlKAE9sGL1KkqWPe/ZgBQmvqCno= -github.com/ogen-go/ogen v0.0.0-20211211145630-e16dcf3319e7/go.mod h1:b30KYUTj30mV20YdJNI+jPc6f2SVFH+GpqiABuV5/Fc= +github.com/ogen-go/ogen v0.5.0 h1:VnXB+C6KmKOkgLtzzLLfSP/UaniByrOZ4obWgwpiG54= +github.com/ogen-go/ogen v0.5.0/go.mod h1:aYpDkiiI7LJ5ZIpRPWv7Z+mFq/4dMQugg4fbQEWQgXU= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -136,16 +136,12 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= -go.opentelemetry.io/otel v1.2.0/go.mod h1:aT17Fk0Z1Nor9e0uisf98LrntPGMnk4frBO9+dkf69I= go.opentelemetry.io/otel v1.3.0 h1:APxLf0eiBwLl+SOXiJJCVYzA1OOJNyAoV8C5RNRyy7Y= go.opentelemetry.io/otel v1.3.0/go.mod h1:PWIKzi6JCp7sM0k9yZ43VX+T345uNbAkDKwHVjb2PTs= -go.opentelemetry.io/otel/internal/metric v0.25.0/go.mod h1:Nhuw26QSX7d6n4duoqAFi5KOQR4AuzyMcl5eXOgwxtc= go.opentelemetry.io/otel/internal/metric v0.26.0 h1:dlrvawyd/A+X8Jp0EBT4wWEe4k5avYaXsXrBr4dbfnY= go.opentelemetry.io/otel/internal/metric v0.26.0/go.mod h1:CbBP6AxKynRs3QCbhklyLUtpfzbqCLiafV9oY2Zj1Jk= -go.opentelemetry.io/otel/metric v0.25.0/go.mod h1:E884FSpQfnJOMMUaq+05IWlJ4rjZpk2s/F1Ju+TEEm8= go.opentelemetry.io/otel/metric v0.26.0 h1:VaPYBTvA13h/FsiWfxa3yZnZEm15BhStD8JZQSA773M= go.opentelemetry.io/otel/metric v0.26.0/go.mod h1:c6YL0fhRo4YVoNs6GoByzUgBp36hBL523rECoZA5UWg= -go.opentelemetry.io/otel/trace v1.2.0/go.mod h1:N5FLswTubnxKxOJHM7XZC074qpeEdLy3CgAVsdMucK0= go.opentelemetry.io/otel/trace v1.3.0 h1:doy8Hzb1RJ+I3yFhtDmwNc7tIyw1tNMOIsyPzp1NOGY= go.opentelemetry.io/otel/trace v1.3.0/go.mod h1:c/VDhno8888bvQYmbYLqe41/Ldmr/KKunbvWM4/fEjk= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= diff --git a/internal/botapi/botapi_test.go b/internal/botapi/botapi_test.go index 446cf8e..40691af 100644 --- a/internal/botapi/botapi_test.go +++ b/internal/botapi/botapi_test.go @@ -2,6 +2,7 @@ package botapi import ( "testing" + "time" "go.uber.org/zap/zaptest" @@ -67,7 +68,7 @@ func testChat() *tg.Chat { ID: 10, Title: "I hate mondays", ParticipantsCount: 10, - Date: int(10), + Date: int(time.Now().Unix()), Version: 1, Photo: &tg.ChatPhotoEmpty{}, } @@ -75,6 +76,33 @@ func testChat() *tg.Chat { return u } +func testChannelID() int64 { + var id constant.TDLibPeerID + id.Channel(testChannel().ID) + return int64(id) +} + +func testChannel() *tg.Channel { + u := &tg.Channel{ + Megagroup: true, + Broadcast: false, + Noforwards: true, + ID: 11, + AccessHash: 0, + Title: "I hate mondays", + Username: "", + Photo: &tg.ChatPhotoEmpty{}, + Date: int(time.Now().Unix()), + RestrictionReason: nil, + AdminRights: tg.ChatAdminRights{}, + BannedRights: tg.ChatBannedRights{}, + DefaultBannedRights: tg.ChatBannedRights{}, + ParticipantsCount: 1, + } + u.SetFlags() + return u +} + func testCommands() []tg.BotCommand { return []tg.BotCommand{ { diff --git a/internal/botapi/chat.go b/internal/botapi/chat.go index 60fae29..3b3038e 100644 --- a/internal/botapi/chat.go +++ b/internal/botapi/chat.go @@ -5,17 +5,53 @@ import ( "github.com/go-faster/errors" + "github.com/gotd/td/telegram/peers" + "github.com/gotd/td/tg" + "github.com/gotd/botapi/internal/oas" ) +func convertToBotAPIChatPermissions(p tg.ChatBannedRights) oas.ChatPermissions { + return oas.ChatPermissions{ + CanSendMessages: oas.NewOptBool(p.SendMessages), + CanSendMediaMessages: oas.NewOptBool(p.SendMedia), + CanSendPolls: oas.NewOptBool(p.SendPolls), + CanSendOtherMessages: oas.NewOptBool(p.SendGames || p.SendStickers || p.SendInline), + CanAddWebPagePreviews: oas.NewOptBool(p.EmbedLinks), + CanChangeInfo: oas.NewOptBool(p.ChangeInfo), + CanInviteUsers: oas.NewOptBool(p.InviteUsers), + CanPinMessages: oas.NewOptBool(p.PinMessages), + } +} + +func (b *BotAPI) checkJoinRequest( + ctx context.Context, + chatID oas.ID, userID int64, + cb func(p peers.InviteLinks, ctx context.Context, user tg.InputUserClass) error, +) (oas.Result, error) { + p, err := b.resolveIDToChat(ctx, chatID) + if err != nil { + return oas.Result{}, errors.Wrap(err, "resolve chatID") + } + user, err := b.resolveUserID(ctx, userID) + if err != nil { + return oas.Result{}, errors.Wrap(err, "resolve userID") + } + + if err := cb(p.InviteLinks(), ctx, user.InputUser()); err != nil { + return oas.Result{}, err + } + return resultOK(true), nil +} + // ApproveChatJoinRequest implements oas.Handler. func (b *BotAPI) ApproveChatJoinRequest(ctx context.Context, req oas.ApproveChatJoinRequest) (oas.Result, error) { - return oas.Result{}, &NotImplementedError{} + return b.checkJoinRequest(ctx, req.ChatID, req.UserID, peers.InviteLinks.ApproveJoin) } // DeclineChatJoinRequest implements oas.Handler. func (b *BotAPI) DeclineChatJoinRequest(ctx context.Context, req oas.DeclineChatJoinRequest) (oas.Result, error) { - return oas.Result{}, &NotImplementedError{} + return b.checkJoinRequest(ctx, req.ChatID, req.UserID, peers.InviteLinks.DeclineJoin) } // DeleteChatPhoto implements oas.Handler. @@ -25,12 +61,105 @@ func (b *BotAPI) DeleteChatPhoto(ctx context.Context, req oas.DeleteChatPhoto) ( // DeleteChatStickerSet implements oas.Handler. func (b *BotAPI) DeleteChatStickerSet(ctx context.Context, req oas.DeleteChatStickerSet) (oas.Result, error) { - return oas.Result{}, &NotImplementedError{} + p, err := b.resolveIDToChat(ctx, req.ChatID) + if err != nil { + return oas.Result{}, errors.Wrap(err, "resolve chatID") + } + + ch, ok := p.(peers.Channel) + if !ok { + return oas.Result{}, &BadRequestError{Message: "Bad Request: method is available only for supergroups"} + } + + s, ok := ch.ToSupergroup() + if !ok { + return oas.Result{}, &BadRequestError{Message: "Bad Request: method is available only for supergroups"} + } + + if err := s.ResetStickerSet(ctx); err != nil { + return oas.Result{}, err + } + return resultOK(true), nil } // GetChat implements oas.Handler. func (b *BotAPI) GetChat(ctx context.Context, req oas.GetChat) (oas.ResultChat, error) { - return oas.ResultChat{}, &NotImplementedError{} + p, err := b.resolveID(ctx, req.ChatID) + if err != nil { + return oas.ResultChat{}, errors.Wrap(err, "resolve chatID") + } + + var ( + id = p.TDLibPeerID() + chat oas.Chat + ) + switch p := p.(type) { + case peers.User: + chat = fillBotAPIChatPrivate(p) + raw := p.Raw() + full, err := p.FullRaw(ctx) + if err != nil { + return oas.ResultChat{}, errors.Wrap(err, "get full") + } + chat.Photo = b.setUserPhoto(id, raw.AccessHash, raw.Photo) + chat.Bio = optString(full.GetAbout) + if full.PrivateForwardName != "" { + chat.HasPrivateForwards.SetTo(true) + } + case peers.Chat: + chat = fillBotAPIChatGroup(p) + full, err := p.FullRaw(ctx) + if err != nil { + return oas.ResultChat{}, errors.Wrap(err, "get full") + } + chat.Photo = b.setChatPhoto(id, 0, p.Raw().Photo) + chat.Description = oas.NewOptString(full.GetAbout()) + if invite, ok := full.GetExportedInvite(); ok { + chat.InviteLink.SetTo(invite.Link) + } + // TODO(tdakkota): resolve pinned. + if v, ok := p.DefaultBannedRights(); ok { + chat.Permissions.SetTo(convertToBotAPIChatPermissions(v)) + } + // TODO(tdakkota): set AllMembersAreAdministrators + case peers.Channel: + chat = fillBotAPIChatGroup(p) + raw := p.Raw() + full, err := p.FullRaw(ctx) + if err != nil { + return oas.ResultChat{}, errors.Wrap(err, "get full") + } + chat.Photo = b.setChatPhoto(id, raw.AccessHash, raw.Photo) + chat.Description = oas.NewOptString(full.GetAbout()) + if invite, ok := full.GetExportedInvite(); ok { + chat.InviteLink.SetTo(invite.Link) + } + // TODO(tdakkota): resolve pinned. + if v, ok := p.DefaultBannedRights(); ok { + chat.Permissions.SetTo(convertToBotAPIChatPermissions(v)) + } + if s, ok := full.GetSlowmodeSeconds(); ok { + chat.SlowModeDelay.SetTo(s) + } + if s, ok := full.GetStickerset(); ok { + chat.StickerSetName.SetTo(s.ShortName) + } + chat.LinkedChatID = optInt64(full.GetLinkedChatID) + if loc, ok := full.Location.(*tg.ChannelLocation); ok { + if p, ok := loc.GeoPoint.AsNotEmpty(); ok { + chat.Location.SetTo(oas.ChatLocation{ + Location: convertToBotAPILocation(p), + Address: loc.Address, + }) + } + } + // TODO(tdakkota): set AllMembersAreAdministrators + } + + return oas.ResultChat{ + Result: oas.NewOptChat(chat), + Ok: true, + }, nil } // SetChatAdministratorCustomTitle implements oas.Handler. @@ -40,7 +169,7 @@ func (b *BotAPI) SetChatAdministratorCustomTitle(ctx context.Context, req oas.Se // SetChatDescription implements oas.Handler. func (b *BotAPI) SetChatDescription(ctx context.Context, req oas.SetChatDescription) (oas.Result, error) { - p, err := b.resolveChatID(ctx, req.ChatID) + p, err := b.resolveIDToChat(ctx, req.ChatID) if err != nil { return oas.Result{}, errors.Wrap(err, "resolve chatID") } @@ -67,7 +196,7 @@ func (b *BotAPI) SetChatStickerSet(ctx context.Context, req oas.SetChatStickerSe // SetChatTitle implements oas.Handler. func (b *BotAPI) SetChatTitle(ctx context.Context, req oas.SetChatTitle) (oas.Result, error) { - p, err := b.resolveChatID(ctx, req.ChatID) + p, err := b.resolveIDToChat(ctx, req.ChatID) if err != nil { return oas.Result{}, errors.Wrap(err, "resolve chatID") } @@ -79,7 +208,7 @@ func (b *BotAPI) SetChatTitle(ctx context.Context, req oas.SetChatTitle) (oas.Re // LeaveChat implements oas.Handler. func (b *BotAPI) LeaveChat(ctx context.Context, req oas.LeaveChat) (oas.Result, error) { - p, err := b.resolveChatID(ctx, req.ChatID) + p, err := b.resolveIDToChat(ctx, req.ChatID) if err != nil { return oas.Result{}, errors.Wrap(err, "resolve chatID") } diff --git a/internal/botapi/chat_member.go b/internal/botapi/chat_member.go index d412806..6585f22 100644 --- a/internal/botapi/chat_member.go +++ b/internal/botapi/chat_member.go @@ -3,6 +3,8 @@ package botapi import ( "context" + "github.com/go-faster/errors" + "github.com/gotd/botapi/internal/oas" ) @@ -28,9 +30,9 @@ func (b *BotAPI) GetChatMember(ctx context.Context, req oas.GetChatMember) (oas. // GetChatMemberCount implements oas.Handler. func (b *BotAPI) GetChatMemberCount(ctx context.Context, req oas.GetChatMemberCount) (oas.ResultInt, error) { - ch, err := b.resolveChatID(ctx, req.ChatID) + ch, err := b.resolveIDToChat(ctx, req.ChatID) if err != nil { - return oas.ResultInt{}, err + return oas.ResultInt{}, errors.Wrap(err, "resolve chatID") } return oas.ResultInt{ Result: oas.NewOptInt(ch.ParticipantsCount()), diff --git a/internal/botapi/chat_test.go b/internal/botapi/chat_test.go index fb86c31..7f9b0d9 100644 --- a/internal/botapi/chat_test.go +++ b/internal/botapi/chat_test.go @@ -22,12 +22,68 @@ func testWithCache(t *testing.T, cb func(a *require.Assertions, mock *tgmock.Moc }, []tg.ChatClass{ testChat(), + testChannel(), }, )) cb(a, mock, api) } +func Test_convertToBotAPIChatPermissions(t *testing.T) { + tests := []struct { + name string + p tg.ChatBannedRights + want oas.ChatPermissions + }{ + { + name: "Zero", + want: oas.ChatPermissions{ + CanSendMessages: oas.NewOptBool(false), + CanSendMediaMessages: oas.NewOptBool(false), + CanSendPolls: oas.NewOptBool(false), + CanSendOtherMessages: oas.NewOptBool(false), + CanAddWebPagePreviews: oas.NewOptBool(false), + CanChangeInfo: oas.NewOptBool(false), + CanInviteUsers: oas.NewOptBool(false), + CanPinMessages: oas.NewOptBool(false), + }, + }, + { + name: "Full", + p: tg.ChatBannedRights{ + ViewMessages: true, + SendMessages: true, + SendMedia: true, + SendStickers: true, + SendGifs: true, + SendGames: true, + SendInline: true, + EmbedLinks: true, + SendPolls: true, + ChangeInfo: true, + InviteUsers: true, + PinMessages: true, + }, + want: oas.ChatPermissions{ + CanSendMessages: oas.NewOptBool(true), + CanSendMediaMessages: oas.NewOptBool(true), + CanSendPolls: oas.NewOptBool(true), + CanSendOtherMessages: oas.NewOptBool(true), + CanAddWebPagePreviews: oas.NewOptBool(true), + CanChangeInfo: oas.NewOptBool(true), + CanInviteUsers: oas.NewOptBool(true), + CanPinMessages: oas.NewOptBool(true), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.p.SetFlags() + require.Equal(t, tt.want, convertToBotAPIChatPermissions(tt.p)) + }) + } +} + func TestBotAPI_SetChatDescription(t *testing.T) { ctx := context.Background() testWithCache(t, func(a *require.Assertions, mock *tgmock.Mock, api *BotAPI) { @@ -53,11 +109,69 @@ func TestBotAPI_SetChatDescription(t *testing.T) { }) } +func TestBotAPI_ApproveChatJoinRequest(t *testing.T) { + ctx := context.Background() + testWithCache(t, func(a *require.Assertions, mock *tgmock.Mock, api *BotAPI) { + mock.ExpectCall(&tg.MessagesHideChatJoinRequestRequest{ + Approved: true, + Peer: &tg.InputPeerChat{ChatID: testChat().ID}, + UserID: &tg.InputUserSelf{}, + }).ThenResult(&tg.Updates{}) + _, err := api.ApproveChatJoinRequest(ctx, oas.ApproveChatJoinRequest{ + ChatID: oas.NewInt64ID(testChatID()), + UserID: testUser().ID, + }) + a.NoError(err) + }) +} + +func TestBotAPI_DeclineChatJoinRequest(t *testing.T) { + ctx := context.Background() + testWithCache(t, func(a *require.Assertions, mock *tgmock.Mock, api *BotAPI) { + mock.ExpectCall(&tg.MessagesHideChatJoinRequestRequest{ + Approved: false, + Peer: &tg.InputPeerChat{ChatID: testChat().ID}, + UserID: &tg.InputUserSelf{}, + }).ThenResult(&tg.Updates{}) + _, err := api.DeclineChatJoinRequest(ctx, oas.DeclineChatJoinRequest{ + ChatID: oas.NewInt64ID(testChatID()), + UserID: testUser().ID, + }) + a.NoError(err) + }) +} + +func TestBotAPI_DeleteChatStickerSet(t *testing.T) { + ctx := context.Background() + testWithCache(t, func(a *require.Assertions, mock *tgmock.Mock, api *BotAPI) { + _, err := api.DeleteChatStickerSet(ctx, oas.DeleteChatStickerSet{ + ChatID: oas.NewInt64ID(testChatID()), + }) + a.Error(err) + + mock.ExpectCall(&tg.ChannelsSetStickersRequest{ + Channel: &tg.InputChannel{ + ChannelID: testChannel().ID, + AccessHash: testChannel().AccessHash, + }, + Stickerset: &tg.InputStickerSetEmpty{}, + }).ThenTrue() + _, err = api.DeleteChatStickerSet(ctx, oas.DeleteChatStickerSet{ + ChatID: oas.NewInt64ID(testChannelID()), + }) + a.NoError(err) + }) +} + +func TestBotAPI_GetChat(t *testing.T) { + +} + func TestBotAPI_SetChatTitle(t *testing.T) { ctx := context.Background() testWithCache(t, func(a *require.Assertions, mock *tgmock.Mock, api *BotAPI) { mock.ExpectCall(&tg.MessagesEditChatTitleRequest{ - ChatID: 10, + ChatID: testChat().ID, Title: "aboba", }).ThenResult(&tg.Updates{}) _, err := api.SetChatTitle(ctx, oas.SetChatTitle{ @@ -72,7 +186,7 @@ func TestBotAPI_LeaveChat(t *testing.T) { ctx := context.Background() testWithCache(t, func(a *require.Assertions, mock *tgmock.Mock, api *BotAPI) { mock.ExpectCall(&tg.MessagesDeleteChatUserRequest{ - ChatID: 10, + ChatID: testChat().ID, UserID: &tg.InputUserSelf{}, }).ThenResult(&tg.Updates{}) _, err := api.LeaveChat(ctx, oas.LeaveChat{ diff --git a/internal/botapi/command.go b/internal/botapi/command.go index 7fadcb9..41916e7 100644 --- a/internal/botapi/command.go +++ b/internal/botapi/command.go @@ -54,7 +54,7 @@ func (b *BotAPI) convertToBotCommandScopeClass( } return &tg.BotCommandScopePeerUser{ Peer: p.InputPeer(), - UserID: user.AsInput(), + UserID: user.InputUser(), }, nil default: return nil, errors.Errorf("unknown peer type %q", scope.Type) diff --git a/internal/botapi/command_test.go b/internal/botapi/command_test.go index b0331d6..f105c2f 100644 --- a/internal/botapi/command_test.go +++ b/internal/botapi/command_test.go @@ -95,7 +95,7 @@ func TestBotAPI_convertToBotCommandScopeClass(t *testing.T) { }, &tg.BotCommandScopePeerUser{ Peer: testChat().AsInputPeer(), - UserID: testUser().AsInput(), + UserID: &tg.InputUserSelf{}, }, false, }, diff --git a/internal/botapi/convert_message.go b/internal/botapi/convert_message.go index 41260c0..f8315b5 100644 --- a/internal/botapi/convert_message.go +++ b/internal/botapi/convert_message.go @@ -92,14 +92,22 @@ func (b *BotAPI) convertToBotAPIPhotoSizes(p tg.PhotoClass) (r []oas.PhotoSize) continue } + // TODO(tdakkota): compute size if downloaded + var fileSize oas.OptInt + switch size := size.(type) { + case *tg.PhotoSize: + fileSize.SetTo(size.Size) + case *tg.PhotoCachedSize: + fileSize.SetTo(len(size.Bytes)) + } + fileID, fileUniqueID := b.encodeFileID(fileid.FromPhoto(photo, rune(t[0]))) r = append(r, oas.PhotoSize{ FileID: fileID, FileUniqueID: fileUniqueID, Width: size.GetW(), Height: size.GetH(), - // TODO(tdakkota): get size from variant/compute if downloaded/etc - FileSize: oas.OptInt{}, + FileSize: fileSize, }) } @@ -446,7 +454,7 @@ func (b *BotAPI) convertPlainMessage(ctx context.Context, m *tg.Message) (r oas. if m.Out { self, err := b.peers.Self(ctx) if err == nil { - r.From.SetTo(convertToBotAPIUser(self.Raw())) + r.From.SetTo(convertToBotAPIUser(self)) } } else if fromID, ok := m.GetFromID(); ok { // FIXME(tdakkota): set service IDs. diff --git a/internal/botapi/convert_message_test.go b/internal/botapi/convert_message_test.go index fa11850..4f0c232 100644 --- a/internal/botapi/convert_message_test.go +++ b/internal/botapi/convert_message_test.go @@ -74,7 +74,7 @@ func TestBotAPI_convertToBotAPIEntities(t *testing.T) { "MentionName", &tg.MessageEntityMentionName{Offset: 1, Length: 10, UserID: 10}, oas.MessageEntity{Type: oas.MessageEntityTypeTextMention, Offset: 1, Length: 10, - User: oas.NewOptUser(convertToBotAPIUser(testUser()))}, + User: oas.NewOptUser(convertRawToBotAPIUser(testUser()))}, }, { "Phone", diff --git a/internal/botapi/errors.go b/internal/botapi/errors.go index aac0bea..e154503 100644 --- a/internal/botapi/errors.go +++ b/internal/botapi/errors.go @@ -1,19 +1,5 @@ package botapi -import ( - "context" - "net/http" - - "github.com/go-faster/errors" - "github.com/go-faster/jx" - "go.uber.org/zap" - - "github.com/gotd/td/telegram/peers" - "github.com/gotd/td/tgerr" - - "github.com/gotd/botapi/internal/oas" -) - // NotImplementedError is stub error for not implemented methods. type NotImplementedError struct { Message string @@ -37,125 +23,6 @@ func (p *BadRequestError) Error() string { return p.Message } -func errorOf(code int) oas.ErrorStatusCode { - return errorStatusCode(code, "") -} - -func errorStatusCode(code int, description string) oas.ErrorStatusCode { - if description == "" { - description = http.StatusText(code) - } - return oas.ErrorStatusCode{ - StatusCode: code, - Response: oas.Error{ - ErrorCode: code, - Description: description, - }, - } -} - func chatNotFound() *BadRequestError { return &BadRequestError{Message: "Bad Request: chat not found"} } - -// NewError maps error to status code. -func (b *BotAPI) NewError(ctx context.Context, err error) (r oas.ErrorStatusCode) { - // TODO(tdakkota): pass request context info. - defer func() { - level := zap.DebugLevel - if r.StatusCode >= 500 { - level = zap.WarnLevel - } - if e := b.logger.Check(level, "Request error"); e != nil { - e.Write(zap.Error(err)) - } - }() - - var ( - notImplemented *NotImplementedError - peerNotFound *peers.PeerNotFoundError - badRequest *BadRequestError - ) - // TODO(tdakkota): better error mapping. - switch { - case errors.As(err, ¬Implemented): - return errorOf(http.StatusNotImplemented) - case errors.As(err, &peerNotFound): - return errorStatusCode(http.StatusBadRequest, "Bad Request: chat not found") - case errors.As(err, &badRequest): - return errorStatusCode(http.StatusBadRequest, badRequest.Message) - } - - // See https://github.com/tdlib/telegram-bot-api/blob/90f52477814a2d8a08c9ffb1d780fd179815d715/telegram-bot-api/Client.cpp#L86. - if rpcErr, ok := tgerr.As(err); ok && rpcErr.Code == 400 { - var ( - errorCode = rpcErr.Code - errorMessage = rpcErr.Message - ) - switch rpcErr.Type { - case "MESSAGE_NOT_MODIFIED": - errorMessage = "message is not modified: specified new message content " + - "and reply markup are exactly the same as a current content " + - "and reply markup of the message" - case "WC_CONVERT_URL_INVALID", "EXTERNAL_URL_INVALID": - errorMessage = "Wrong HTTP URL specified" - case "WEBPAGE_CURL_FAILED": - errorMessage = "Failed to get HTTP URL content" - case "WEBPAGE_MEDIA_EMPTY": - errorMessage = "Wrong type of the web page content" - case "MEDIA_GROUPED_INVALID": - errorMessage = "Can't use the media of the specified type in the album" - case "REPLY_MARKUP_TOO_LONG": - errorMessage = "reply markup is too long" - case "INPUT_USER_DEACTIVATED": - errorCode = 403 - errorMessage = "Forbidden: user is deactivated" - case "USER_IS_BLOCKED": - errorCode = 403 - errorMessage = "bot was blocked by the user" - case "USER_ADMIN_INVALID": - errorCode = 400 - errorMessage = "user is an administrator of the chat" - case "File generation failed": - errorCode = 400 - errorMessage = "can't upload file by URL" - case "CHAT_ABOUT_NOT_MODIFIED": - errorCode = 400 - errorMessage = "chat description is not modified" - case "PACK_SHORT_NAME_INVALID": - errorCode = 400 - errorMessage = "invalid sticker set name is specified" - case "PACK_SHORT_NAME_OCCUPIED": - errorCode = 400 - errorMessage = "sticker set name is already occupied" - case "STICKER_EMOJI_INVALID": - errorCode = 400 - errorMessage = "invalid sticker emojis" - case "QUERY_ID_INVALID": - errorCode = 400 - errorMessage = "query is too old and response timeout expired or query ID is invalid" - case "MESSAGE_DELETE_FORBIDDEN": - errorCode = 400 - errorMessage = "message can't be deleted" - } - - return errorStatusCode(errorCode, errorMessage) - } - - resp := errorOf(http.StatusInternalServerError) - if b.debug && err != nil { - resp.Response.Description = err.Error() - } - return resp -} - -// NotFound is default not found handler. -func NotFound(w http.ResponseWriter, _ *http.Request) { - apiError := errorOf(http.StatusNotFound) - - e := jx.GetEncoder() - defer jx.PutEncoder(e) - - apiError.Encode(e) - _, _ = e.WriteTo(w) -} diff --git a/internal/botapi/errors_map.go b/internal/botapi/errors_map.go new file mode 100644 index 0000000..7bd0404 --- /dev/null +++ b/internal/botapi/errors_map.go @@ -0,0 +1,152 @@ +package botapi + +import ( + "context" + "net/http" + + "github.com/go-faster/errors" + "github.com/go-faster/jx" + "go.uber.org/zap" + + "github.com/gotd/td/telegram/peers" + "github.com/gotd/td/tgerr" + + "github.com/gotd/botapi/internal/oas" +) + +func errorOf(code int) oas.ErrorStatusCode { + return errorStatusCode(code, "") +} + +func errorStatusCode(code int, description string) oas.ErrorStatusCode { + if description == "" { + description = http.StatusText(code) + } + return oas.ErrorStatusCode{ + StatusCode: code, + Response: oas.Error{ + ErrorCode: code, + Description: description, + }, + } +} + +// See https://github.com/tdlib/telegram-bot-api/blob/90f52477814a2d8a08c9ffb1d780fd179815d715/telegram-bot-api/Client.cpp#L86. +func tryMapRPCError(err error) (r oas.ErrorStatusCode, _ bool) { + rpcErr, ok := tgerr.As(err) + if !ok || rpcErr.Code != 400 { + return r, false + } + + var ( + errorCode = rpcErr.Code + errorMessage = rpcErr.Message + ) + switch rpcErr.Type { + case "MESSAGE_NOT_MODIFIED": + errorMessage = "message is not modified: specified new message content " + + "and reply markup are exactly the same as a current content " + + "and reply markup of the message" + case "WC_CONVERT_URL_INVALID", "EXTERNAL_URL_INVALID": + errorMessage = "Wrong HTTP URL specified" + case "WEBPAGE_CURL_FAILED": + errorMessage = "Failed to get HTTP URL content" + case "WEBPAGE_MEDIA_EMPTY": + errorMessage = "Wrong type of the web page content" + case "MEDIA_GROUPED_INVALID": + errorMessage = "Can't use the media of the specified type in the album" + case "REPLY_MARKUP_TOO_LONG": + errorMessage = "reply markup is too long" + case "INPUT_USER_DEACTIVATED": + errorCode = 403 + errorMessage = "Forbidden: user is deactivated" + case "USER_IS_BLOCKED": + errorCode = 403 + errorMessage = "bot was blocked by the user" + case "USER_ADMIN_INVALID": + errorCode = 400 + errorMessage = "user is an administrator of the chat" + case "File generation failed": + errorCode = 400 + errorMessage = "can't upload file by URL" + case "CHAT_ABOUT_NOT_MODIFIED": + errorCode = 400 + errorMessage = "chat description is not modified" + case "PACK_SHORT_NAME_INVALID": + errorCode = 400 + errorMessage = "invalid sticker set name is specified" + case "PACK_SHORT_NAME_OCCUPIED": + errorCode = 400 + errorMessage = "sticker set name is already occupied" + case "STICKER_EMOJI_INVALID": + errorCode = 400 + errorMessage = "invalid sticker emojis" + case "QUERY_ID_INVALID": + errorCode = 400 + errorMessage = "query is too old and response timeout expired or query ID is invalid" + case "MESSAGE_DELETE_FORBIDDEN": + errorCode = 400 + errorMessage = "message can't be deleted" + } + + return errorStatusCode(errorCode, errorMessage), true +} + +func mapGotdError(err error) error { + var ( + peerNotFound *peers.PeerNotFoundError + ) + switch { + case errors.As(err, &peerNotFound): + return &BadRequestError{Message: "Bad Request: chat not found"} + } + return err +} + +// NewError maps error to status code. +func (b *BotAPI) NewError(ctx context.Context, err error) (r oas.ErrorStatusCode) { + // TODO(tdakkota): pass request context info. + defer func() { + level := zap.DebugLevel + if r.StatusCode >= 500 { + level = zap.WarnLevel + } + if e := b.logger.Check(level, "Request error"); e != nil { + e.Write(zap.Error(err)) + } + }() + + err = mapGotdError(err) + var ( + notImplemented *NotImplementedError + badRequest *BadRequestError + ) + // TODO(tdakkota): better error mapping. + switch { + case errors.As(err, ¬Implemented): + return errorOf(http.StatusNotImplemented) + case errors.As(err, &badRequest): + return errorStatusCode(http.StatusBadRequest, badRequest.Message) + } + + if r, ok := tryMapRPCError(err); ok { + return r + } + + resp := errorOf(http.StatusInternalServerError) + if b.debug && err != nil { + resp.Response.Description = err.Error() + } + return resp +} + +// NotFound is default not found handler. +func NotFound(w http.ResponseWriter, _ *http.Request) { + apiError := errorOf(http.StatusNotFound) + + e := jx.GetEncoder() + defer jx.PutEncoder(e) + + apiError.Encode(e) + _, _ = e.WriteTo(w) +} diff --git a/internal/botapi/file.go b/internal/botapi/file.go index 709e55e..497b566 100644 --- a/internal/botapi/file.go +++ b/internal/botapi/file.go @@ -7,8 +7,8 @@ import ( ) // GetFile implements oas.Handler. -func (b *BotAPI) GetFile(ctx context.Context, req oas.GetFile) (oas.Result, error) { - return oas.Result{}, &NotImplementedError{} +func (b *BotAPI) GetFile(ctx context.Context, req oas.GetFile) (oas.ResultFile, error) { + return oas.ResultFile{}, &NotImplementedError{} } // UploadStickerFile implements oas.Handler. diff --git a/internal/botapi/file_id.go b/internal/botapi/file_id.go index 0129dcb..fa80f78 100644 --- a/internal/botapi/file_id.go +++ b/internal/botapi/file_id.go @@ -1,6 +1,12 @@ package botapi -import "github.com/gotd/td/fileid" +import ( + "github.com/gotd/td/constant" + "github.com/gotd/td/fileid" + "github.com/gotd/td/tg" + + "github.com/gotd/botapi/internal/oas" +) func (b *BotAPI) encodeFileID(f fileid.FileID) (fileID, fileUniqueID string) { fileID, _ = fileid.EncodeFileID(f) @@ -8,3 +14,52 @@ func (b *BotAPI) encodeFileID(f fileid.FileID) (fileID, fileUniqueID string) { fileUniqueID = "todo" return fileID, fileUniqueID } + +func (b *BotAPI) profilePhotoFileID( + id constant.TDLibPeerID, + accessHash int64, + photo fileid.ChatPhoto, + big bool, +) (fileID, fileUniqueID string) { + return b.encodeFileID(fileid.FromChatPhoto(id, accessHash, photo, big)) +} + +func (b *BotAPI) setChatPhoto( + id constant.TDLibPeerID, + accessHash int64, + from tg.ChatPhotoClass, +) (to oas.OptChatPhoto) { + p, ok := from.(*tg.ChatPhoto) + if !ok { + return + } + + smallFileID, smallUniqueFileID := b.profilePhotoFileID(id, accessHash, p, false) + bigFileID, bigUniqueFileID := b.profilePhotoFileID(id, accessHash, p, true) + return oas.NewOptChatPhoto(oas.ChatPhoto{ + SmallFileID: smallFileID, + SmallFileUniqueID: smallUniqueFileID, + BigFileID: bigFileID, + BigFileUniqueID: bigUniqueFileID, + }) +} + +func (b *BotAPI) setUserPhoto( + id constant.TDLibPeerID, + accessHash int64, + from tg.UserProfilePhotoClass, +) (to oas.OptChatPhoto) { + p, ok := from.(*tg.UserProfilePhoto) + if !ok { + return + } + + smallFileID, smallUniqueFileID := b.profilePhotoFileID(id, accessHash, p, false) + bigFileID, bigUniqueFileID := b.profilePhotoFileID(id, accessHash, p, true) + return oas.NewOptChatPhoto(oas.ChatPhoto{ + SmallFileID: smallFileID, + SmallFileUniqueID: smallUniqueFileID, + BigFileID: bigFileID, + BigFileUniqueID: bigUniqueFileID, + }) +} diff --git a/internal/botapi/invite_link.go b/internal/botapi/invite_link.go index 9e22449..64f6064 100644 --- a/internal/botapi/invite_link.go +++ b/internal/botapi/invite_link.go @@ -2,26 +2,131 @@ package botapi import ( "context" + "time" + + "github.com/go-faster/errors" + + "github.com/gotd/td/telegram/peers" "github.com/gotd/botapi/internal/oas" ) +func (b *BotAPI) convertInviteLink(ctx context.Context, link peers.InviteLink) (oas.ChatInviteLink, error) { + creator, err := link.Creator(ctx) + if err != nil { + return oas.ChatInviteLink{}, errors.Wrap(err, "get creator") + } + + raw := link.Raw() + result := oas.ChatInviteLink{ + InviteLink: link.Link(), + Creator: convertToBotAPIUser(creator), + CreatesJoinRequest: link.RequestNeeded(), + IsPrimary: link.Permanent(), + IsRevoked: link.Revoked(), + Name: optString(link.Title), + ExpireDate: optInt(raw.GetExpireDate), + MemberLimit: optInt(link.UsageLimit), + PendingJoinRequestCount: optInt(link.Requested), + } + return result, nil +} + +func (b *BotAPI) editInviteLinks( + ctx context.Context, + id oas.ID, + cb func(links peers.InviteLinks) (peers.InviteLink, error), +) (oas.ResultChatInviteLink, error) { + p, err := b.resolveIDToChat(ctx, id) + if err != nil { + return oas.ResultChatInviteLink{}, errors.Wrap(err, "resolve chatID") + } + + link, err := cb(p.InviteLinks()) + if err != nil { + return oas.ResultChatInviteLink{}, err + } + + result, err := b.convertInviteLink(ctx, link) + if err != nil { + return oas.ResultChatInviteLink{}, errors.Wrap(err, "convert link") + } + + return oas.ResultChatInviteLink{ + Result: oas.NewOptChatInviteLink(result), + Ok: true, + }, nil +} + // CreateChatInviteLink implements oas.Handler. func (b *BotAPI) CreateChatInviteLink(ctx context.Context, req oas.CreateChatInviteLink) (oas.ResultChatInviteLink, error) { - return oas.ResultChatInviteLink{}, &NotImplementedError{} + return b.editInviteLinks(ctx, req.ChatID, func(links peers.InviteLinks) (peers.InviteLink, error) { + opts := peers.ExportLinkOptions{ + RequestNeeded: req.CreatesJoinRequest.Value, + ExpireDate: time.Time{}, + UsageLimit: req.MemberLimit.Value, + Title: req.Name.Value, + } + if u, ok := req.ExpireDate.Get(); ok { + opts.ExpireDate = time.Unix(int64(u), 0) + } + + link, err := links.AddNew(ctx, opts) + if err != nil { + return peers.InviteLink{}, errors.Wrap(err, "create link") + } + return link, nil + }) } // EditChatInviteLink implements oas.Handler. func (b *BotAPI) EditChatInviteLink(ctx context.Context, req oas.EditChatInviteLink) (oas.ResultChatInviteLink, error) { - return oas.ResultChatInviteLink{}, &NotImplementedError{} + return b.editInviteLinks(ctx, req.ChatID, func(links peers.InviteLinks) (peers.InviteLink, error) { + opts := peers.ExportLinkOptions{ + RequestNeeded: req.CreatesJoinRequest.Value, + ExpireDate: time.Time{}, + UsageLimit: req.MemberLimit.Value, + Title: req.Name.Value, + } + if u, ok := req.ExpireDate.Get(); ok { + opts.ExpireDate = time.Unix(int64(u), 0) + } + + link, err := links.Edit(ctx, req.InviteLink, opts) + if err != nil { + return peers.InviteLink{}, errors.Wrap(err, "edit link") + } + + return link, nil + }) } // ExportChatInviteLink implements oas.Handler. func (b *BotAPI) ExportChatInviteLink(ctx context.Context, req oas.ExportChatInviteLink) (oas.ResultString, error) { - return oas.ResultString{}, &NotImplementedError{} + p, err := b.resolveIDToChat(ctx, req.ChatID) + if err != nil { + return oas.ResultString{}, errors.Wrap(err, "resolve chatID") + } + + link, err := p.InviteLinks().ExportNew(ctx, peers.ExportLinkOptions{}) + if err != nil { + return oas.ResultString{}, errors.Wrap(err, "export link") + } + + return oas.ResultString{ + Result: oas.NewOptString(link.Link()), + Ok: true, + }, nil } // RevokeChatInviteLink implements oas.Handler. func (b *BotAPI) RevokeChatInviteLink(ctx context.Context, req oas.RevokeChatInviteLink) (oas.ResultChatInviteLink, error) { - return oas.ResultChatInviteLink{}, &NotImplementedError{} + return b.editInviteLinks(ctx, req.ChatID, func(links peers.InviteLinks) (peers.InviteLink, error) { + link, err := links.Revoke(ctx, req.InviteLink) + if err != nil { + return peers.InviteLink{}, errors.Wrap(err, "edit link") + } + + return link, nil + }) } diff --git a/internal/botapi/invite_link_test.go b/internal/botapi/invite_link_test.go new file mode 100644 index 0000000..7edd2eb --- /dev/null +++ b/internal/botapi/invite_link_test.go @@ -0,0 +1,36 @@ +package botapi + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/gotd/td/tg" + "github.com/gotd/td/tgmock" + + "github.com/gotd/botapi/internal/oas" +) + +func TestBotAPI_RevokeChatInviteLink(t *testing.T) { + ctx := context.Background() + testWithCache(t, func(a *require.Assertions, mock *tgmock.Mock, api *BotAPI) { + mock.ExpectCall(&tg.MessagesEditExportedChatInviteRequest{ + Revoked: true, + Peer: &tg.InputPeerChat{ChatID: testChat().ID}, + Link: "aboba", + }).ThenResult(&tg.MessagesExportedChatInvite{ + Invite: tg.ChatInviteExported{ + Revoked: true, + Link: "aboba", + AdminID: testUser().ID, + }, + Users: []tg.UserClass{testUser()}, + }) + _, err := api.RevokeChatInviteLink(ctx, oas.RevokeChatInviteLink{ + ChatID: oas.NewInt64ID(testChatID()), + InviteLink: "aboba", + }) + a.NoError(err) + }) +} diff --git a/internal/botapi/markup.go b/internal/botapi/markup.go index 2d9fa53..a8a3e7c 100644 --- a/internal/botapi/markup.go +++ b/internal/botapi/markup.go @@ -33,7 +33,7 @@ func (b *BotAPI) convertToTelegramInlineButton( loginURL := button.LoginURL.Value var user tg.InputUserClass = &tg.InputUserSelf{} - if v, ok := loginURL.BotUsername.Get(); ok && v != "" { + if v := loginURL.BotUsername.Or(""); v != "" { p, err := b.peers.ResolveDomain(ctx, loginURL.BotUsername.Value) if err != nil { return nil, errors.Wrap(err, "resolve bot") @@ -107,10 +107,10 @@ func convertToTelegramButton(kb oas.KeyboardButton) tg.KeyboardButtonClass { func (b *BotAPI) convertToTelegramReplyMarkup( ctx context.Context, - m *oas.SendMessageReplyMarkup, + m *oas.SendReplyMarkup, ) (tg.ReplyMarkupClass, error) { switch m.Type { - case oas.InlineKeyboardMarkupSendMessageReplyMarkup: + case oas.InlineKeyboardMarkupSendReplyMarkup: rows := m.InlineKeyboardMarkup.InlineKeyboard result := &tg.ReplyInlineMarkup{Rows: make([]tg.KeyboardButtonRow, 0, len(rows))} for _, row := range rows { @@ -125,7 +125,7 @@ func (b *BotAPI) convertToTelegramReplyMarkup( result.Rows = append(result.Rows, tg.KeyboardButtonRow{Buttons: resultRow}) } return result, nil - case oas.ReplyKeyboardMarkupSendMessageReplyMarkup: + case oas.ReplyKeyboardMarkupSendReplyMarkup: mark := m.ReplyKeyboardMarkup rows := mark.Keyboard @@ -146,12 +146,12 @@ func (b *BotAPI) convertToTelegramReplyMarkup( result.Rows = append(result.Rows, tg.KeyboardButtonRow{Buttons: resultRow}) } return result, nil - case oas.ReplyKeyboardRemoveSendMessageReplyMarkup: - if v, ok := m.ReplyKeyboardRemove.Selective.Get(); ok && v { + case oas.ReplyKeyboardRemoveSendReplyMarkup: + if v := m.ReplyKeyboardRemove.Selective.Or(false); v { return markup.SelectiveHide(), nil } return markup.Hide(), nil - case oas.ForceReplySendMessageReplyMarkup: + case oas.ForceReplySendReplyMarkup: mark := m.ForceReply result := &tg.ReplyKeyboardForceReply{ Selective: mark.Selective.Value, diff --git a/internal/botapi/markup_test.go b/internal/botapi/markup_test.go index 8f43ec0..9b014d4 100644 --- a/internal/botapi/markup_test.go +++ b/internal/botapi/markup_test.go @@ -287,14 +287,14 @@ func Test_convertToTelegramButton(t *testing.T) { func TestBotAPI_convertToTelegramReplyMarkup(t *testing.T) { tests := []struct { name string - input *oas.SendMessageReplyMarkup + input *oas.SendReplyMarkup want tg.ReplyMarkupClass wantErr bool }{ { "Inline", - &oas.SendMessageReplyMarkup{ - Type: oas.InlineKeyboardMarkupSendMessageReplyMarkup, + &oas.SendReplyMarkup{ + Type: oas.InlineKeyboardMarkupSendReplyMarkup, InlineKeyboardMarkup: oas.InlineKeyboardMarkup{ InlineKeyboard: [][]oas.InlineKeyboardButton{ { @@ -319,8 +319,8 @@ func TestBotAPI_convertToTelegramReplyMarkup(t *testing.T) { }, { "Reply", - &oas.SendMessageReplyMarkup{ - Type: oas.ReplyKeyboardMarkupSendMessageReplyMarkup, + &oas.SendReplyMarkup{ + Type: oas.ReplyKeyboardMarkupSendReplyMarkup, ReplyKeyboardMarkup: oas.ReplyKeyboardMarkup{ Keyboard: [][]oas.KeyboardButton{ { @@ -350,8 +350,8 @@ func TestBotAPI_convertToTelegramReplyMarkup(t *testing.T) { }, { "Hide", - &oas.SendMessageReplyMarkup{ - Type: oas.ReplyKeyboardRemoveSendMessageReplyMarkup, + &oas.SendReplyMarkup{ + Type: oas.ReplyKeyboardRemoveSendReplyMarkup, ReplyKeyboardRemove: oas.ReplyKeyboardRemove{ RemoveKeyboard: true, }, @@ -363,8 +363,8 @@ func TestBotAPI_convertToTelegramReplyMarkup(t *testing.T) { }, { "SelectiveHide", - &oas.SendMessageReplyMarkup{ - Type: oas.ReplyKeyboardRemoveSendMessageReplyMarkup, + &oas.SendReplyMarkup{ + Type: oas.ReplyKeyboardRemoveSendReplyMarkup, ReplyKeyboardRemove: oas.ReplyKeyboardRemove{ RemoveKeyboard: true, Selective: oas.NewOptBool(true), @@ -377,8 +377,8 @@ func TestBotAPI_convertToTelegramReplyMarkup(t *testing.T) { }, { "ForceReply", - &oas.SendMessageReplyMarkup{ - Type: oas.ForceReplySendMessageReplyMarkup, + &oas.SendReplyMarkup{ + Type: oas.ForceReplySendReplyMarkup, ForceReply: oas.ForceReply{ ForceReply: true, InputFieldPlaceholder: oas.NewOptString("placeholder"), @@ -393,7 +393,7 @@ func TestBotAPI_convertToTelegramReplyMarkup(t *testing.T) { }, { "UnknownType", - &oas.SendMessageReplyMarkup{ + &oas.SendReplyMarkup{ Type: "aboba", }, nil, diff --git a/internal/botapi/me.go b/internal/botapi/me.go index 459877a..5802458 100644 --- a/internal/botapi/me.go +++ b/internal/botapi/me.go @@ -3,12 +3,13 @@ package botapi import ( "context" + "github.com/gotd/td/telegram/peers" "github.com/gotd/td/tg" "github.com/gotd/botapi/internal/oas" ) -func convertToBotAPIUser(user *tg.User) oas.User { +func convertRawToBotAPIUser(user *tg.User) oas.User { return oas.User{ ID: user.ID, IsBot: user.Bot, @@ -22,6 +23,10 @@ func convertToBotAPIUser(user *tg.User) oas.User { } } +func convertToBotAPIUser(u peers.User) oas.User { + return convertRawToBotAPIUser(u.Raw()) +} + // GetMe implements oas.Handler. func (b *BotAPI) GetMe(ctx context.Context) (oas.ResultUser, error) { me, err := b.peers.Self(ctx) @@ -30,7 +35,7 @@ func (b *BotAPI) GetMe(ctx context.Context) (oas.ResultUser, error) { } return oas.ResultUser{ - Result: oas.NewOptUser(convertToBotAPIUser(me.Raw())), + Result: oas.NewOptUser(convertToBotAPIUser(me)), Ok: true, }, nil } diff --git a/internal/botapi/optional.go b/internal/botapi/optional.go index 78a7aac..810da02 100644 --- a/internal/botapi/optional.go +++ b/internal/botapi/optional.go @@ -17,3 +17,11 @@ func optInt(getter func() (int, bool)) oas.OptInt { } return oas.NewOptInt(v) } + +func optInt64(getter func() (int64, bool)) oas.OptInt64 { + v, ok := getter() + if !ok { + return oas.OptInt64{} + } + return oas.NewOptInt64(v) +} diff --git a/internal/botapi/peers.go b/internal/botapi/peers.go index a3715d5..c28e3cd 100644 --- a/internal/botapi/peers.go +++ b/internal/botapi/peers.go @@ -13,61 +13,79 @@ import ( "github.com/gotd/botapi/internal/oas" ) -func (b *BotAPI) getChatByPeer(ctx context.Context, p tg.PeerClass) (oas.Chat, error) { - peer, err := b.peers.ResolvePeer(ctx, p) - if err != nil { - return oas.Chat{}, errors.Wrapf(err, "find peer: %+v", p) - } - - tdlibID := peer.TDLibPeerID() - if user, ok := peer.(peers.User); ok { - return oas.Chat{ - ID: int64(tdlibID), - Type: oas.ChatTypePrivate, - Username: optString(user.Username), - FirstName: optString(user.FirstName), - LastName: optString(user.LastName), - }, nil +func fillBotAPIChatPrivate(user peers.User) oas.Chat { + return oas.Chat{ + ID: int64(user.TDLibPeerID()), + Type: oas.ChatTypePrivate, + Username: optString(user.Username), + FirstName: optString(user.FirstName), + LastName: optString(user.LastName), } +} +func fillBotAPIChatGroup(chat Chat) oas.Chat { r := oas.Chat{ - ID: int64(tdlibID), + ID: int64(chat.TDLibPeerID()), Type: oas.ChatTypeGroup, - Title: oas.NewOptString(peer.VisibleName()), - HasProtectedContent: oas.OptBool{}, + Title: oas.NewOptString(chat.VisibleName()), + Username: optString(chat.Username), + HasProtectedContent: oas.NewOptBool(chat.NoForwards()), } - switch ch := peer.(type) { - case peers.Chat: - r.HasProtectedContent.SetTo(ch.NoForwards()) + switch ch := chat.(type) { case peers.Channel: if _, ok := ch.ToBroadcast(); ok { r.Type = oas.ChatTypeChannel } else { r.Type = oas.ChatTypeSupergroup } - r.Username = optString(ch.Username) - r.HasProtectedContent.SetTo(ch.NoForwards()) + } + return r +} + +func (b *BotAPI) getChatByPeer(ctx context.Context, p tg.PeerClass) (oas.Chat, error) { + peer, err := b.peers.ResolvePeer(ctx, p) + if err != nil { + return oas.Chat{}, errors.Wrapf(err, "find peer: %+v", p) } - return r, nil + if user, ok := peer.(peers.User); ok { + return fillBotAPIChatPrivate(user), nil + } + + ch, ok := peer.(Chat) + if !ok { + return oas.Chat{}, errors.Errorf("unexpected type %T", peer) + } + return fillBotAPIChatGroup(ch), nil } -func (b *BotAPI) resolveUserID(ctx context.Context, id int64) (*tg.User, error) { +func (b *BotAPI) resolveUserID(ctx context.Context, id int64) (peers.User, error) { user, err := b.peers.GetUser(ctx, &tg.InputUser{UserID: id}) if err != nil { - return nil, errors.Wrapf(err, "find user: %d", id) + return peers.User{}, errors.Wrapf(err, "find user: %d", id) } - return user.Raw(), nil + return user, nil } // Chat is generic interface for peers.Chat, peers.Channel and friends. type Chat interface { peers.Peer + Creator() bool Left() bool + NoForwards() bool + CallActive() bool + CallNotEmpty() bool ParticipantsCount() int + AdminRights() (tg.ChatAdminRights, bool) + DefaultBannedRights() (tg.ChatBannedRights, bool) + Leave(ctx context.Context) error SetTitle(ctx context.Context, title string) error SetDescription(ctx context.Context, about string) error + + InviteLinks() peers.InviteLinks + ToSupergroup() (peers.Supergroup, bool) + ToBroadcast() (peers.Broadcast, bool) } var _ = []Chat{ @@ -75,7 +93,7 @@ var _ = []Chat{ peers.Channel{}, } -func (b *BotAPI) resolveChatID(ctx context.Context, id oas.ID) (Chat, error) { +func (b *BotAPI) resolveIDToChat(ctx context.Context, id oas.ID) (Chat, error) { p, err := b.resolveID(ctx, id) if err != nil { return nil, err diff --git a/internal/botapi/rewrite.go b/internal/botapi/rewrite.go new file mode 100644 index 0000000..1dabb14 --- /dev/null +++ b/internal/botapi/rewrite.go @@ -0,0 +1,15 @@ +package botapi + +// CorrectMethod fixes legacy method name to actual. +func CorrectMethod(m string) string { + switch m { + case "getChatMembersCount": + // See https://core.telegram.org/bots/api#june-25-2021. + return "getChatMemberCount" + case "kickChatMember": + // See https://core.telegram.org/bots/api#june-25-2021. + return "banChatMember" + default: + return m + } +} diff --git a/internal/botapi/send.go b/internal/botapi/send.go index aaa8956..667fdcd 100644 --- a/internal/botapi/send.go +++ b/internal/botapi/send.go @@ -5,6 +5,9 @@ import ( "github.com/go-faster/errors" + "github.com/gotd/td/telegram/message" + "github.com/gotd/td/telegram/peers" + "github.com/gotd/td/telegram/message/html" "github.com/gotd/td/telegram/message/unpack" "github.com/gotd/td/tg" @@ -12,6 +15,82 @@ import ( "github.com/gotd/botapi/internal/oas" ) +func (b *BotAPI) sentMessage( + ctx context.Context, + p peers.Peer, + resp tg.UpdatesClass, err error, +) (oas.ResultMessage, error) { + m, err := unpack.MessageClass(resp, err) + if err != nil { + return oas.ResultMessage{}, errors.Wrap(err, "send") + } + + msg, ok := m.(*tg.Message) + if !ok { + return oas.ResultMessage{ + Ok: true, + }, nil + } + if msg.PeerID == nil { + switch p := p.InputPeer().(type) { + case *tg.InputPeerChat: + msg.PeerID = &tg.PeerChat{ChatID: p.ChatID} + case *tg.InputPeerUser: + msg.PeerID = &tg.PeerUser{UserID: p.UserID} + case *tg.InputPeerChannel: + msg.PeerID = &tg.PeerChannel{ChannelID: p.ChannelID} + } + } + + resultMsg, err := b.convertPlainMessage(ctx, msg) + if err != nil { + return oas.ResultMessage{}, errors.Wrap(err, "get message") + } + return oas.ResultMessage{ + Result: oas.NewOptMessage(resultMsg), + Ok: true, + }, nil +} + +type sendOpts struct { + To oas.ID + DisableWebPagePreview oas.OptBool + DisableNotification oas.OptBool + ReplyToMessageID oas.OptInt + AllowSendingWithoutReply oas.OptBool + ReplyMarkup *oas.SendReplyMarkup +} + +func (b *BotAPI) prepareSend( + ctx context.Context, + req sendOpts, +) (*message.Builder, peers.Peer, error) { + p, err := b.resolveID(ctx, req.To) + if err != nil { + return nil, nil, errors.Wrap(err, "resolve chatID") + } + s := &b.sender.To(p.InputPeer()).Builder + + if v := req.DisableWebPagePreview.Or(false); v { + s = s.NoWebpage() + } + if v := req.DisableNotification.Or(false); v { + s = s.Silent() + } + // TODO(tdakkota): check allow_sending_without_reply + if v, ok := req.ReplyToMessageID.Get(); ok { + s = s.Reply(v) + } + if m := req.ReplyMarkup; m != nil { + mkp, err := b.convertToTelegramReplyMarkup(ctx, m) + if err != nil { + return nil, nil, errors.Wrap(err, "convert markup") + } + s = s.Markup(mkp) + } + return s, p, nil +} + // SendAnimation implements oas.Handler. func (b *BotAPI) SendAnimation(ctx context.Context, req oas.SendAnimation) (oas.ResultMessage, error) { return oas.ResultMessage{}, &NotImplementedError{} @@ -24,7 +103,46 @@ func (b *BotAPI) SendAudio(ctx context.Context, req oas.SendAudio) (oas.ResultMe // SendChatAction implements oas.Handler. func (b *BotAPI) SendChatAction(ctx context.Context, req oas.SendChatAction) (oas.Result, error) { - return oas.Result{}, &NotImplementedError{} + p, err := b.resolveID(ctx, req.ChatID) + if err != nil { + return oas.Result{}, errors.Wrap(err, "resolve chatID") + } + + s := b.sender.To(p.InputPeer()).TypingAction() + progress := 0 + switch req.Action { + case "cancel": + err = s.Cancel(ctx) + case "typing": + err = s.Typing(ctx) + case "record_video": + err = s.RecordVideo(ctx) + case "upload_video": + err = s.UploadVideo(ctx, progress) + case "record_audio", "record_voice": + err = s.RecordAudio(ctx) + case "upload_audio", "upload_voice": + err = s.UploadVideo(ctx, progress) + case "upload_photo": + err = s.UploadPhoto(ctx, progress) + case "upload_document": + err = s.UploadDocument(ctx, progress) + case "choose_sticker": + err = s.ChooseSticker(ctx) + case "pick_up_location", "find_location": + err = s.GeoLocation(ctx) + case "record_video_note": + err = s.RecordRound(ctx) + case "upload_video_note": + err = s.UploadRound(ctx, progress) + default: + return oas.Result{}, &BadRequestError{"Wrong parameter action in request"} + } + if err != nil { + return oas.Result{}, errors.Wrap(err, "send action") + } + + return resultOK(true), nil } // SendContact implements oas.Handler. @@ -34,7 +152,20 @@ func (b *BotAPI) SendContact(ctx context.Context, req oas.SendContact) (oas.Resu // SendDice implements oas.Handler. func (b *BotAPI) SendDice(ctx context.Context, req oas.SendDice) (oas.ResultMessage, error) { - return oas.ResultMessage{}, &NotImplementedError{} + s, p, err := b.prepareSend( + ctx, + sendOpts{ + To: req.ChatID, + DisableNotification: req.DisableNotification, + ReplyToMessageID: req.ReplyToMessageID, + AllowSendingWithoutReply: req.AllowSendingWithoutReply, + }, + ) + if err != nil { + return oas.ResultMessage{}, errors.Wrap(err, "prepare send") + } + resp, err := s.Media(ctx, message.MediaDice(req.Emoji.Or("🎲"))) + return b.sentMessage(ctx, p, resp, err) } // SendDocument implements oas.Handler. @@ -44,7 +175,33 @@ func (b *BotAPI) SendDocument(ctx context.Context, req oas.SendDocument) (oas.Re // SendGame implements oas.Handler. func (b *BotAPI) SendGame(ctx context.Context, req oas.SendGame) (oas.ResultMessage, error) { - return oas.ResultMessage{}, &NotImplementedError{} + var markup *oas.SendReplyMarkup + if m, ok := req.ReplyMarkup.Get(); ok { + markup = &oas.SendReplyMarkup{ + Type: oas.InlineKeyboardMarkupSendReplyMarkup, + InlineKeyboardMarkup: m, + } + } + + s, p, err := b.prepareSend( + ctx, + sendOpts{ + To: oas.NewInt64ID(req.ChatID), + DisableNotification: req.DisableNotification, + ReplyToMessageID: req.ReplyToMessageID, + AllowSendingWithoutReply: req.AllowSendingWithoutReply, + ReplyMarkup: markup, + }, + ) + if err != nil { + return oas.ResultMessage{}, errors.Wrap(err, "prepare send") + } + + resp, err := s.Media(ctx, message.Game(&tg.InputGameShortName{ + BotID: &tg.InputUserSelf{}, + ShortName: req.GameShortName, + })) + return b.sentMessage(ctx, p, resp, err) } // SendInvoice implements oas.Handler. @@ -69,27 +226,19 @@ func (b *BotAPI) SendMessage(ctx context.Context, req oas.SendMessage) (oas.Resu return oas.ResultMessage{}, &NotImplementedError{Message: "only HTML formatting is supported"} } - p, err := b.resolveID(ctx, req.ChatID) + s, p, err := b.prepareSend( + ctx, + sendOpts{ + To: req.ChatID, + DisableWebPagePreview: req.DisableWebPagePreview, + DisableNotification: req.DisableNotification, + ReplyToMessageID: req.ReplyToMessageID, + AllowSendingWithoutReply: req.AllowSendingWithoutReply, + ReplyMarkup: req.ReplyMarkup, + }, + ) if err != nil { - return oas.ResultMessage{}, errors.Wrap(err, "resolve chatID") - } - s := &b.sender.To(p.InputPeer()).Builder - - if v, ok := req.DisableWebPagePreview.Get(); ok && v { - s = s.NoWebpage() - } - if v, ok := req.DisableNotification.Get(); ok && v { - s = s.Silent() - } - if v, ok := req.ReplyToMessageID.Get(); ok { - s = s.Reply(v) - } - if m := req.ReplyMarkup; m != nil { - mkp, err := b.convertToTelegramReplyMarkup(ctx, m) - if err != nil { - return oas.ResultMessage{}, errors.Wrap(err, "convert markup") - } - s = s.Markup(mkp) + return oas.ResultMessage{}, errors.Wrap(err, "prepare send") } var resp tg.UpdatesClass @@ -101,36 +250,7 @@ func (b *BotAPI) SendMessage(ctx context.Context, req oas.SendMessage) (oas.Resu resp, err = s.Text(ctx, req.Text) } - m, err := unpack.MessageClass(resp, err) - if err != nil { - return oas.ResultMessage{}, errors.Wrap(err, "send") - } - - msg, ok := m.(*tg.Message) - if !ok { - return oas.ResultMessage{ - Ok: true, - }, nil - } - if msg.PeerID == nil { - switch p := p.InputPeer().(type) { - case *tg.InputPeerChat: - msg.PeerID = &tg.PeerChat{ChatID: p.ChatID} - case *tg.InputPeerUser: - msg.PeerID = &tg.PeerUser{UserID: p.UserID} - case *tg.InputPeerChannel: - msg.PeerID = &tg.PeerChannel{ChannelID: p.ChannelID} - } - } - - resultMsg, err := b.convertPlainMessage(ctx, msg) - if err != nil { - return oas.ResultMessage{}, errors.Wrap(err, "get message") - } - return oas.ResultMessage{ - Result: oas.NewOptMessage(resultMsg), - Ok: true, - }, nil + return b.sentMessage(ctx, p, resp, err) } // SendPhoto implements oas.Handler. diff --git a/internal/botapi/send_test.go b/internal/botapi/send_test.go new file mode 100644 index 0000000..b6c56a5 --- /dev/null +++ b/internal/botapi/send_test.go @@ -0,0 +1,61 @@ +package botapi + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/gotd/td/tg" + "github.com/gotd/td/tgmock" + + "github.com/gotd/botapi/internal/oas" +) + +func TestBotAPI_SendChatAction(t *testing.T) { + progress := 0 + tests := []struct { + action string + expect tg.SendMessageActionClass + wantErr bool + }{ + {"cancel", &tg.SendMessageCancelAction{}, false}, + {"typing", &tg.SendMessageTypingAction{}, false}, + {"record_video", &tg.SendMessageRecordVideoAction{}, false}, + {"upload_video", &tg.SendMessageUploadVideoAction{Progress: progress}, false}, + {"record_audio", &tg.SendMessageRecordAudioAction{}, false}, + {"record_voice", &tg.SendMessageRecordAudioAction{}, false}, + {"upload_audio", &tg.SendMessageUploadVideoAction{Progress: progress}, false}, + {"upload_voice", &tg.SendMessageUploadVideoAction{Progress: progress}, false}, + {"upload_photo", &tg.SendMessageUploadPhotoAction{Progress: progress}, false}, + {"upload_document", &tg.SendMessageUploadDocumentAction{Progress: progress}, false}, + {"choose_sticker", &tg.SendMessageChooseStickerAction{}, false}, + {"pick_up_location", &tg.SendMessageGeoLocationAction{}, false}, + {"find_location", &tg.SendMessageGeoLocationAction{}, false}, + {"record_video_note", &tg.SendMessageRecordRoundAction{}, false}, + {"upload_video_note", &tg.SendMessageUploadRoundAction{Progress: progress}, false}, + {"", nil, true}, + } + for _, tt := range tests { + t.Run(tt.action, func(t *testing.T) { + ctx := context.Background() + testWithCache(t, func(a *require.Assertions, mock *tgmock.Mock, api *BotAPI) { + if !tt.wantErr { + mock.ExpectCall(&tg.MessagesSetTypingRequest{ + Peer: &tg.InputPeerChat{ChatID: testChat().ID}, + Action: tt.expect, + }).ThenTrue() + } + _, err := api.SendChatAction(ctx, oas.SendChatAction{ + ChatID: oas.NewInt64ID(testChatID()), + Action: tt.action, + }) + if tt.wantErr { + a.Error(err) + return + } + a.NoError(err) + }) + }) + } +} diff --git a/internal/botapi/sticker.go b/internal/botapi/sticker.go index cf90fca..d25d36e 100644 --- a/internal/botapi/sticker.go +++ b/internal/botapi/sticker.go @@ -22,8 +22,8 @@ func (b *BotAPI) DeleteStickerFromSet(ctx context.Context, req oas.DeleteSticker } // GetStickerSet implements oas.Handler. -func (b *BotAPI) GetStickerSet(ctx context.Context, req oas.GetStickerSet) (oas.Result, error) { - return oas.Result{}, &NotImplementedError{} +func (b *BotAPI) GetStickerSet(ctx context.Context, req oas.GetStickerSet) (oas.ResultStickerSet, error) { + return oas.ResultStickerSet{}, &NotImplementedError{} } // SetStickerPositionInSet implements oas.Handler. diff --git a/internal/botapi/unimplemented_test.go b/internal/botapi/unimplemented_test.go index c379421..92e5485 100644 --- a/internal/botapi/unimplemented_test.go +++ b/internal/botapi/unimplemented_test.go @@ -4,14 +4,16 @@ import ( "context" "testing" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/gotd/botapi/internal/oas" ) +var _ oas.Handler = (*BotAPI)(nil) + func TestUnimplemented(t *testing.T) { ctx := context.Background() - a := require.New(t) + a := assert.New(t) b := BotAPI{} { @@ -44,12 +46,6 @@ func TestUnimplemented(t *testing.T) { a.ErrorAs(err, &implErr) } - { - _, err := b.ApproveChatJoinRequest(ctx, oas.ApproveChatJoinRequest{}) - var implErr *NotImplementedError - a.ErrorAs(err, &implErr) - } - { _, err := b.BanChatMember(ctx, oas.BanChatMember{}) var implErr *NotImplementedError @@ -68,36 +64,18 @@ func TestUnimplemented(t *testing.T) { a.ErrorAs(err, &implErr) } - { - _, err := b.CreateChatInviteLink(ctx, oas.CreateChatInviteLink{}) - var implErr *NotImplementedError - a.ErrorAs(err, &implErr) - } - { _, err := b.CreateNewStickerSet(ctx, oas.CreateNewStickerSet{}) var implErr *NotImplementedError a.ErrorAs(err, &implErr) } - { - _, err := b.DeclineChatJoinRequest(ctx, oas.DeclineChatJoinRequest{}) - var implErr *NotImplementedError - a.ErrorAs(err, &implErr) - } - { _, err := b.DeleteChatPhoto(ctx, oas.DeleteChatPhoto{}) var implErr *NotImplementedError a.ErrorAs(err, &implErr) } - { - _, err := b.DeleteChatStickerSet(ctx, oas.DeleteChatStickerSet{}) - var implErr *NotImplementedError - a.ErrorAs(err, &implErr) - } - { _, err := b.DeleteMessage(ctx, oas.DeleteMessage{}) var implErr *NotImplementedError @@ -116,12 +94,6 @@ func TestUnimplemented(t *testing.T) { a.ErrorAs(err, &implErr) } - { - _, err := b.EditChatInviteLink(ctx, oas.EditChatInviteLink{}) - var implErr *NotImplementedError - a.ErrorAs(err, &implErr) - } - { _, err := b.EditMessageCaption(ctx, oas.EditMessageCaption{}) var implErr *NotImplementedError @@ -152,24 +124,12 @@ func TestUnimplemented(t *testing.T) { a.ErrorAs(err, &implErr) } - { - _, err := b.ExportChatInviteLink(ctx, oas.ExportChatInviteLink{}) - var implErr *NotImplementedError - a.ErrorAs(err, &implErr) - } - { _, err := b.ForwardMessage(ctx, oas.ForwardMessage{}) var implErr *NotImplementedError a.ErrorAs(err, &implErr) } - { - _, err := b.GetChat(ctx, oas.GetChat{}) - var implErr *NotImplementedError - a.ErrorAs(err, &implErr) - } - { _, err := b.GetChatAdministrators(ctx, oas.GetChatAdministrators{}) var implErr *NotImplementedError @@ -206,12 +166,6 @@ func TestUnimplemented(t *testing.T) { a.ErrorAs(err, &implErr) } - { - _, err := b.GetUserProfilePhotos(ctx, oas.GetUserProfilePhotos{}) - var implErr *NotImplementedError - a.ErrorAs(err, &implErr) - } - { _, err := b.GetWebhookInfo(ctx) var implErr *NotImplementedError @@ -236,12 +190,6 @@ func TestUnimplemented(t *testing.T) { a.ErrorAs(err, &implErr) } - { - _, err := b.RevokeChatInviteLink(ctx, oas.RevokeChatInviteLink{}) - var implErr *NotImplementedError - a.ErrorAs(err, &implErr) - } - { _, err := b.SendAnimation(ctx, oas.SendAnimation{}) var implErr *NotImplementedError @@ -254,36 +202,18 @@ func TestUnimplemented(t *testing.T) { a.ErrorAs(err, &implErr) } - { - _, err := b.SendChatAction(ctx, oas.SendChatAction{}) - var implErr *NotImplementedError - a.ErrorAs(err, &implErr) - } - { _, err := b.SendContact(ctx, oas.SendContact{}) var implErr *NotImplementedError a.ErrorAs(err, &implErr) } - { - _, err := b.SendDice(ctx, oas.SendDice{}) - var implErr *NotImplementedError - a.ErrorAs(err, &implErr) - } - { _, err := b.SendDocument(ctx, oas.SendDocument{}) var implErr *NotImplementedError a.ErrorAs(err, &implErr) } - { - _, err := b.SendGame(ctx, oas.SendGame{}) - var implErr *NotImplementedError - a.ErrorAs(err, &implErr) - } - { _, err := b.SendInvoice(ctx, oas.SendInvoice{}) var implErr *NotImplementedError diff --git a/internal/botapi/user.go b/internal/botapi/user.go index 8f952c8..42b3d9e 100644 --- a/internal/botapi/user.go +++ b/internal/botapi/user.go @@ -3,10 +3,46 @@ package botapi import ( "context" + "github.com/go-faster/errors" + + "github.com/gotd/td/tg" + "github.com/gotd/botapi/internal/oas" ) // GetUserProfilePhotos implements oas.Handler. func (b *BotAPI) GetUserProfilePhotos(ctx context.Context, req oas.GetUserProfilePhotos) (oas.ResultUserProfilePhotos, error) { - return oas.ResultUserProfilePhotos{}, &NotImplementedError{} + userID, err := b.resolveUserID(ctx, req.UserID) + if err != nil { + return oas.ResultUserProfilePhotos{}, errors.Wrap(err, "resolve userID") + } + + response, err := b.raw.PhotosGetUserPhotos(ctx, &tg.PhotosGetUserPhotosRequest{ + UserID: userID.InputUser(), + Offset: req.Offset.Value, + Limit: req.Limit.Or(100), + }) + if err != nil { + return oas.ResultUserProfilePhotos{}, errors.Wrap(err, "get photos") + } + var totalCount int + switch response := response.(type) { + case *tg.PhotosPhotos: + totalCount = len(response.Photos) + case *tg.PhotosPhotosSlice: + totalCount = response.Count + } + + var photos [][]oas.PhotoSize + for _, p := range response.MapPhotos() { + photos = append(photos, b.convertToBotAPIPhotoSizes(p)) + } + + return oas.ResultUserProfilePhotos{ + Result: oas.NewOptUserProfilePhotos(oas.UserProfilePhotos{ + TotalCount: totalCount, + Photos: photos, + }), + Ok: true, + }, nil } diff --git a/internal/botapi/user_test.go b/internal/botapi/user_test.go new file mode 100644 index 0000000..11a88da --- /dev/null +++ b/internal/botapi/user_test.go @@ -0,0 +1,75 @@ +package botapi + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/gotd/td/tg" + "github.com/gotd/td/tgmock" + + "github.com/gotd/botapi/internal/oas" +) + +func TestBotAPI_GetUserProfilePhotos(t *testing.T) { + ctx := context.Background() + testWithCache(t, func(a *require.Assertions, mock *tgmock.Mock, api *BotAPI) { + mock.ExpectCall(&tg.PhotosGetUserPhotosRequest{ + UserID: &tg.InputUserSelf{}, + Offset: 1, + Limit: 100, + }).ThenResult(&tg.PhotosPhotosSlice{ + Count: 10, + Photos: []tg.PhotoClass{ + &tg.Photo{ + ID: 10, + AccessHash: 10, + Date: 10, + Sizes: []tg.PhotoSizeClass{ + &tg.PhotoSize{ + Type: "m", + W: 10, + H: 10, + Size: 10, + }, + }, + DCID: 2, + }, + &tg.Photo{ + ID: 10, + AccessHash: 10, + Date: 10, + Sizes: []tg.PhotoSizeClass{ + &tg.PhotoCachedSize{ + Type: "m", + W: 10, + H: 10, + Bytes: []byte("data"), + }, + }, + DCID: 2, + }, + }, + Users: nil, + }) + r, err := api.GetUserProfilePhotos(ctx, oas.GetUserProfilePhotos{ + UserID: testUser().ID, + Offset: oas.NewOptInt(1), + }) + a.NoError(err) + a.True(r.Result.Set) + val := r.Result.Value + + a.Equal(10, val.TotalCount) + a.Len(val.Photos, 2) + a.Len(val.Photos[0], 1) + a.Len(val.Photos[1], 1) + + f, s := val.Photos[0][0], val.Photos[1][0] + a.NotEmpty(f.FileID) + a.NotEmpty(s.FileID) + a.Equal(f.FileSize.Value, 10) + a.Equal(s.FileSize.Value, 4) + }) +} diff --git a/internal/guard_test.go b/internal/guard_test.go index 331fd40..df0b767 100644 --- a/internal/guard_test.go +++ b/internal/guard_test.go @@ -16,6 +16,7 @@ var _ interface { GetChatMember(context.Context, oas.GetChatMember) (oas.ResultChatMember, error) GetChatMemberCount(context.Context, oas.GetChatMemberCount) (oas.ResultInt, error) GetGameHighScores(context.Context, oas.GetGameHighScores) (oas.ResultArrayOfGameHighScore, error) + GetStickerSet(ctx context.Context, req oas.GetStickerSet) (oas.ResultStickerSet, error) GetMe(context.Context) (oas.ResultUser, error) GetMyCommands(context.Context, oas.OptGetMyCommands) (oas.ResultArrayOfBotCommand, error) GetUpdates(context.Context, oas.OptGetUpdates) (oas.ResultArrayOfUpdate, error) diff --git a/internal/oas/oas_cfg_gen.go b/internal/oas/oas_cfg_gen.go index 1c12d10..6886f51 100644 --- a/internal/oas/oas_cfg_gen.go +++ b/internal/oas/oas_cfg_gen.go @@ -92,9 +92,7 @@ func newConfig(opts ...Option) config { cfg := config{ TracerProvider: otel.GetTracerProvider(), MeterProvider: metric.NewNoopMeterProvider(), - Client: &http.Client{ - Timeout: time.Second * 15, - }, + Client: http.DefaultClient, } for _, opt := range opts { opt.apply(&cfg) diff --git a/internal/oas/oas_client_gen.go b/internal/oas/oas_client_gen.go index 613c936..fac0e8c 100644 --- a/internal/oas/oas_client_gen.go +++ b/internal/oas/oas_client_gen.go @@ -1860,7 +1860,7 @@ func (c *Client) GetChatMemberCount(ctx context.Context, request GetChatMemberCo // GetFile invokes getFile operation. // // POST /getFile -func (c *Client) GetFile(ctx context.Context, request GetFile) (res Result, err error) { +func (c *Client) GetFile(ctx context.Context, request GetFile) (res ResultFile, err error) { startTime := time.Now() ctx, span := c.cfg.Tracer.Start(ctx, `GetFile`, trace.WithAttributes(otelogen.OperationID(`getFile`)), @@ -2062,7 +2062,7 @@ func (c *Client) GetMyCommands(ctx context.Context, request OptGetMyCommands) (r // GetStickerSet invokes getStickerSet operation. // // POST /getStickerSet -func (c *Client) GetStickerSet(ctx context.Context, request GetStickerSet) (res Result, err error) { +func (c *Client) GetStickerSet(ctx context.Context, request GetStickerSet) (res ResultStickerSet, err error) { startTime := time.Now() ctx, span := c.cfg.Tracer.Start(ctx, `GetStickerSet`, trace.WithAttributes(otelogen.OperationID(`getStickerSet`)), diff --git a/internal/oas/oas_json_gen.go b/internal/oas/oas_json_gen.go index 18562f1..deaa4f8 100644 --- a/internal/oas/oas_json_gen.go +++ b/internal/oas/oas_json_gen.go @@ -1300,6 +1300,10 @@ func (s Chat) Encode(e *jx.Encoder) { e.FieldStart("location") s.Location.Encode(e) } + if s.AllMembersAreAdministrators.Set { + e.FieldStart("all_members_are_administrators") + s.AllMembersAreAdministrators.Encode(e) + } e.ObjEnd() } @@ -1412,6 +1416,11 @@ func (s *Chat) Decode(d *jx.Decoder) error { if err := s.Location.Decode(d); err != nil { return err } + case "all_members_are_administrators": + s.AllMembersAreAdministrators.Reset() + if err := s.AllMembersAreAdministrators.Decode(d); err != nil { + return err + } default: return d.Skip() } @@ -2634,7 +2643,7 @@ func (s *CopyMessage) Decode(d *jx.Decoder) error { } case "reply_markup": s.ReplyMarkup = nil - var elem CopyMessageReplyMarkup + var elem SendReplyMarkup if err := elem.Decode(d); err != nil { return err } @@ -2646,92 +2655,6 @@ func (s *CopyMessage) Decode(d *jx.Decoder) error { }) } -// Encode encodes CopyMessageReplyMarkup as json. -func (s CopyMessageReplyMarkup) Encode(e *jx.Encoder) { - switch s.Type { - case InlineKeyboardMarkupCopyMessageReplyMarkup: - s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupCopyMessageReplyMarkup: - s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveCopyMessageReplyMarkup: - s.ReplyKeyboardRemove.Encode(e) - case ForceReplyCopyMessageReplyMarkup: - s.ForceReply.Encode(e) - } -} - -// Decode decodes CopyMessageReplyMarkup from json. -func (s *CopyMessageReplyMarkup) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New(`invalid: unable to decode CopyMessageReplyMarkup to nil`) - } - // Sum type fields. - if d.Next() != jx.Object { - return errors.Errorf("unexpected json type %q", d.Next()) - } - var found bool - if err := d.Capture(func(d *jx.Decoder) error { - return d.ObjBytes(func(d *jx.Decoder, key []byte) error { - if found { - return d.Skip() - } - switch string(key) { - case "inline_keyboard": - found = true - s.Type = InlineKeyboardMarkupCopyMessageReplyMarkup - case "keyboard": - found = true - s.Type = ReplyKeyboardMarkupCopyMessageReplyMarkup - case "resize_keyboard": - found = true - s.Type = ReplyKeyboardMarkupCopyMessageReplyMarkup - case "one_time_keyboard": - found = true - s.Type = ReplyKeyboardMarkupCopyMessageReplyMarkup - case "remove_keyboard": - found = true - s.Type = ReplyKeyboardRemoveCopyMessageReplyMarkup - case "force_reply": - found = true - s.Type = ForceReplyCopyMessageReplyMarkup - case "input_field_placeholder": - found = true - s.Type = ForceReplyCopyMessageReplyMarkup - case "selective": - found = true - s.Type = ForceReplyCopyMessageReplyMarkup - } - return d.Skip() - }) - }); err != nil { - return errors.Wrap(err, "capture") - } - if !found { - return errors.New("unable to detect sum type variant") - } - switch s.Type { - case InlineKeyboardMarkupCopyMessageReplyMarkup: - if err := s.InlineKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardMarkupCopyMessageReplyMarkup: - if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardRemoveCopyMessageReplyMarkup: - if err := s.ReplyKeyboardRemove.Decode(d); err != nil { - return err - } - case ForceReplyCopyMessageReplyMarkup: - if err := s.ForceReply.Decode(d); err != nil { - return err - } - default: - return errors.Errorf("inferred invalid type: %s", s.Type) - } - return nil -} - // Encode implements json.Marshaler. func (s CreateChatInviteLink) Encode(e *jx.Encoder) { e.ObjStart() @@ -9706,6 +9629,18 @@ func (s Message) Encode(e *jx.Encoder) { e.FieldStart("reply_markup") s.ReplyMarkup.Encode(e) } + if s.NewChatMember.Set { + e.FieldStart("new_chat_member") + s.NewChatMember.Encode(e) + } + if s.NewChatParticipant.Set { + e.FieldStart("new_chat_participant") + s.NewChatParticipant.Encode(e) + } + if s.LeftChatParticipant.Set { + e.FieldStart("left_chat_participant") + s.LeftChatParticipant.Encode(e) + } e.ObjEnd() } @@ -10048,6 +9983,21 @@ func (s *Message) Decode(d *jx.Decoder) error { if err := s.ReplyMarkup.Decode(d); err != nil { return err } + case "new_chat_member": + s.NewChatMember.Reset() + if err := s.NewChatMember.Decode(d); err != nil { + return err + } + case "new_chat_participant": + s.NewChatParticipant.Reset() + if err := s.NewChatParticipant.Decode(d); err != nil { + return err + } + case "left_chat_participant": + s.LeftChatParticipant.Reset() + if err := s.LeftChatParticipant.Decode(d); err != nil { + return err + } default: return d.Skip() } @@ -11247,6 +11197,28 @@ func (o *OptSticker) Decode(d *jx.Decoder) error { } } +// Encode encodes StickerSet as json. +func (o OptStickerSet) Encode(e *jx.Encoder) { + o.Value.Encode(e) +} + +// Decode decodes StickerSet from json. +func (o *OptStickerSet) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New(`invalid: unable to decode OptStickerSet to nil`) + } + switch d.Next() { + case jx.Object: + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil + default: + return errors.Errorf(`unexpected type %q while reading OptStickerSet`, d.Next()) + } +} + // Encode encodes string as json. func (o OptString) Encode(e *jx.Encoder) { e.Str(string(o.Value)) @@ -13907,6 +13879,44 @@ func (s *ResultPoll) Decode(d *jx.Decoder) error { }) } +// Encode implements json.Marshaler. +func (s ResultStickerSet) Encode(e *jx.Encoder) { + e.ObjStart() + if s.Result.Set { + e.FieldStart("result") + s.Result.Encode(e) + } + + e.FieldStart("ok") + e.Bool(s.Ok) + e.ObjEnd() +} + +// Decode decodes ResultStickerSet from json. +func (s *ResultStickerSet) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New(`invalid: unable to decode ResultStickerSet to nil`) + } + return d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "result": + s.Result.Reset() + if err := s.Result.Decode(d); err != nil { + return err + } + case "ok": + v, err := d.Bool() + s.Ok = bool(v) + if err != nil { + return err + } + default: + return d.Skip() + } + return nil + }) +} + // Encode implements json.Marshaler. func (s ResultString) Encode(e *jx.Encoder) { e.ObjStart() @@ -14231,7 +14241,7 @@ func (s *SendAnimation) Decode(d *jx.Decoder) error { } case "reply_markup": s.ReplyMarkup = nil - var elem SendAnimationReplyMarkup + var elem SendReplyMarkup if err := elem.Decode(d); err != nil { return err } @@ -14243,92 +14253,6 @@ func (s *SendAnimation) Decode(d *jx.Decoder) error { }) } -// Encode encodes SendAnimationReplyMarkup as json. -func (s SendAnimationReplyMarkup) Encode(e *jx.Encoder) { - switch s.Type { - case InlineKeyboardMarkupSendAnimationReplyMarkup: - s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupSendAnimationReplyMarkup: - s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveSendAnimationReplyMarkup: - s.ReplyKeyboardRemove.Encode(e) - case ForceReplySendAnimationReplyMarkup: - s.ForceReply.Encode(e) - } -} - -// Decode decodes SendAnimationReplyMarkup from json. -func (s *SendAnimationReplyMarkup) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New(`invalid: unable to decode SendAnimationReplyMarkup to nil`) - } - // Sum type fields. - if d.Next() != jx.Object { - return errors.Errorf("unexpected json type %q", d.Next()) - } - var found bool - if err := d.Capture(func(d *jx.Decoder) error { - return d.ObjBytes(func(d *jx.Decoder, key []byte) error { - if found { - return d.Skip() - } - switch string(key) { - case "inline_keyboard": - found = true - s.Type = InlineKeyboardMarkupSendAnimationReplyMarkup - case "keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendAnimationReplyMarkup - case "resize_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendAnimationReplyMarkup - case "one_time_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendAnimationReplyMarkup - case "remove_keyboard": - found = true - s.Type = ReplyKeyboardRemoveSendAnimationReplyMarkup - case "force_reply": - found = true - s.Type = ForceReplySendAnimationReplyMarkup - case "input_field_placeholder": - found = true - s.Type = ForceReplySendAnimationReplyMarkup - case "selective": - found = true - s.Type = ForceReplySendAnimationReplyMarkup - } - return d.Skip() - }) - }); err != nil { - return errors.Wrap(err, "capture") - } - if !found { - return errors.New("unable to detect sum type variant") - } - switch s.Type { - case InlineKeyboardMarkupSendAnimationReplyMarkup: - if err := s.InlineKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardMarkupSendAnimationReplyMarkup: - if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardRemoveSendAnimationReplyMarkup: - if err := s.ReplyKeyboardRemove.Decode(d); err != nil { - return err - } - case ForceReplySendAnimationReplyMarkup: - if err := s.ForceReply.Decode(d); err != nil { - return err - } - default: - return errors.Errorf("inferred invalid type: %s", s.Type) - } - return nil -} - // Encode implements json.Marshaler. func (s SendAudio) Encode(e *jx.Encoder) { e.ObjStart() @@ -14465,7 +14389,7 @@ func (s *SendAudio) Decode(d *jx.Decoder) error { } case "reply_markup": s.ReplyMarkup = nil - var elem SendAudioReplyMarkup + var elem SendReplyMarkup if err := elem.Decode(d); err != nil { return err } @@ -14477,122 +14401,36 @@ func (s *SendAudio) Decode(d *jx.Decoder) error { }) } -// Encode encodes SendAudioReplyMarkup as json. -func (s SendAudioReplyMarkup) Encode(e *jx.Encoder) { - switch s.Type { - case InlineKeyboardMarkupSendAudioReplyMarkup: - s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupSendAudioReplyMarkup: - s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveSendAudioReplyMarkup: - s.ReplyKeyboardRemove.Encode(e) - case ForceReplySendAudioReplyMarkup: - s.ForceReply.Encode(e) - } +// Encode implements json.Marshaler. +func (s SendChatAction) Encode(e *jx.Encoder) { + e.ObjStart() + + e.FieldStart("chat_id") + s.ChatID.Encode(e) + + e.FieldStart("action") + e.Str(s.Action) + e.ObjEnd() } -// Decode decodes SendAudioReplyMarkup from json. -func (s *SendAudioReplyMarkup) Decode(d *jx.Decoder) error { +// Decode decodes SendChatAction from json. +func (s *SendChatAction) Decode(d *jx.Decoder) error { if s == nil { - return errors.New(`invalid: unable to decode SendAudioReplyMarkup to nil`) - } - // Sum type fields. - if d.Next() != jx.Object { - return errors.Errorf("unexpected json type %q", d.Next()) + return errors.New(`invalid: unable to decode SendChatAction to nil`) } - var found bool - if err := d.Capture(func(d *jx.Decoder) error { - return d.ObjBytes(func(d *jx.Decoder, key []byte) error { - if found { - return d.Skip() + return d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "chat_id": + if err := s.ChatID.Decode(d); err != nil { + return err } - switch string(key) { - case "inline_keyboard": - found = true - s.Type = InlineKeyboardMarkupSendAudioReplyMarkup - case "keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendAudioReplyMarkup - case "resize_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendAudioReplyMarkup - case "one_time_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendAudioReplyMarkup - case "remove_keyboard": - found = true - s.Type = ReplyKeyboardRemoveSendAudioReplyMarkup - case "force_reply": - found = true - s.Type = ForceReplySendAudioReplyMarkup - case "input_field_placeholder": - found = true - s.Type = ForceReplySendAudioReplyMarkup - case "selective": - found = true - s.Type = ForceReplySendAudioReplyMarkup + case "action": + v, err := d.Str() + s.Action = string(v) + if err != nil { + return err } - return d.Skip() - }) - }); err != nil { - return errors.Wrap(err, "capture") - } - if !found { - return errors.New("unable to detect sum type variant") - } - switch s.Type { - case InlineKeyboardMarkupSendAudioReplyMarkup: - if err := s.InlineKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardMarkupSendAudioReplyMarkup: - if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardRemoveSendAudioReplyMarkup: - if err := s.ReplyKeyboardRemove.Decode(d); err != nil { - return err - } - case ForceReplySendAudioReplyMarkup: - if err := s.ForceReply.Decode(d); err != nil { - return err - } - default: - return errors.Errorf("inferred invalid type: %s", s.Type) - } - return nil -} - -// Encode implements json.Marshaler. -func (s SendChatAction) Encode(e *jx.Encoder) { - e.ObjStart() - - e.FieldStart("chat_id") - s.ChatID.Encode(e) - - e.FieldStart("action") - e.Str(s.Action) - e.ObjEnd() -} - -// Decode decodes SendChatAction from json. -func (s *SendChatAction) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New(`invalid: unable to decode SendChatAction to nil`) - } - return d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "chat_id": - if err := s.ChatID.Decode(d); err != nil { - return err - } - case "action": - v, err := d.Str() - s.Action = string(v) - if err != nil { - return err - } - default: + default: return d.Skip() } return nil @@ -14688,7 +14526,7 @@ func (s *SendContact) Decode(d *jx.Decoder) error { } case "reply_markup": s.ReplyMarkup = nil - var elem SendContactReplyMarkup + var elem SendReplyMarkup if err := elem.Decode(d); err != nil { return err } @@ -14700,92 +14538,6 @@ func (s *SendContact) Decode(d *jx.Decoder) error { }) } -// Encode encodes SendContactReplyMarkup as json. -func (s SendContactReplyMarkup) Encode(e *jx.Encoder) { - switch s.Type { - case InlineKeyboardMarkupSendContactReplyMarkup: - s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupSendContactReplyMarkup: - s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveSendContactReplyMarkup: - s.ReplyKeyboardRemove.Encode(e) - case ForceReplySendContactReplyMarkup: - s.ForceReply.Encode(e) - } -} - -// Decode decodes SendContactReplyMarkup from json. -func (s *SendContactReplyMarkup) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New(`invalid: unable to decode SendContactReplyMarkup to nil`) - } - // Sum type fields. - if d.Next() != jx.Object { - return errors.Errorf("unexpected json type %q", d.Next()) - } - var found bool - if err := d.Capture(func(d *jx.Decoder) error { - return d.ObjBytes(func(d *jx.Decoder, key []byte) error { - if found { - return d.Skip() - } - switch string(key) { - case "inline_keyboard": - found = true - s.Type = InlineKeyboardMarkupSendContactReplyMarkup - case "keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendContactReplyMarkup - case "resize_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendContactReplyMarkup - case "one_time_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendContactReplyMarkup - case "remove_keyboard": - found = true - s.Type = ReplyKeyboardRemoveSendContactReplyMarkup - case "force_reply": - found = true - s.Type = ForceReplySendContactReplyMarkup - case "input_field_placeholder": - found = true - s.Type = ForceReplySendContactReplyMarkup - case "selective": - found = true - s.Type = ForceReplySendContactReplyMarkup - } - return d.Skip() - }) - }); err != nil { - return errors.Wrap(err, "capture") - } - if !found { - return errors.New("unable to detect sum type variant") - } - switch s.Type { - case InlineKeyboardMarkupSendContactReplyMarkup: - if err := s.InlineKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardMarkupSendContactReplyMarkup: - if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardRemoveSendContactReplyMarkup: - if err := s.ReplyKeyboardRemove.Decode(d); err != nil { - return err - } - case ForceReplySendContactReplyMarkup: - if err := s.ForceReply.Decode(d); err != nil { - return err - } - default: - return errors.Errorf("inferred invalid type: %s", s.Type) - } - return nil -} - // Encode implements json.Marshaler. func (s SendDice) Encode(e *jx.Encoder) { e.ObjStart() @@ -14848,7 +14600,7 @@ func (s *SendDice) Decode(d *jx.Decoder) error { } case "reply_markup": s.ReplyMarkup = nil - var elem SendDiceReplyMarkup + var elem SendReplyMarkup if err := elem.Decode(d); err != nil { return err } @@ -14860,92 +14612,6 @@ func (s *SendDice) Decode(d *jx.Decoder) error { }) } -// Encode encodes SendDiceReplyMarkup as json. -func (s SendDiceReplyMarkup) Encode(e *jx.Encoder) { - switch s.Type { - case InlineKeyboardMarkupSendDiceReplyMarkup: - s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupSendDiceReplyMarkup: - s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveSendDiceReplyMarkup: - s.ReplyKeyboardRemove.Encode(e) - case ForceReplySendDiceReplyMarkup: - s.ForceReply.Encode(e) - } -} - -// Decode decodes SendDiceReplyMarkup from json. -func (s *SendDiceReplyMarkup) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New(`invalid: unable to decode SendDiceReplyMarkup to nil`) - } - // Sum type fields. - if d.Next() != jx.Object { - return errors.Errorf("unexpected json type %q", d.Next()) - } - var found bool - if err := d.Capture(func(d *jx.Decoder) error { - return d.ObjBytes(func(d *jx.Decoder, key []byte) error { - if found { - return d.Skip() - } - switch string(key) { - case "inline_keyboard": - found = true - s.Type = InlineKeyboardMarkupSendDiceReplyMarkup - case "keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendDiceReplyMarkup - case "resize_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendDiceReplyMarkup - case "one_time_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendDiceReplyMarkup - case "remove_keyboard": - found = true - s.Type = ReplyKeyboardRemoveSendDiceReplyMarkup - case "force_reply": - found = true - s.Type = ForceReplySendDiceReplyMarkup - case "input_field_placeholder": - found = true - s.Type = ForceReplySendDiceReplyMarkup - case "selective": - found = true - s.Type = ForceReplySendDiceReplyMarkup - } - return d.Skip() - }) - }); err != nil { - return errors.Wrap(err, "capture") - } - if !found { - return errors.New("unable to detect sum type variant") - } - switch s.Type { - case InlineKeyboardMarkupSendDiceReplyMarkup: - if err := s.InlineKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardMarkupSendDiceReplyMarkup: - if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardRemoveSendDiceReplyMarkup: - if err := s.ReplyKeyboardRemove.Decode(d); err != nil { - return err - } - case ForceReplySendDiceReplyMarkup: - if err := s.ForceReply.Decode(d); err != nil { - return err - } - default: - return errors.Errorf("inferred invalid type: %s", s.Type) - } - return nil -} - // Encode implements json.Marshaler. func (s SendDocument) Encode(e *jx.Encoder) { e.ObjStart() @@ -15064,7 +14730,7 @@ func (s *SendDocument) Decode(d *jx.Decoder) error { } case "reply_markup": s.ReplyMarkup = nil - var elem SendDocumentReplyMarkup + var elem SendReplyMarkup if err := elem.Decode(d); err != nil { return err } @@ -15076,92 +14742,6 @@ func (s *SendDocument) Decode(d *jx.Decoder) error { }) } -// Encode encodes SendDocumentReplyMarkup as json. -func (s SendDocumentReplyMarkup) Encode(e *jx.Encoder) { - switch s.Type { - case InlineKeyboardMarkupSendDocumentReplyMarkup: - s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupSendDocumentReplyMarkup: - s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveSendDocumentReplyMarkup: - s.ReplyKeyboardRemove.Encode(e) - case ForceReplySendDocumentReplyMarkup: - s.ForceReply.Encode(e) - } -} - -// Decode decodes SendDocumentReplyMarkup from json. -func (s *SendDocumentReplyMarkup) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New(`invalid: unable to decode SendDocumentReplyMarkup to nil`) - } - // Sum type fields. - if d.Next() != jx.Object { - return errors.Errorf("unexpected json type %q", d.Next()) - } - var found bool - if err := d.Capture(func(d *jx.Decoder) error { - return d.ObjBytes(func(d *jx.Decoder, key []byte) error { - if found { - return d.Skip() - } - switch string(key) { - case "inline_keyboard": - found = true - s.Type = InlineKeyboardMarkupSendDocumentReplyMarkup - case "keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendDocumentReplyMarkup - case "resize_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendDocumentReplyMarkup - case "one_time_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendDocumentReplyMarkup - case "remove_keyboard": - found = true - s.Type = ReplyKeyboardRemoveSendDocumentReplyMarkup - case "force_reply": - found = true - s.Type = ForceReplySendDocumentReplyMarkup - case "input_field_placeholder": - found = true - s.Type = ForceReplySendDocumentReplyMarkup - case "selective": - found = true - s.Type = ForceReplySendDocumentReplyMarkup - } - return d.Skip() - }) - }); err != nil { - return errors.Wrap(err, "capture") - } - if !found { - return errors.New("unable to detect sum type variant") - } - switch s.Type { - case InlineKeyboardMarkupSendDocumentReplyMarkup: - if err := s.InlineKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardMarkupSendDocumentReplyMarkup: - if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardRemoveSendDocumentReplyMarkup: - if err := s.ReplyKeyboardRemove.Decode(d); err != nil { - return err - } - case ForceReplySendDocumentReplyMarkup: - if err := s.ForceReply.Decode(d); err != nil { - return err - } - default: - return errors.Errorf("inferred invalid type: %s", s.Type) - } - return nil -} - // Encode implements json.Marshaler. func (s SendGame) Encode(e *jx.Encoder) { e.ObjStart() @@ -15618,7 +15198,7 @@ func (s *SendLocation) Decode(d *jx.Decoder) error { } case "reply_markup": s.ReplyMarkup = nil - var elem SendLocationReplyMarkup + var elem SendReplyMarkup if err := elem.Decode(d); err != nil { return err } @@ -15630,95 +15210,9 @@ func (s *SendLocation) Decode(d *jx.Decoder) error { }) } -// Encode encodes SendLocationReplyMarkup as json. -func (s SendLocationReplyMarkup) Encode(e *jx.Encoder) { - switch s.Type { - case InlineKeyboardMarkupSendLocationReplyMarkup: - s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupSendLocationReplyMarkup: - s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveSendLocationReplyMarkup: - s.ReplyKeyboardRemove.Encode(e) - case ForceReplySendLocationReplyMarkup: - s.ForceReply.Encode(e) - } -} - -// Decode decodes SendLocationReplyMarkup from json. -func (s *SendLocationReplyMarkup) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New(`invalid: unable to decode SendLocationReplyMarkup to nil`) - } - // Sum type fields. - if d.Next() != jx.Object { - return errors.Errorf("unexpected json type %q", d.Next()) - } - var found bool - if err := d.Capture(func(d *jx.Decoder) error { - return d.ObjBytes(func(d *jx.Decoder, key []byte) error { - if found { - return d.Skip() - } - switch string(key) { - case "inline_keyboard": - found = true - s.Type = InlineKeyboardMarkupSendLocationReplyMarkup - case "keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendLocationReplyMarkup - case "resize_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendLocationReplyMarkup - case "one_time_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendLocationReplyMarkup - case "remove_keyboard": - found = true - s.Type = ReplyKeyboardRemoveSendLocationReplyMarkup - case "force_reply": - found = true - s.Type = ForceReplySendLocationReplyMarkup - case "input_field_placeholder": - found = true - s.Type = ForceReplySendLocationReplyMarkup - case "selective": - found = true - s.Type = ForceReplySendLocationReplyMarkup - } - return d.Skip() - }) - }); err != nil { - return errors.Wrap(err, "capture") - } - if !found { - return errors.New("unable to detect sum type variant") - } - switch s.Type { - case InlineKeyboardMarkupSendLocationReplyMarkup: - if err := s.InlineKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardMarkupSendLocationReplyMarkup: - if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardRemoveSendLocationReplyMarkup: - if err := s.ReplyKeyboardRemove.Decode(d); err != nil { - return err - } - case ForceReplySendLocationReplyMarkup: - if err := s.ForceReply.Decode(d); err != nil { - return err - } - default: - return errors.Errorf("inferred invalid type: %s", s.Type) - } - return nil -} - -// Encode implements json.Marshaler. -func (s SendMediaGroup) Encode(e *jx.Encoder) { - e.ObjStart() +// Encode implements json.Marshaler. +func (s SendMediaGroup) Encode(e *jx.Encoder) { + e.ObjStart() e.FieldStart("chat_id") s.ChatID.Encode(e) @@ -15973,7 +15467,7 @@ func (s *SendMessage) Decode(d *jx.Decoder) error { } case "reply_markup": s.ReplyMarkup = nil - var elem SendMessageReplyMarkup + var elem SendReplyMarkup if err := elem.Decode(d); err != nil { return err } @@ -15985,92 +15479,6 @@ func (s *SendMessage) Decode(d *jx.Decoder) error { }) } -// Encode encodes SendMessageReplyMarkup as json. -func (s SendMessageReplyMarkup) Encode(e *jx.Encoder) { - switch s.Type { - case InlineKeyboardMarkupSendMessageReplyMarkup: - s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupSendMessageReplyMarkup: - s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveSendMessageReplyMarkup: - s.ReplyKeyboardRemove.Encode(e) - case ForceReplySendMessageReplyMarkup: - s.ForceReply.Encode(e) - } -} - -// Decode decodes SendMessageReplyMarkup from json. -func (s *SendMessageReplyMarkup) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New(`invalid: unable to decode SendMessageReplyMarkup to nil`) - } - // Sum type fields. - if d.Next() != jx.Object { - return errors.Errorf("unexpected json type %q", d.Next()) - } - var found bool - if err := d.Capture(func(d *jx.Decoder) error { - return d.ObjBytes(func(d *jx.Decoder, key []byte) error { - if found { - return d.Skip() - } - switch string(key) { - case "inline_keyboard": - found = true - s.Type = InlineKeyboardMarkupSendMessageReplyMarkup - case "keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendMessageReplyMarkup - case "resize_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendMessageReplyMarkup - case "one_time_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendMessageReplyMarkup - case "remove_keyboard": - found = true - s.Type = ReplyKeyboardRemoveSendMessageReplyMarkup - case "force_reply": - found = true - s.Type = ForceReplySendMessageReplyMarkup - case "input_field_placeholder": - found = true - s.Type = ForceReplySendMessageReplyMarkup - case "selective": - found = true - s.Type = ForceReplySendMessageReplyMarkup - } - return d.Skip() - }) - }); err != nil { - return errors.Wrap(err, "capture") - } - if !found { - return errors.New("unable to detect sum type variant") - } - switch s.Type { - case InlineKeyboardMarkupSendMessageReplyMarkup: - if err := s.InlineKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardMarkupSendMessageReplyMarkup: - if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardRemoveSendMessageReplyMarkup: - if err := s.ReplyKeyboardRemove.Decode(d); err != nil { - return err - } - case ForceReplySendMessageReplyMarkup: - if err := s.ForceReply.Decode(d); err != nil { - return err - } - default: - return errors.Errorf("inferred invalid type: %s", s.Type) - } - return nil -} - // Encode implements json.Marshaler. func (s SendPhoto) Encode(e *jx.Encoder) { e.ObjStart() @@ -16171,7 +15579,7 @@ func (s *SendPhoto) Decode(d *jx.Decoder) error { } case "reply_markup": s.ReplyMarkup = nil - var elem SendPhotoReplyMarkup + var elem SendReplyMarkup if err := elem.Decode(d); err != nil { return err } @@ -16183,92 +15591,6 @@ func (s *SendPhoto) Decode(d *jx.Decoder) error { }) } -// Encode encodes SendPhotoReplyMarkup as json. -func (s SendPhotoReplyMarkup) Encode(e *jx.Encoder) { - switch s.Type { - case InlineKeyboardMarkupSendPhotoReplyMarkup: - s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupSendPhotoReplyMarkup: - s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveSendPhotoReplyMarkup: - s.ReplyKeyboardRemove.Encode(e) - case ForceReplySendPhotoReplyMarkup: - s.ForceReply.Encode(e) - } -} - -// Decode decodes SendPhotoReplyMarkup from json. -func (s *SendPhotoReplyMarkup) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New(`invalid: unable to decode SendPhotoReplyMarkup to nil`) - } - // Sum type fields. - if d.Next() != jx.Object { - return errors.Errorf("unexpected json type %q", d.Next()) - } - var found bool - if err := d.Capture(func(d *jx.Decoder) error { - return d.ObjBytes(func(d *jx.Decoder, key []byte) error { - if found { - return d.Skip() - } - switch string(key) { - case "inline_keyboard": - found = true - s.Type = InlineKeyboardMarkupSendPhotoReplyMarkup - case "keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendPhotoReplyMarkup - case "resize_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendPhotoReplyMarkup - case "one_time_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendPhotoReplyMarkup - case "remove_keyboard": - found = true - s.Type = ReplyKeyboardRemoveSendPhotoReplyMarkup - case "force_reply": - found = true - s.Type = ForceReplySendPhotoReplyMarkup - case "input_field_placeholder": - found = true - s.Type = ForceReplySendPhotoReplyMarkup - case "selective": - found = true - s.Type = ForceReplySendPhotoReplyMarkup - } - return d.Skip() - }) - }); err != nil { - return errors.Wrap(err, "capture") - } - if !found { - return errors.New("unable to detect sum type variant") - } - switch s.Type { - case InlineKeyboardMarkupSendPhotoReplyMarkup: - if err := s.InlineKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardMarkupSendPhotoReplyMarkup: - if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardRemoveSendPhotoReplyMarkup: - if err := s.ReplyKeyboardRemove.Decode(d); err != nil { - return err - } - case ForceReplySendPhotoReplyMarkup: - if err := s.ForceReply.Decode(d); err != nil { - return err - } - default: - return errors.Errorf("inferred invalid type: %s", s.Type) - } - return nil -} - // Encode implements json.Marshaler. func (s SendPoll) Encode(e *jx.Encoder) { e.ObjStart() @@ -16453,7 +15775,7 @@ func (s *SendPoll) Decode(d *jx.Decoder) error { } case "reply_markup": s.ReplyMarkup = nil - var elem SendPollReplyMarkup + var elem SendReplyMarkup if err := elem.Decode(d); err != nil { return err } @@ -16465,24 +15787,24 @@ func (s *SendPoll) Decode(d *jx.Decoder) error { }) } -// Encode encodes SendPollReplyMarkup as json. -func (s SendPollReplyMarkup) Encode(e *jx.Encoder) { +// Encode encodes SendReplyMarkup as json. +func (s SendReplyMarkup) Encode(e *jx.Encoder) { switch s.Type { - case InlineKeyboardMarkupSendPollReplyMarkup: + case InlineKeyboardMarkupSendReplyMarkup: s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupSendPollReplyMarkup: + case ReplyKeyboardMarkupSendReplyMarkup: s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveSendPollReplyMarkup: + case ReplyKeyboardRemoveSendReplyMarkup: s.ReplyKeyboardRemove.Encode(e) - case ForceReplySendPollReplyMarkup: + case ForceReplySendReplyMarkup: s.ForceReply.Encode(e) } } -// Decode decodes SendPollReplyMarkup from json. -func (s *SendPollReplyMarkup) Decode(d *jx.Decoder) error { +// Decode decodes SendReplyMarkup from json. +func (s *SendReplyMarkup) Decode(d *jx.Decoder) error { if s == nil { - return errors.New(`invalid: unable to decode SendPollReplyMarkup to nil`) + return errors.New(`invalid: unable to decode SendReplyMarkup to nil`) } // Sum type fields. if d.Next() != jx.Object { @@ -16497,28 +15819,28 @@ func (s *SendPollReplyMarkup) Decode(d *jx.Decoder) error { switch string(key) { case "inline_keyboard": found = true - s.Type = InlineKeyboardMarkupSendPollReplyMarkup + s.Type = InlineKeyboardMarkupSendReplyMarkup case "keyboard": found = true - s.Type = ReplyKeyboardMarkupSendPollReplyMarkup + s.Type = ReplyKeyboardMarkupSendReplyMarkup case "resize_keyboard": found = true - s.Type = ReplyKeyboardMarkupSendPollReplyMarkup + s.Type = ReplyKeyboardMarkupSendReplyMarkup case "one_time_keyboard": found = true - s.Type = ReplyKeyboardMarkupSendPollReplyMarkup + s.Type = ReplyKeyboardMarkupSendReplyMarkup case "remove_keyboard": found = true - s.Type = ReplyKeyboardRemoveSendPollReplyMarkup + s.Type = ReplyKeyboardRemoveSendReplyMarkup case "force_reply": found = true - s.Type = ForceReplySendPollReplyMarkup + s.Type = ForceReplySendReplyMarkup case "input_field_placeholder": found = true - s.Type = ForceReplySendPollReplyMarkup + s.Type = ForceReplySendReplyMarkup case "selective": found = true - s.Type = ForceReplySendPollReplyMarkup + s.Type = ForceReplySendReplyMarkup } return d.Skip() }) @@ -16529,19 +15851,19 @@ func (s *SendPollReplyMarkup) Decode(d *jx.Decoder) error { return errors.New("unable to detect sum type variant") } switch s.Type { - case InlineKeyboardMarkupSendPollReplyMarkup: + case InlineKeyboardMarkupSendReplyMarkup: if err := s.InlineKeyboardMarkup.Decode(d); err != nil { return err } - case ReplyKeyboardMarkupSendPollReplyMarkup: + case ReplyKeyboardMarkupSendReplyMarkup: if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { return err } - case ReplyKeyboardRemoveSendPollReplyMarkup: + case ReplyKeyboardRemoveSendReplyMarkup: if err := s.ReplyKeyboardRemove.Decode(d); err != nil { return err } - case ForceReplySendPollReplyMarkup: + case ForceReplySendReplyMarkup: if err := s.ForceReply.Decode(d); err != nil { return err } @@ -16613,7 +15935,7 @@ func (s *SendSticker) Decode(d *jx.Decoder) error { } case "reply_markup": s.ReplyMarkup = nil - var elem SendStickerReplyMarkup + var elem SendReplyMarkup if err := elem.Decode(d); err != nil { return err } @@ -16625,92 +15947,6 @@ func (s *SendSticker) Decode(d *jx.Decoder) error { }) } -// Encode encodes SendStickerReplyMarkup as json. -func (s SendStickerReplyMarkup) Encode(e *jx.Encoder) { - switch s.Type { - case InlineKeyboardMarkupSendStickerReplyMarkup: - s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupSendStickerReplyMarkup: - s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveSendStickerReplyMarkup: - s.ReplyKeyboardRemove.Encode(e) - case ForceReplySendStickerReplyMarkup: - s.ForceReply.Encode(e) - } -} - -// Decode decodes SendStickerReplyMarkup from json. -func (s *SendStickerReplyMarkup) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New(`invalid: unable to decode SendStickerReplyMarkup to nil`) - } - // Sum type fields. - if d.Next() != jx.Object { - return errors.Errorf("unexpected json type %q", d.Next()) - } - var found bool - if err := d.Capture(func(d *jx.Decoder) error { - return d.ObjBytes(func(d *jx.Decoder, key []byte) error { - if found { - return d.Skip() - } - switch string(key) { - case "inline_keyboard": - found = true - s.Type = InlineKeyboardMarkupSendStickerReplyMarkup - case "keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendStickerReplyMarkup - case "resize_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendStickerReplyMarkup - case "one_time_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendStickerReplyMarkup - case "remove_keyboard": - found = true - s.Type = ReplyKeyboardRemoveSendStickerReplyMarkup - case "force_reply": - found = true - s.Type = ForceReplySendStickerReplyMarkup - case "input_field_placeholder": - found = true - s.Type = ForceReplySendStickerReplyMarkup - case "selective": - found = true - s.Type = ForceReplySendStickerReplyMarkup - } - return d.Skip() - }) - }); err != nil { - return errors.Wrap(err, "capture") - } - if !found { - return errors.New("unable to detect sum type variant") - } - switch s.Type { - case InlineKeyboardMarkupSendStickerReplyMarkup: - if err := s.InlineKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardMarkupSendStickerReplyMarkup: - if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardRemoveSendStickerReplyMarkup: - if err := s.ReplyKeyboardRemove.Decode(d); err != nil { - return err - } - case ForceReplySendStickerReplyMarkup: - if err := s.ForceReply.Decode(d); err != nil { - return err - } - default: - return errors.Errorf("inferred invalid type: %s", s.Type) - } - return nil -} - // Encode implements json.Marshaler. func (s SendVenue) Encode(e *jx.Encoder) { e.ObjStart() @@ -16836,7 +16072,7 @@ func (s *SendVenue) Decode(d *jx.Decoder) error { } case "reply_markup": s.ReplyMarkup = nil - var elem SendVenueReplyMarkup + var elem SendReplyMarkup if err := elem.Decode(d); err != nil { return err } @@ -16848,92 +16084,6 @@ func (s *SendVenue) Decode(d *jx.Decoder) error { }) } -// Encode encodes SendVenueReplyMarkup as json. -func (s SendVenueReplyMarkup) Encode(e *jx.Encoder) { - switch s.Type { - case InlineKeyboardMarkupSendVenueReplyMarkup: - s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupSendVenueReplyMarkup: - s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveSendVenueReplyMarkup: - s.ReplyKeyboardRemove.Encode(e) - case ForceReplySendVenueReplyMarkup: - s.ForceReply.Encode(e) - } -} - -// Decode decodes SendVenueReplyMarkup from json. -func (s *SendVenueReplyMarkup) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New(`invalid: unable to decode SendVenueReplyMarkup to nil`) - } - // Sum type fields. - if d.Next() != jx.Object { - return errors.Errorf("unexpected json type %q", d.Next()) - } - var found bool - if err := d.Capture(func(d *jx.Decoder) error { - return d.ObjBytes(func(d *jx.Decoder, key []byte) error { - if found { - return d.Skip() - } - switch string(key) { - case "inline_keyboard": - found = true - s.Type = InlineKeyboardMarkupSendVenueReplyMarkup - case "keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendVenueReplyMarkup - case "resize_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendVenueReplyMarkup - case "one_time_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendVenueReplyMarkup - case "remove_keyboard": - found = true - s.Type = ReplyKeyboardRemoveSendVenueReplyMarkup - case "force_reply": - found = true - s.Type = ForceReplySendVenueReplyMarkup - case "input_field_placeholder": - found = true - s.Type = ForceReplySendVenueReplyMarkup - case "selective": - found = true - s.Type = ForceReplySendVenueReplyMarkup - } - return d.Skip() - }) - }); err != nil { - return errors.Wrap(err, "capture") - } - if !found { - return errors.New("unable to detect sum type variant") - } - switch s.Type { - case InlineKeyboardMarkupSendVenueReplyMarkup: - if err := s.InlineKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardMarkupSendVenueReplyMarkup: - if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardRemoveSendVenueReplyMarkup: - if err := s.ReplyKeyboardRemove.Decode(d); err != nil { - return err - } - case ForceReplySendVenueReplyMarkup: - if err := s.ForceReply.Decode(d); err != nil { - return err - } - default: - return errors.Errorf("inferred invalid type: %s", s.Type) - } - return nil -} - // Encode implements json.Marshaler. func (s SendVideo) Encode(e *jx.Encoder) { e.ObjStart() @@ -17079,7 +16229,7 @@ func (s *SendVideo) Decode(d *jx.Decoder) error { } case "reply_markup": s.ReplyMarkup = nil - var elem SendVideoReplyMarkup + var elem SendReplyMarkup if err := elem.Decode(d); err != nil { return err } @@ -17116,252 +16266,80 @@ func (s SendVideoNote) Encode(e *jx.Encoder) { e.FieldStart("disable_notification") s.DisableNotification.Encode(e) } - if s.ReplyToMessageID.Set { - e.FieldStart("reply_to_message_id") - s.ReplyToMessageID.Encode(e) - } - if s.AllowSendingWithoutReply.Set { - e.FieldStart("allow_sending_without_reply") - s.AllowSendingWithoutReply.Encode(e) - } - if s.ReplyMarkup != nil { - e.FieldStart("reply_markup") - s.ReplyMarkup.Encode(e) - } - e.ObjEnd() -} - -// Decode decodes SendVideoNote from json. -func (s *SendVideoNote) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New(`invalid: unable to decode SendVideoNote to nil`) - } - return d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "chat_id": - if err := s.ChatID.Decode(d); err != nil { - return err - } - case "video_note": - v, err := d.Str() - s.VideoNote = string(v) - if err != nil { - return err - } - case "duration": - s.Duration.Reset() - if err := s.Duration.Decode(d); err != nil { - return err - } - case "length": - s.Length.Reset() - if err := s.Length.Decode(d); err != nil { - return err - } - case "thumb": - s.Thumb.Reset() - if err := s.Thumb.Decode(d); err != nil { - return err - } - case "disable_notification": - s.DisableNotification.Reset() - if err := s.DisableNotification.Decode(d); err != nil { - return err - } - case "reply_to_message_id": - s.ReplyToMessageID.Reset() - if err := s.ReplyToMessageID.Decode(d); err != nil { - return err - } - case "allow_sending_without_reply": - s.AllowSendingWithoutReply.Reset() - if err := s.AllowSendingWithoutReply.Decode(d); err != nil { - return err - } - case "reply_markup": - s.ReplyMarkup = nil - var elem SendVideoNoteReplyMarkup - if err := elem.Decode(d); err != nil { - return err - } - s.ReplyMarkup = &elem - default: - return d.Skip() - } - return nil - }) -} - -// Encode encodes SendVideoNoteReplyMarkup as json. -func (s SendVideoNoteReplyMarkup) Encode(e *jx.Encoder) { - switch s.Type { - case InlineKeyboardMarkupSendVideoNoteReplyMarkup: - s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupSendVideoNoteReplyMarkup: - s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveSendVideoNoteReplyMarkup: - s.ReplyKeyboardRemove.Encode(e) - case ForceReplySendVideoNoteReplyMarkup: - s.ForceReply.Encode(e) - } -} - -// Decode decodes SendVideoNoteReplyMarkup from json. -func (s *SendVideoNoteReplyMarkup) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New(`invalid: unable to decode SendVideoNoteReplyMarkup to nil`) - } - // Sum type fields. - if d.Next() != jx.Object { - return errors.Errorf("unexpected json type %q", d.Next()) - } - var found bool - if err := d.Capture(func(d *jx.Decoder) error { - return d.ObjBytes(func(d *jx.Decoder, key []byte) error { - if found { - return d.Skip() - } - switch string(key) { - case "inline_keyboard": - found = true - s.Type = InlineKeyboardMarkupSendVideoNoteReplyMarkup - case "keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendVideoNoteReplyMarkup - case "resize_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendVideoNoteReplyMarkup - case "one_time_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendVideoNoteReplyMarkup - case "remove_keyboard": - found = true - s.Type = ReplyKeyboardRemoveSendVideoNoteReplyMarkup - case "force_reply": - found = true - s.Type = ForceReplySendVideoNoteReplyMarkup - case "input_field_placeholder": - found = true - s.Type = ForceReplySendVideoNoteReplyMarkup - case "selective": - found = true - s.Type = ForceReplySendVideoNoteReplyMarkup - } - return d.Skip() - }) - }); err != nil { - return errors.Wrap(err, "capture") - } - if !found { - return errors.New("unable to detect sum type variant") - } - switch s.Type { - case InlineKeyboardMarkupSendVideoNoteReplyMarkup: - if err := s.InlineKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardMarkupSendVideoNoteReplyMarkup: - if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardRemoveSendVideoNoteReplyMarkup: - if err := s.ReplyKeyboardRemove.Decode(d); err != nil { - return err - } - case ForceReplySendVideoNoteReplyMarkup: - if err := s.ForceReply.Decode(d); err != nil { - return err - } - default: - return errors.Errorf("inferred invalid type: %s", s.Type) + if s.ReplyToMessageID.Set { + e.FieldStart("reply_to_message_id") + s.ReplyToMessageID.Encode(e) } - return nil -} - -// Encode encodes SendVideoReplyMarkup as json. -func (s SendVideoReplyMarkup) Encode(e *jx.Encoder) { - switch s.Type { - case InlineKeyboardMarkupSendVideoReplyMarkup: - s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupSendVideoReplyMarkup: - s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveSendVideoReplyMarkup: - s.ReplyKeyboardRemove.Encode(e) - case ForceReplySendVideoReplyMarkup: - s.ForceReply.Encode(e) + if s.AllowSendingWithoutReply.Set { + e.FieldStart("allow_sending_without_reply") + s.AllowSendingWithoutReply.Encode(e) + } + if s.ReplyMarkup != nil { + e.FieldStart("reply_markup") + s.ReplyMarkup.Encode(e) } + e.ObjEnd() } -// Decode decodes SendVideoReplyMarkup from json. -func (s *SendVideoReplyMarkup) Decode(d *jx.Decoder) error { +// Decode decodes SendVideoNote from json. +func (s *SendVideoNote) Decode(d *jx.Decoder) error { if s == nil { - return errors.New(`invalid: unable to decode SendVideoReplyMarkup to nil`) - } - // Sum type fields. - if d.Next() != jx.Object { - return errors.Errorf("unexpected json type %q", d.Next()) + return errors.New(`invalid: unable to decode SendVideoNote to nil`) } - var found bool - if err := d.Capture(func(d *jx.Decoder) error { - return d.ObjBytes(func(d *jx.Decoder, key []byte) error { - if found { - return d.Skip() + return d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "chat_id": + if err := s.ChatID.Decode(d); err != nil { + return err } - switch string(key) { - case "inline_keyboard": - found = true - s.Type = InlineKeyboardMarkupSendVideoReplyMarkup - case "keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendVideoReplyMarkup - case "resize_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendVideoReplyMarkup - case "one_time_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendVideoReplyMarkup - case "remove_keyboard": - found = true - s.Type = ReplyKeyboardRemoveSendVideoReplyMarkup - case "force_reply": - found = true - s.Type = ForceReplySendVideoReplyMarkup - case "input_field_placeholder": - found = true - s.Type = ForceReplySendVideoReplyMarkup - case "selective": - found = true - s.Type = ForceReplySendVideoReplyMarkup + case "video_note": + v, err := d.Str() + s.VideoNote = string(v) + if err != nil { + return err + } + case "duration": + s.Duration.Reset() + if err := s.Duration.Decode(d); err != nil { + return err + } + case "length": + s.Length.Reset() + if err := s.Length.Decode(d); err != nil { + return err + } + case "thumb": + s.Thumb.Reset() + if err := s.Thumb.Decode(d); err != nil { + return err + } + case "disable_notification": + s.DisableNotification.Reset() + if err := s.DisableNotification.Decode(d); err != nil { + return err + } + case "reply_to_message_id": + s.ReplyToMessageID.Reset() + if err := s.ReplyToMessageID.Decode(d); err != nil { + return err + } + case "allow_sending_without_reply": + s.AllowSendingWithoutReply.Reset() + if err := s.AllowSendingWithoutReply.Decode(d); err != nil { + return err } + case "reply_markup": + s.ReplyMarkup = nil + var elem SendReplyMarkup + if err := elem.Decode(d); err != nil { + return err + } + s.ReplyMarkup = &elem + default: return d.Skip() - }) - }); err != nil { - return errors.Wrap(err, "capture") - } - if !found { - return errors.New("unable to detect sum type variant") - } - switch s.Type { - case InlineKeyboardMarkupSendVideoReplyMarkup: - if err := s.InlineKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardMarkupSendVideoReplyMarkup: - if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardRemoveSendVideoReplyMarkup: - if err := s.ReplyKeyboardRemove.Decode(d); err != nil { - return err - } - case ForceReplySendVideoReplyMarkup: - if err := s.ForceReply.Decode(d); err != nil { - return err } - default: - return errors.Errorf("inferred invalid type: %s", s.Type) - } - return nil + return nil + }) } // Encode implements json.Marshaler. @@ -17473,7 +16451,7 @@ func (s *SendVoice) Decode(d *jx.Decoder) error { } case "reply_markup": s.ReplyMarkup = nil - var elem SendVoiceReplyMarkup + var elem SendReplyMarkup if err := elem.Decode(d); err != nil { return err } @@ -17485,92 +16463,6 @@ func (s *SendVoice) Decode(d *jx.Decoder) error { }) } -// Encode encodes SendVoiceReplyMarkup as json. -func (s SendVoiceReplyMarkup) Encode(e *jx.Encoder) { - switch s.Type { - case InlineKeyboardMarkupSendVoiceReplyMarkup: - s.InlineKeyboardMarkup.Encode(e) - case ReplyKeyboardMarkupSendVoiceReplyMarkup: - s.ReplyKeyboardMarkup.Encode(e) - case ReplyKeyboardRemoveSendVoiceReplyMarkup: - s.ReplyKeyboardRemove.Encode(e) - case ForceReplySendVoiceReplyMarkup: - s.ForceReply.Encode(e) - } -} - -// Decode decodes SendVoiceReplyMarkup from json. -func (s *SendVoiceReplyMarkup) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New(`invalid: unable to decode SendVoiceReplyMarkup to nil`) - } - // Sum type fields. - if d.Next() != jx.Object { - return errors.Errorf("unexpected json type %q", d.Next()) - } - var found bool - if err := d.Capture(func(d *jx.Decoder) error { - return d.ObjBytes(func(d *jx.Decoder, key []byte) error { - if found { - return d.Skip() - } - switch string(key) { - case "inline_keyboard": - found = true - s.Type = InlineKeyboardMarkupSendVoiceReplyMarkup - case "keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendVoiceReplyMarkup - case "resize_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendVoiceReplyMarkup - case "one_time_keyboard": - found = true - s.Type = ReplyKeyboardMarkupSendVoiceReplyMarkup - case "remove_keyboard": - found = true - s.Type = ReplyKeyboardRemoveSendVoiceReplyMarkup - case "force_reply": - found = true - s.Type = ForceReplySendVoiceReplyMarkup - case "input_field_placeholder": - found = true - s.Type = ForceReplySendVoiceReplyMarkup - case "selective": - found = true - s.Type = ForceReplySendVoiceReplyMarkup - } - return d.Skip() - }) - }); err != nil { - return errors.Wrap(err, "capture") - } - if !found { - return errors.New("unable to detect sum type variant") - } - switch s.Type { - case InlineKeyboardMarkupSendVoiceReplyMarkup: - if err := s.InlineKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardMarkupSendVoiceReplyMarkup: - if err := s.ReplyKeyboardMarkup.Decode(d); err != nil { - return err - } - case ReplyKeyboardRemoveSendVoiceReplyMarkup: - if err := s.ReplyKeyboardRemove.Decode(d); err != nil { - return err - } - case ForceReplySendVoiceReplyMarkup: - if err := s.ForceReply.Decode(d); err != nil { - return err - } - default: - return errors.Errorf("inferred invalid type: %s", s.Type) - } - return nil -} - // Encode implements json.Marshaler. func (s SetChatAdministratorCustomTitle) Encode(e *jx.Encoder) { e.ObjStart() @@ -18449,6 +17341,90 @@ func (s *Sticker) Decode(d *jx.Decoder) error { }) } +// Encode implements json.Marshaler. +func (s StickerSet) Encode(e *jx.Encoder) { + e.ObjStart() + + e.FieldStart("name") + e.Str(s.Name) + + e.FieldStart("title") + e.Str(s.Title) + + e.FieldStart("is_animated") + e.Bool(s.IsAnimated) + + e.FieldStart("contains_masks") + e.Bool(s.ContainsMasks) + + e.FieldStart("stickers") + e.ArrStart() + for _, elem := range s.Stickers { + elem.Encode(e) + } + e.ArrEnd() + if s.Thumb.Set { + e.FieldStart("thumb") + s.Thumb.Encode(e) + } + e.ObjEnd() +} + +// Decode decodes StickerSet from json. +func (s *StickerSet) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New(`invalid: unable to decode StickerSet to nil`) + } + return d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "name": + v, err := d.Str() + s.Name = string(v) + if err != nil { + return err + } + case "title": + v, err := d.Str() + s.Title = string(v) + if err != nil { + return err + } + case "is_animated": + v, err := d.Bool() + s.IsAnimated = bool(v) + if err != nil { + return err + } + case "contains_masks": + v, err := d.Bool() + s.ContainsMasks = bool(v) + if err != nil { + return err + } + case "stickers": + s.Stickers = nil + if err := d.Arr(func(d *jx.Decoder) error { + var elem Sticker + if err := elem.Decode(d); err != nil { + return err + } + s.Stickers = append(s.Stickers, elem) + return nil + }); err != nil { + return err + } + case "thumb": + s.Thumb.Reset() + if err := s.Thumb.Decode(d); err != nil { + return err + } + default: + return d.Skip() + } + return nil + }) +} + // Encode implements json.Marshaler. func (s StopMessageLiveLocation) Encode(e *jx.Encoder) { e.ObjStart() diff --git a/internal/oas/oas_res_dec_gen.go b/internal/oas/oas_res_dec_gen.go index 0419172..734045d 100644 --- a/internal/oas/oas_res_dec_gen.go +++ b/internal/oas/oas_res_dec_gen.go @@ -2170,7 +2170,7 @@ func decodeGetChatMemberCountResponse(resp *http.Response, span trace.Span) (res } } -func decodeGetFileResponse(resp *http.Response, span trace.Span) (res Result, err error) { +func decodeGetFileResponse(resp *http.Response, span trace.Span) (res ResultFile, err error) { switch resp.StatusCode { case 200: switch resp.Header.Get("Content-Type") { @@ -2185,7 +2185,7 @@ func decodeGetFileResponse(resp *http.Response, span trace.Span) (res Result, er defer jx.PutDecoder(d) d.ResetBytes(buf.Bytes()) - var response Result + var response ResultFile if err := func() error { if err := response.Decode(d); err != nil { return err @@ -2442,7 +2442,7 @@ func decodeGetMyCommandsResponse(resp *http.Response, span trace.Span) (res Resu } } -func decodeGetStickerSetResponse(resp *http.Response, span trace.Span) (res Result, err error) { +func decodeGetStickerSetResponse(resp *http.Response, span trace.Span) (res ResultStickerSet, err error) { switch resp.StatusCode { case 200: switch resp.Header.Get("Content-Type") { @@ -2457,7 +2457,7 @@ func decodeGetStickerSetResponse(resp *http.Response, span trace.Span) (res Resu defer jx.PutDecoder(d) d.ResetBytes(buf.Bytes()) - var response Result + var response ResultStickerSet if err := func() error { if err := response.Decode(d); err != nil { return err diff --git a/internal/oas/oas_res_enc_gen.go b/internal/oas/oas_res_enc_gen.go index 019da59..7c4b5d5 100644 --- a/internal/oas/oas_res_enc_gen.go +++ b/internal/oas/oas_res_enc_gen.go @@ -496,7 +496,7 @@ func encodeGetChatMemberCountResponse(response ResultInt, w http.ResponseWriter, return nil } -func encodeGetFileResponse(response Result, w http.ResponseWriter, span trace.Span) error { +func encodeGetFileResponse(response ResultFile, w http.ResponseWriter, span trace.Span) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) e := jx.GetEncoder() @@ -552,7 +552,7 @@ func encodeGetMyCommandsResponse(response ResultArrayOfBotCommand, w http.Respon return nil } -func encodeGetStickerSetResponse(response Result, w http.ResponseWriter, span trace.Span) error { +func encodeGetStickerSetResponse(response ResultStickerSet, w http.ResponseWriter, span trace.Span) error { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) e := jx.GetEncoder() diff --git a/internal/oas/oas_router_gen.go b/internal/oas/oas_router_gen.go index 8a1d612..e896e89 100644 --- a/internal/oas/oas_router_gen.go +++ b/internal/oas/oas_router_gen.go @@ -66,7 +66,7 @@ func (s *Server) notFound(w http.ResponseWriter, r *http.Request) { http.NotFound(w, r) } -func skipSlash(p []byte) []byte { +func skipSlash(p string) string { if len(p) > 0 && p[0] == '/' { return p[1:] } @@ -74,9 +74,9 @@ func skipSlash(p []byte) []byte { } // nextElem return next path element from p and forwarded p. -func nextElem(p []byte) (elem, next []byte) { +func nextElem(p string) (elem, next string) { p = skipSlash(p) - idx := bytes.IndexByte(p, '/') + idx := strings.IndexByte(p, '/') if idx < 0 { idx = len(p) } @@ -86,14 +86,14 @@ func nextElem(p []byte) (elem, next []byte) { // ServeHTTP serves http request as defined by OpenAPI v3 specification, // calling handler that matches the path or returning not found error. func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { - p := []byte(r.URL.Path) + p := r.URL.Path if len(p) == 0 { s.notFound(w, r) return } var ( - elem []byte // current element, without slashes + elem string // current element, without slashes args map[string]string // lazily initialized ) @@ -102,7 +102,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { case "POST": // Root edge. elem, p = nextElem(p) - switch string(elem) { + switch elem { case "addStickerToSet": // -> 1 // POST /addStickerToSet s.handleAddStickerToSetRequest(args, w, r) diff --git a/internal/oas/oas_schemas_gen.go b/internal/oas/oas_schemas_gen.go index 9a80534..6a4e038 100644 --- a/internal/oas/oas_schemas_gen.go +++ b/internal/oas/oas_schemas_gen.go @@ -427,26 +427,27 @@ type CallbackQuery struct { // Ref: #/components/schemas/Chat type Chat struct { - ID int64 `json:"id"` - Type ChatType `json:"type"` - Title OptString `json:"title"` - Username OptString `json:"username"` - FirstName OptString `json:"first_name"` - LastName OptString `json:"last_name"` - Photo OptChatPhoto `json:"photo"` - Bio OptString `json:"bio"` - HasPrivateForwards OptBool `json:"has_private_forwards"` - Description OptString `json:"description"` - InviteLink OptString `json:"invite_link"` - PinnedMessage *Message `json:"pinned_message"` - Permissions OptChatPermissions `json:"permissions"` - SlowModeDelay OptInt `json:"slow_mode_delay"` - MessageAutoDeleteTime OptInt `json:"message_auto_delete_time"` - HasProtectedContent OptBool `json:"has_protected_content"` - StickerSetName OptString `json:"sticker_set_name"` - CanSetStickerSet OptBool `json:"can_set_sticker_set"` - LinkedChatID OptInt64 `json:"linked_chat_id"` - Location OptChatLocation `json:"location"` + ID int64 `json:"id"` + Type ChatType `json:"type"` + Title OptString `json:"title"` + Username OptString `json:"username"` + FirstName OptString `json:"first_name"` + LastName OptString `json:"last_name"` + Photo OptChatPhoto `json:"photo"` + Bio OptString `json:"bio"` + HasPrivateForwards OptBool `json:"has_private_forwards"` + Description OptString `json:"description"` + InviteLink OptString `json:"invite_link"` + PinnedMessage *Message `json:"pinned_message"` + Permissions OptChatPermissions `json:"permissions"` + SlowModeDelay OptInt `json:"slow_mode_delay"` + MessageAutoDeleteTime OptInt `json:"message_auto_delete_time"` + HasProtectedContent OptBool `json:"has_protected_content"` + StickerSetName OptString `json:"sticker_set_name"` + CanSetStickerSet OptBool `json:"can_set_sticker_set"` + LinkedChatID OptInt64 `json:"linked_chat_id"` + Location OptChatLocation `json:"location"` + AllMembersAreAdministrators OptBool `json:"all_members_are_administrators"` } // Ref: #/components/schemas/ChatInviteLink @@ -769,140 +770,16 @@ type Contact struct { // Ref: #/components/schemas/copyMessage type CopyMessage struct { - ChatID ID `json:"chat_id"` - FromChatID ID `json:"from_chat_id"` - MessageID int `json:"message_id"` - Caption OptString `json:"caption"` - ParseMode OptString `json:"parse_mode"` - CaptionEntities []MessageEntity `json:"caption_entities"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *CopyMessageReplyMarkup `json:"reply_markup"` -} - -// CopyMessageReplyMarkup represents sum type. -type CopyMessageReplyMarkup struct { - Type CopyMessageReplyMarkupType // switch on this field - InlineKeyboardMarkup InlineKeyboardMarkup - ReplyKeyboardMarkup ReplyKeyboardMarkup - ReplyKeyboardRemove ReplyKeyboardRemove - ForceReply ForceReply -} - -// CopyMessageReplyMarkupType is oneOf type of CopyMessageReplyMarkup. -type CopyMessageReplyMarkupType string - -// Possible values for CopyMessageReplyMarkupType. -const ( - InlineKeyboardMarkupCopyMessageReplyMarkup CopyMessageReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupCopyMessageReplyMarkup CopyMessageReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveCopyMessageReplyMarkup CopyMessageReplyMarkupType = "ReplyKeyboardRemove" - ForceReplyCopyMessageReplyMarkup CopyMessageReplyMarkupType = "ForceReply" -) - -// IsInlineKeyboardMarkup reports whether CopyMessageReplyMarkup is InlineKeyboardMarkup. -func (s CopyMessageReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupCopyMessageReplyMarkup -} - -// IsReplyKeyboardMarkup reports whether CopyMessageReplyMarkup is ReplyKeyboardMarkup. -func (s CopyMessageReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupCopyMessageReplyMarkup -} - -// IsReplyKeyboardRemove reports whether CopyMessageReplyMarkup is ReplyKeyboardRemove. -func (s CopyMessageReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveCopyMessageReplyMarkup -} - -// IsForceReply reports whether CopyMessageReplyMarkup is ForceReply. -func (s CopyMessageReplyMarkup) IsForceReply() bool { - return s.Type == ForceReplyCopyMessageReplyMarkup -} - -// SetInlineKeyboardMarkup sets CopyMessageReplyMarkup to InlineKeyboardMarkup. -func (s *CopyMessageReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupCopyMessageReplyMarkup - s.InlineKeyboardMarkup = v -} - -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if CopyMessageReplyMarkup is InlineKeyboardMarkup. -func (s CopyMessageReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { - if !s.IsInlineKeyboardMarkup() { - return v, false - } - return s.InlineKeyboardMarkup, true -} - -// NewInlineKeyboardMarkupCopyMessageReplyMarkup returns new CopyMessageReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupCopyMessageReplyMarkup(v InlineKeyboardMarkup) CopyMessageReplyMarkup { - var s CopyMessageReplyMarkup - s.SetInlineKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardMarkup sets CopyMessageReplyMarkup to ReplyKeyboardMarkup. -func (s *CopyMessageReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupCopyMessageReplyMarkup - s.ReplyKeyboardMarkup = v -} - -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if CopyMessageReplyMarkup is ReplyKeyboardMarkup. -func (s CopyMessageReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { - if !s.IsReplyKeyboardMarkup() { - return v, false - } - return s.ReplyKeyboardMarkup, true -} - -// NewReplyKeyboardMarkupCopyMessageReplyMarkup returns new CopyMessageReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupCopyMessageReplyMarkup(v ReplyKeyboardMarkup) CopyMessageReplyMarkup { - var s CopyMessageReplyMarkup - s.SetReplyKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardRemove sets CopyMessageReplyMarkup to ReplyKeyboardRemove. -func (s *CopyMessageReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveCopyMessageReplyMarkup - s.ReplyKeyboardRemove = v -} - -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if CopyMessageReplyMarkup is ReplyKeyboardRemove. -func (s CopyMessageReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { - if !s.IsReplyKeyboardRemove() { - return v, false - } - return s.ReplyKeyboardRemove, true -} - -// NewReplyKeyboardRemoveCopyMessageReplyMarkup returns new CopyMessageReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveCopyMessageReplyMarkup(v ReplyKeyboardRemove) CopyMessageReplyMarkup { - var s CopyMessageReplyMarkup - s.SetReplyKeyboardRemove(v) - return s -} - -// SetForceReply sets CopyMessageReplyMarkup to ForceReply. -func (s *CopyMessageReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplyCopyMessageReplyMarkup - s.ForceReply = v -} - -// GetForceReply returns ForceReply and true boolean if CopyMessageReplyMarkup is ForceReply. -func (s CopyMessageReplyMarkup) GetForceReply() (v ForceReply, ok bool) { - if !s.IsForceReply() { - return v, false - } - return s.ForceReply, true -} - -// NewForceReplyCopyMessageReplyMarkup returns new CopyMessageReplyMarkup from ForceReply. -func NewForceReplyCopyMessageReplyMarkup(v ForceReply) CopyMessageReplyMarkup { - var s CopyMessageReplyMarkup - s.SetForceReply(v) - return s + ChatID ID `json:"chat_id"` + FromChatID ID `json:"from_chat_id"` + MessageID int `json:"message_id"` + Caption OptString `json:"caption"` + ParseMode OptString `json:"parse_mode"` + CaptionEntities []MessageEntity `json:"caption_entities"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` } // Ref: #/components/schemas/createChatInviteLink @@ -2776,6 +2653,9 @@ type Message struct { VoiceChatEnded OptVoiceChatEnded `json:"voice_chat_ended"` VoiceChatParticipantsInvited OptVoiceChatParticipantsInvited `json:"voice_chat_participants_invited"` ReplyMarkup OptInlineKeyboardMarkup `json:"reply_markup"` + NewChatMember OptUser `json:"new_chat_member"` + NewChatParticipant OptUser `json:"new_chat_participant"` + LeftChatParticipant OptUser `json:"left_chat_participant"` } // Ref: #/components/schemas/MessageAutoDeleteTimerChanged @@ -2856,6 +2736,14 @@ func (o OptAnimation) Get() (v Animation, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptAnimation) Or(d Animation) Animation { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptAudio returns new OptAudio with value set to v. func NewOptAudio(v Audio) OptAudio { return OptAudio{ @@ -2894,6 +2782,14 @@ func (o OptAudio) Get() (v Audio, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptAudio) Or(d Audio) Audio { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptBool returns new OptBool with value set to v. func NewOptBool(v bool) OptBool { return OptBool{ @@ -2932,6 +2828,14 @@ func (o OptBool) Get() (v bool, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptBool) Or(d bool) bool { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptCallbackQuery returns new OptCallbackQuery with value set to v. func NewOptCallbackQuery(v CallbackQuery) OptCallbackQuery { return OptCallbackQuery{ @@ -2970,6 +2874,14 @@ func (o OptCallbackQuery) Get() (v CallbackQuery, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptCallbackQuery) Or(d CallbackQuery) CallbackQuery { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptChat returns new OptChat with value set to v. func NewOptChat(v Chat) OptChat { return OptChat{ @@ -3008,6 +2920,14 @@ func (o OptChat) Get() (v Chat, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptChat) Or(d Chat) Chat { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptChatInviteLink returns new OptChatInviteLink with value set to v. func NewOptChatInviteLink(v ChatInviteLink) OptChatInviteLink { return OptChatInviteLink{ @@ -3046,6 +2966,14 @@ func (o OptChatInviteLink) Get() (v ChatInviteLink, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptChatInviteLink) Or(d ChatInviteLink) ChatInviteLink { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptChatJoinRequest returns new OptChatJoinRequest with value set to v. func NewOptChatJoinRequest(v ChatJoinRequest) OptChatJoinRequest { return OptChatJoinRequest{ @@ -3084,6 +3012,14 @@ func (o OptChatJoinRequest) Get() (v ChatJoinRequest, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptChatJoinRequest) Or(d ChatJoinRequest) ChatJoinRequest { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptChatLocation returns new OptChatLocation with value set to v. func NewOptChatLocation(v ChatLocation) OptChatLocation { return OptChatLocation{ @@ -3122,6 +3058,14 @@ func (o OptChatLocation) Get() (v ChatLocation, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptChatLocation) Or(d ChatLocation) ChatLocation { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptChatMemberUpdated returns new OptChatMemberUpdated with value set to v. func NewOptChatMemberUpdated(v ChatMemberUpdated) OptChatMemberUpdated { return OptChatMemberUpdated{ @@ -3160,6 +3104,14 @@ func (o OptChatMemberUpdated) Get() (v ChatMemberUpdated, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptChatMemberUpdated) Or(d ChatMemberUpdated) ChatMemberUpdated { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptChatPermissions returns new OptChatPermissions with value set to v. func NewOptChatPermissions(v ChatPermissions) OptChatPermissions { return OptChatPermissions{ @@ -3198,6 +3150,14 @@ func (o OptChatPermissions) Get() (v ChatPermissions, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptChatPermissions) Or(d ChatPermissions) ChatPermissions { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptChatPhoto returns new OptChatPhoto with value set to v. func NewOptChatPhoto(v ChatPhoto) OptChatPhoto { return OptChatPhoto{ @@ -3236,6 +3196,14 @@ func (o OptChatPhoto) Get() (v ChatPhoto, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptChatPhoto) Or(d ChatPhoto) ChatPhoto { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptChosenInlineResult returns new OptChosenInlineResult with value set to v. func NewOptChosenInlineResult(v ChosenInlineResult) OptChosenInlineResult { return OptChosenInlineResult{ @@ -3274,6 +3242,14 @@ func (o OptChosenInlineResult) Get() (v ChosenInlineResult, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptChosenInlineResult) Or(d ChosenInlineResult) ChosenInlineResult { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptContact returns new OptContact with value set to v. func NewOptContact(v Contact) OptContact { return OptContact{ @@ -3312,6 +3288,14 @@ func (o OptContact) Get() (v Contact, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptContact) Or(d Contact) Contact { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptDeleteMyCommands returns new OptDeleteMyCommands with value set to v. func NewOptDeleteMyCommands(v DeleteMyCommands) OptDeleteMyCommands { return OptDeleteMyCommands{ @@ -3350,6 +3334,14 @@ func (o OptDeleteMyCommands) Get() (v DeleteMyCommands, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptDeleteMyCommands) Or(d DeleteMyCommands) DeleteMyCommands { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptDeleteWebhook returns new OptDeleteWebhook with value set to v. func NewOptDeleteWebhook(v DeleteWebhook) OptDeleteWebhook { return OptDeleteWebhook{ @@ -3388,6 +3380,14 @@ func (o OptDeleteWebhook) Get() (v DeleteWebhook, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptDeleteWebhook) Or(d DeleteWebhook) DeleteWebhook { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptDice returns new OptDice with value set to v. func NewOptDice(v Dice) OptDice { return OptDice{ @@ -3426,6 +3426,14 @@ func (o OptDice) Get() (v Dice, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptDice) Or(d Dice) Dice { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptDocument returns new OptDocument with value set to v. func NewOptDocument(v Document) OptDocument { return OptDocument{ @@ -3464,6 +3472,14 @@ func (o OptDocument) Get() (v Document, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptDocument) Or(d Document) Document { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptFile returns new OptFile with value set to v. func NewOptFile(v File) OptFile { return OptFile{ @@ -3502,6 +3518,14 @@ func (o OptFile) Get() (v File, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptFile) Or(d File) File { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptFloat64 returns new OptFloat64 with value set to v. func NewOptFloat64(v float64) OptFloat64 { return OptFloat64{ @@ -3540,6 +3564,14 @@ func (o OptFloat64) Get() (v float64, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptFloat64) Or(d float64) float64 { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptGame returns new OptGame with value set to v. func NewOptGame(v Game) OptGame { return OptGame{ @@ -3578,6 +3610,14 @@ func (o OptGame) Get() (v Game, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptGame) Or(d Game) Game { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptGetMyCommands returns new OptGetMyCommands with value set to v. func NewOptGetMyCommands(v GetMyCommands) OptGetMyCommands { return OptGetMyCommands{ @@ -3616,6 +3656,14 @@ func (o OptGetMyCommands) Get() (v GetMyCommands, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptGetMyCommands) Or(d GetMyCommands) GetMyCommands { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptGetUpdates returns new OptGetUpdates with value set to v. func NewOptGetUpdates(v GetUpdates) OptGetUpdates { return OptGetUpdates{ @@ -3654,6 +3702,14 @@ func (o OptGetUpdates) Get() (v GetUpdates, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptGetUpdates) Or(d GetUpdates) GetUpdates { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptInlineKeyboardMarkup returns new OptInlineKeyboardMarkup with value set to v. func NewOptInlineKeyboardMarkup(v InlineKeyboardMarkup) OptInlineKeyboardMarkup { return OptInlineKeyboardMarkup{ @@ -3692,6 +3748,14 @@ func (o OptInlineKeyboardMarkup) Get() (v InlineKeyboardMarkup, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptInlineKeyboardMarkup) Or(d InlineKeyboardMarkup) InlineKeyboardMarkup { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptInlineQuery returns new OptInlineQuery with value set to v. func NewOptInlineQuery(v InlineQuery) OptInlineQuery { return OptInlineQuery{ @@ -3730,6 +3794,14 @@ func (o OptInlineQuery) Get() (v InlineQuery, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptInlineQuery) Or(d InlineQuery) InlineQuery { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptInlineQueryChatType returns new OptInlineQueryChatType with value set to v. func NewOptInlineQueryChatType(v InlineQueryChatType) OptInlineQueryChatType { return OptInlineQueryChatType{ @@ -3768,6 +3840,14 @@ func (o OptInlineQueryChatType) Get() (v InlineQueryChatType, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptInlineQueryChatType) Or(d InlineQueryChatType) InlineQueryChatType { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptInt returns new OptInt with value set to v. func NewOptInt(v int) OptInt { return OptInt{ @@ -3806,6 +3886,14 @@ func (o OptInt) Get() (v int, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptInt) Or(d int) int { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptInt64 returns new OptInt64 with value set to v. func NewOptInt64(v int64) OptInt64 { return OptInt64{ @@ -3844,6 +3932,14 @@ func (o OptInt64) Get() (v int64, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptInt64) Or(d int64) int64 { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptInvoice returns new OptInvoice with value set to v. func NewOptInvoice(v Invoice) OptInvoice { return OptInvoice{ @@ -3882,6 +3978,14 @@ func (o OptInvoice) Get() (v Invoice, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptInvoice) Or(d Invoice) Invoice { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptKeyboardButtonPollType returns new OptKeyboardButtonPollType with value set to v. func NewOptKeyboardButtonPollType(v KeyboardButtonPollType) OptKeyboardButtonPollType { return OptKeyboardButtonPollType{ @@ -3920,6 +4024,14 @@ func (o OptKeyboardButtonPollType) Get() (v KeyboardButtonPollType, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptKeyboardButtonPollType) Or(d KeyboardButtonPollType) KeyboardButtonPollType { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptLocation returns new OptLocation with value set to v. func NewOptLocation(v Location) OptLocation { return OptLocation{ @@ -3958,6 +4070,14 @@ func (o OptLocation) Get() (v Location, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptLocation) Or(d Location) Location { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptLoginUrl returns new OptLoginUrl with value set to v. func NewOptLoginUrl(v LoginUrl) OptLoginUrl { return OptLoginUrl{ @@ -3996,6 +4116,14 @@ func (o OptLoginUrl) Get() (v LoginUrl, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptLoginUrl) Or(d LoginUrl) LoginUrl { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptMaskPosition returns new OptMaskPosition with value set to v. func NewOptMaskPosition(v MaskPosition) OptMaskPosition { return OptMaskPosition{ @@ -4034,6 +4162,14 @@ func (o OptMaskPosition) Get() (v MaskPosition, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptMaskPosition) Or(d MaskPosition) MaskPosition { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptMessage returns new OptMessage with value set to v. func NewOptMessage(v Message) OptMessage { return OptMessage{ @@ -4072,6 +4208,14 @@ func (o OptMessage) Get() (v Message, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptMessage) Or(d Message) Message { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptMessageAutoDeleteTimerChanged returns new OptMessageAutoDeleteTimerChanged with value set to v. func NewOptMessageAutoDeleteTimerChanged(v MessageAutoDeleteTimerChanged) OptMessageAutoDeleteTimerChanged { return OptMessageAutoDeleteTimerChanged{ @@ -4110,6 +4254,14 @@ func (o OptMessageAutoDeleteTimerChanged) Get() (v MessageAutoDeleteTimerChanged return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptMessageAutoDeleteTimerChanged) Or(d MessageAutoDeleteTimerChanged) MessageAutoDeleteTimerChanged { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptMessageId returns new OptMessageId with value set to v. func NewOptMessageId(v MessageId) OptMessageId { return OptMessageId{ @@ -4148,6 +4300,14 @@ func (o OptMessageId) Get() (v MessageId, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptMessageId) Or(d MessageId) MessageId { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptOrderInfo returns new OptOrderInfo with value set to v. func NewOptOrderInfo(v OrderInfo) OptOrderInfo { return OptOrderInfo{ @@ -4186,6 +4346,14 @@ func (o OptOrderInfo) Get() (v OrderInfo, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptOrderInfo) Or(d OrderInfo) OrderInfo { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptPassportData returns new OptPassportData with value set to v. func NewOptPassportData(v PassportData) OptPassportData { return OptPassportData{ @@ -4224,6 +4392,14 @@ func (o OptPassportData) Get() (v PassportData, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptPassportData) Or(d PassportData) PassportData { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptPassportFile returns new OptPassportFile with value set to v. func NewOptPassportFile(v PassportFile) OptPassportFile { return OptPassportFile{ @@ -4262,6 +4438,14 @@ func (o OptPassportFile) Get() (v PassportFile, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptPassportFile) Or(d PassportFile) PassportFile { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptPhotoSize returns new OptPhotoSize with value set to v. func NewOptPhotoSize(v PhotoSize) OptPhotoSize { return OptPhotoSize{ @@ -4300,6 +4484,14 @@ func (o OptPhotoSize) Get() (v PhotoSize, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptPhotoSize) Or(d PhotoSize) PhotoSize { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptPoll returns new OptPoll with value set to v. func NewOptPoll(v Poll) OptPoll { return OptPoll{ @@ -4338,6 +4530,14 @@ func (o OptPoll) Get() (v Poll, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptPoll) Or(d Poll) Poll { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptPollAnswer returns new OptPollAnswer with value set to v. func NewOptPollAnswer(v PollAnswer) OptPollAnswer { return OptPollAnswer{ @@ -4376,6 +4576,14 @@ func (o OptPollAnswer) Get() (v PollAnswer, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptPollAnswer) Or(d PollAnswer) PollAnswer { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptPreCheckoutQuery returns new OptPreCheckoutQuery with value set to v. func NewOptPreCheckoutQuery(v PreCheckoutQuery) OptPreCheckoutQuery { return OptPreCheckoutQuery{ @@ -4414,6 +4622,14 @@ func (o OptPreCheckoutQuery) Get() (v PreCheckoutQuery, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptPreCheckoutQuery) Or(d PreCheckoutQuery) PreCheckoutQuery { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptProximityAlertTriggered returns new OptProximityAlertTriggered with value set to v. func NewOptProximityAlertTriggered(v ProximityAlertTriggered) OptProximityAlertTriggered { return OptProximityAlertTriggered{ @@ -4452,6 +4668,14 @@ func (o OptProximityAlertTriggered) Get() (v ProximityAlertTriggered, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptProximityAlertTriggered) Or(d ProximityAlertTriggered) ProximityAlertTriggered { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptResponse returns new OptResponse with value set to v. func NewOptResponse(v Response) OptResponse { return OptResponse{ @@ -4490,6 +4714,14 @@ func (o OptResponse) Get() (v Response, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptResponse) Or(d Response) Response { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptShippingAddress returns new OptShippingAddress with value set to v. func NewOptShippingAddress(v ShippingAddress) OptShippingAddress { return OptShippingAddress{ @@ -4528,6 +4760,14 @@ func (o OptShippingAddress) Get() (v ShippingAddress, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptShippingAddress) Or(d ShippingAddress) ShippingAddress { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptShippingQuery returns new OptShippingQuery with value set to v. func NewOptShippingQuery(v ShippingQuery) OptShippingQuery { return OptShippingQuery{ @@ -4566,6 +4806,14 @@ func (o OptShippingQuery) Get() (v ShippingQuery, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptShippingQuery) Or(d ShippingQuery) ShippingQuery { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptSticker returns new OptSticker with value set to v. func NewOptSticker(v Sticker) OptSticker { return OptSticker{ @@ -4604,6 +4852,60 @@ func (o OptSticker) Get() (v Sticker, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptSticker) Or(d Sticker) Sticker { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptStickerSet returns new OptStickerSet with value set to v. +func NewOptStickerSet(v StickerSet) OptStickerSet { + return OptStickerSet{ + Value: v, + Set: true, + } +} + +// OptStickerSet is optional StickerSet. +type OptStickerSet struct { + Value StickerSet + Set bool +} + +// IsSet returns true if OptStickerSet was set. +func (o OptStickerSet) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptStickerSet) Reset() { + var v StickerSet + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptStickerSet) SetTo(v StickerSet) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptStickerSet) Get() (v StickerSet, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptStickerSet) Or(d StickerSet) StickerSet { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptString returns new OptString with value set to v. func NewOptString(v string) OptString { return OptString{ @@ -4642,6 +4944,14 @@ func (o OptString) Get() (v string, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptString) Or(d string) string { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptSuccessfulPayment returns new OptSuccessfulPayment with value set to v. func NewOptSuccessfulPayment(v SuccessfulPayment) OptSuccessfulPayment { return OptSuccessfulPayment{ @@ -4680,6 +4990,14 @@ func (o OptSuccessfulPayment) Get() (v SuccessfulPayment, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptSuccessfulPayment) Or(d SuccessfulPayment) SuccessfulPayment { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptUser returns new OptUser with value set to v. func NewOptUser(v User) OptUser { return OptUser{ @@ -4718,6 +5036,14 @@ func (o OptUser) Get() (v User, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptUser) Or(d User) User { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptUserProfilePhotos returns new OptUserProfilePhotos with value set to v. func NewOptUserProfilePhotos(v UserProfilePhotos) OptUserProfilePhotos { return OptUserProfilePhotos{ @@ -4756,6 +5082,14 @@ func (o OptUserProfilePhotos) Get() (v UserProfilePhotos, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptUserProfilePhotos) Or(d UserProfilePhotos) UserProfilePhotos { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptVenue returns new OptVenue with value set to v. func NewOptVenue(v Venue) OptVenue { return OptVenue{ @@ -4794,7 +5128,15 @@ func (o OptVenue) Get() (v Venue, ok bool) { return o.Value, true } -// NewOptVideo returns new OptVideo with value set to v. +// Or returns value if set, or given parameter if does not. +func (o OptVenue) Or(d Venue) Venue { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptVideo returns new OptVideo with value set to v. func NewOptVideo(v Video) OptVideo { return OptVideo{ Value: v, @@ -4832,6 +5174,14 @@ func (o OptVideo) Get() (v Video, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptVideo) Or(d Video) Video { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptVideoNote returns new OptVideoNote with value set to v. func NewOptVideoNote(v VideoNote) OptVideoNote { return OptVideoNote{ @@ -4870,6 +5220,14 @@ func (o OptVideoNote) Get() (v VideoNote, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptVideoNote) Or(d VideoNote) VideoNote { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptVoice returns new OptVoice with value set to v. func NewOptVoice(v Voice) OptVoice { return OptVoice{ @@ -4908,6 +5266,14 @@ func (o OptVoice) Get() (v Voice, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptVoice) Or(d Voice) Voice { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptVoiceChatEnded returns new OptVoiceChatEnded with value set to v. func NewOptVoiceChatEnded(v VoiceChatEnded) OptVoiceChatEnded { return OptVoiceChatEnded{ @@ -4946,6 +5312,14 @@ func (o OptVoiceChatEnded) Get() (v VoiceChatEnded, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptVoiceChatEnded) Or(d VoiceChatEnded) VoiceChatEnded { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptVoiceChatParticipantsInvited returns new OptVoiceChatParticipantsInvited with value set to v. func NewOptVoiceChatParticipantsInvited(v VoiceChatParticipantsInvited) OptVoiceChatParticipantsInvited { return OptVoiceChatParticipantsInvited{ @@ -4984,6 +5358,14 @@ func (o OptVoiceChatParticipantsInvited) Get() (v VoiceChatParticipantsInvited, return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptVoiceChatParticipantsInvited) Or(d VoiceChatParticipantsInvited) VoiceChatParticipantsInvited { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptVoiceChatScheduled returns new OptVoiceChatScheduled with value set to v. func NewOptVoiceChatScheduled(v VoiceChatScheduled) OptVoiceChatScheduled { return OptVoiceChatScheduled{ @@ -5022,6 +5404,14 @@ func (o OptVoiceChatScheduled) Get() (v VoiceChatScheduled, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptVoiceChatScheduled) Or(d VoiceChatScheduled) VoiceChatScheduled { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptWebhookInfo returns new OptWebhookInfo with value set to v. func NewOptWebhookInfo(v WebhookInfo) OptWebhookInfo { return OptWebhookInfo{ @@ -5060,6 +5450,14 @@ func (o OptWebhookInfo) Get() (v WebhookInfo, ok bool) { return o.Value, true } +// Or returns value if set, or given parameter if does not. +func (o OptWebhookInfo) Or(d WebhookInfo) WebhookInfo { + if v, ok := o.Get(); ok { + return v + } + return d +} + // Ref: #/components/schemas/OrderInfo type OrderInfo struct { Name OptString `json:"name"` @@ -5705,6 +6103,12 @@ type ResultPoll struct { Ok bool `json:"ok"` } +// Ref: #/components/schemas/ResultStickerSet +type ResultStickerSet struct { + Result OptStickerSet `json:"result"` + Ok bool `json:"ok"` +} + // Ref: #/components/schemas/ResultString type ResultString struct { Result OptString `json:"result"` @@ -5737,2134 +6141,535 @@ type RevokeChatInviteLink struct { // Ref: #/components/schemas/sendAnimation type SendAnimation struct { + ChatID ID `json:"chat_id"` + Animation string `json:"animation"` + Duration OptInt `json:"duration"` + Width OptInt `json:"width"` + Height OptInt `json:"height"` + Thumb OptString `json:"thumb"` + Caption OptString `json:"caption"` + ParseMode OptString `json:"parse_mode"` + CaptionEntities []MessageEntity `json:"caption_entities"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` +} + +// Ref: #/components/schemas/sendAudio +type SendAudio struct { + ChatID ID `json:"chat_id"` + Audio string `json:"audio"` + Caption OptString `json:"caption"` + ParseMode OptString `json:"parse_mode"` + CaptionEntities []MessageEntity `json:"caption_entities"` + Duration OptInt `json:"duration"` + Performer OptString `json:"performer"` + Title OptString `json:"title"` + Thumb OptString `json:"thumb"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` +} + +// Ref: #/components/schemas/sendChatAction +type SendChatAction struct { + ChatID ID `json:"chat_id"` + Action string `json:"action"` +} + +// Ref: #/components/schemas/sendContact +type SendContact struct { + ChatID ID `json:"chat_id"` + PhoneNumber string `json:"phone_number"` + FirstName string `json:"first_name"` + LastName OptString `json:"last_name"` + Vcard OptString `json:"vcard"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` +} + +// Ref: #/components/schemas/sendDice +type SendDice struct { + ChatID ID `json:"chat_id"` + Emoji OptString `json:"emoji"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` +} + +// Ref: #/components/schemas/sendDocument +type SendDocument struct { + ChatID ID `json:"chat_id"` + Document string `json:"document"` + Thumb OptString `json:"thumb"` + Caption OptString `json:"caption"` + ParseMode OptString `json:"parse_mode"` + CaptionEntities []MessageEntity `json:"caption_entities"` + DisableContentTypeDetection OptBool `json:"disable_content_type_detection"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` +} + +// Ref: #/components/schemas/sendGame +type SendGame struct { + ChatID int64 `json:"chat_id"` + GameShortName string `json:"game_short_name"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup OptInlineKeyboardMarkup `json:"reply_markup"` +} + +// Ref: #/components/schemas/sendInvoice +type SendInvoice struct { + ChatID ID `json:"chat_id"` + Title string `json:"title"` + Description string `json:"description"` + Payload string `json:"payload"` + ProviderToken string `json:"provider_token"` + Currency string `json:"currency"` + Prices []LabeledPrice `json:"prices"` + MaxTipAmount OptInt `json:"max_tip_amount"` + SuggestedTipAmounts []int `json:"suggested_tip_amounts"` + StartParameter OptString `json:"start_parameter"` + ProviderData OptString `json:"provider_data"` + PhotoURL OptString `json:"photo_url"` + PhotoSize OptInt `json:"photo_size"` + PhotoWidth OptInt `json:"photo_width"` + PhotoHeight OptInt `json:"photo_height"` + NeedName OptBool `json:"need_name"` + NeedPhoneNumber OptBool `json:"need_phone_number"` + NeedEmail OptBool `json:"need_email"` + NeedShippingAddress OptBool `json:"need_shipping_address"` + SendPhoneNumberToProvider OptBool `json:"send_phone_number_to_provider"` + SendEmailToProvider OptBool `json:"send_email_to_provider"` + IsFlexible OptBool `json:"is_flexible"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup OptInlineKeyboardMarkup `json:"reply_markup"` +} + +// Ref: #/components/schemas/sendLocation +type SendLocation struct { + ChatID ID `json:"chat_id"` + Latitude float64 `json:"latitude"` + Longitude float64 `json:"longitude"` + HorizontalAccuracy OptFloat64 `json:"horizontal_accuracy"` + LivePeriod OptInt `json:"live_period"` + Heading OptInt `json:"heading"` + ProximityAlertRadius OptInt `json:"proximity_alert_radius"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` +} + +// Ref: #/components/schemas/sendMediaGroup +type SendMediaGroup struct { ChatID ID `json:"chat_id"` - Animation string `json:"animation"` - Duration OptInt `json:"duration"` - Width OptInt `json:"width"` - Height OptInt `json:"height"` - Thumb OptString `json:"thumb"` - Caption OptString `json:"caption"` - ParseMode OptString `json:"parse_mode"` - CaptionEntities []MessageEntity `json:"caption_entities"` + Media []SendMediaGroupMediaItem `json:"media"` DisableNotification OptBool `json:"disable_notification"` ReplyToMessageID OptInt `json:"reply_to_message_id"` AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *SendAnimationReplyMarkup `json:"reply_markup"` } -// SendAnimationReplyMarkup represents sum type. -type SendAnimationReplyMarkup struct { - Type SendAnimationReplyMarkupType // switch on this field - InlineKeyboardMarkup InlineKeyboardMarkup - ReplyKeyboardMarkup ReplyKeyboardMarkup - ReplyKeyboardRemove ReplyKeyboardRemove - ForceReply ForceReply +// SendMediaGroupMediaItem represents sum type. +type SendMediaGroupMediaItem struct { + Type SendMediaGroupMediaItemType // switch on this field + InputMediaAudio InputMediaAudio + InputMediaDocument InputMediaDocument + InputMediaPhoto InputMediaPhoto + InputMediaVideo InputMediaVideo } -// SendAnimationReplyMarkupType is oneOf type of SendAnimationReplyMarkup. -type SendAnimationReplyMarkupType string +// SendMediaGroupMediaItemType is oneOf type of SendMediaGroupMediaItem. +type SendMediaGroupMediaItemType string -// Possible values for SendAnimationReplyMarkupType. +// Possible values for SendMediaGroupMediaItemType. const ( - InlineKeyboardMarkupSendAnimationReplyMarkup SendAnimationReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupSendAnimationReplyMarkup SendAnimationReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveSendAnimationReplyMarkup SendAnimationReplyMarkupType = "ReplyKeyboardRemove" - ForceReplySendAnimationReplyMarkup SendAnimationReplyMarkupType = "ForceReply" + InputMediaAudioSendMediaGroupMediaItem SendMediaGroupMediaItemType = "InputMediaAudio" + InputMediaDocumentSendMediaGroupMediaItem SendMediaGroupMediaItemType = "InputMediaDocument" + InputMediaPhotoSendMediaGroupMediaItem SendMediaGroupMediaItemType = "InputMediaPhoto" + InputMediaVideoSendMediaGroupMediaItem SendMediaGroupMediaItemType = "InputMediaVideo" ) -// IsInlineKeyboardMarkup reports whether SendAnimationReplyMarkup is InlineKeyboardMarkup. -func (s SendAnimationReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupSendAnimationReplyMarkup +// IsInputMediaAudio reports whether SendMediaGroupMediaItem is InputMediaAudio. +func (s SendMediaGroupMediaItem) IsInputMediaAudio() bool { + return s.Type == InputMediaAudioSendMediaGroupMediaItem } -// IsReplyKeyboardMarkup reports whether SendAnimationReplyMarkup is ReplyKeyboardMarkup. -func (s SendAnimationReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupSendAnimationReplyMarkup +// IsInputMediaDocument reports whether SendMediaGroupMediaItem is InputMediaDocument. +func (s SendMediaGroupMediaItem) IsInputMediaDocument() bool { + return s.Type == InputMediaDocumentSendMediaGroupMediaItem } -// IsReplyKeyboardRemove reports whether SendAnimationReplyMarkup is ReplyKeyboardRemove. -func (s SendAnimationReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveSendAnimationReplyMarkup +// IsInputMediaPhoto reports whether SendMediaGroupMediaItem is InputMediaPhoto. +func (s SendMediaGroupMediaItem) IsInputMediaPhoto() bool { + return s.Type == InputMediaPhotoSendMediaGroupMediaItem } -// IsForceReply reports whether SendAnimationReplyMarkup is ForceReply. -func (s SendAnimationReplyMarkup) IsForceReply() bool { - return s.Type == ForceReplySendAnimationReplyMarkup +// IsInputMediaVideo reports whether SendMediaGroupMediaItem is InputMediaVideo. +func (s SendMediaGroupMediaItem) IsInputMediaVideo() bool { + return s.Type == InputMediaVideoSendMediaGroupMediaItem } -// SetInlineKeyboardMarkup sets SendAnimationReplyMarkup to InlineKeyboardMarkup. -func (s *SendAnimationReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupSendAnimationReplyMarkup - s.InlineKeyboardMarkup = v +// SetInputMediaAudio sets SendMediaGroupMediaItem to InputMediaAudio. +func (s *SendMediaGroupMediaItem) SetInputMediaAudio(v InputMediaAudio) { + s.Type = InputMediaAudioSendMediaGroupMediaItem + s.InputMediaAudio = v } -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendAnimationReplyMarkup is InlineKeyboardMarkup. -func (s SendAnimationReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { - if !s.IsInlineKeyboardMarkup() { +// GetInputMediaAudio returns InputMediaAudio and true boolean if SendMediaGroupMediaItem is InputMediaAudio. +func (s SendMediaGroupMediaItem) GetInputMediaAudio() (v InputMediaAudio, ok bool) { + if !s.IsInputMediaAudio() { return v, false } - return s.InlineKeyboardMarkup, true + return s.InputMediaAudio, true } -// NewInlineKeyboardMarkupSendAnimationReplyMarkup returns new SendAnimationReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupSendAnimationReplyMarkup(v InlineKeyboardMarkup) SendAnimationReplyMarkup { - var s SendAnimationReplyMarkup - s.SetInlineKeyboardMarkup(v) +// NewInputMediaAudioSendMediaGroupMediaItem returns new SendMediaGroupMediaItem from InputMediaAudio. +func NewInputMediaAudioSendMediaGroupMediaItem(v InputMediaAudio) SendMediaGroupMediaItem { + var s SendMediaGroupMediaItem + s.SetInputMediaAudio(v) return s } -// SetReplyKeyboardMarkup sets SendAnimationReplyMarkup to ReplyKeyboardMarkup. -func (s *SendAnimationReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupSendAnimationReplyMarkup - s.ReplyKeyboardMarkup = v +// SetInputMediaDocument sets SendMediaGroupMediaItem to InputMediaDocument. +func (s *SendMediaGroupMediaItem) SetInputMediaDocument(v InputMediaDocument) { + s.Type = InputMediaDocumentSendMediaGroupMediaItem + s.InputMediaDocument = v } -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendAnimationReplyMarkup is ReplyKeyboardMarkup. -func (s SendAnimationReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { - if !s.IsReplyKeyboardMarkup() { +// GetInputMediaDocument returns InputMediaDocument and true boolean if SendMediaGroupMediaItem is InputMediaDocument. +func (s SendMediaGroupMediaItem) GetInputMediaDocument() (v InputMediaDocument, ok bool) { + if !s.IsInputMediaDocument() { return v, false } - return s.ReplyKeyboardMarkup, true + return s.InputMediaDocument, true } -// NewReplyKeyboardMarkupSendAnimationReplyMarkup returns new SendAnimationReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupSendAnimationReplyMarkup(v ReplyKeyboardMarkup) SendAnimationReplyMarkup { - var s SendAnimationReplyMarkup - s.SetReplyKeyboardMarkup(v) +// NewInputMediaDocumentSendMediaGroupMediaItem returns new SendMediaGroupMediaItem from InputMediaDocument. +func NewInputMediaDocumentSendMediaGroupMediaItem(v InputMediaDocument) SendMediaGroupMediaItem { + var s SendMediaGroupMediaItem + s.SetInputMediaDocument(v) return s } -// SetReplyKeyboardRemove sets SendAnimationReplyMarkup to ReplyKeyboardRemove. -func (s *SendAnimationReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveSendAnimationReplyMarkup - s.ReplyKeyboardRemove = v +// SetInputMediaPhoto sets SendMediaGroupMediaItem to InputMediaPhoto. +func (s *SendMediaGroupMediaItem) SetInputMediaPhoto(v InputMediaPhoto) { + s.Type = InputMediaPhotoSendMediaGroupMediaItem + s.InputMediaPhoto = v } -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendAnimationReplyMarkup is ReplyKeyboardRemove. -func (s SendAnimationReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { - if !s.IsReplyKeyboardRemove() { +// GetInputMediaPhoto returns InputMediaPhoto and true boolean if SendMediaGroupMediaItem is InputMediaPhoto. +func (s SendMediaGroupMediaItem) GetInputMediaPhoto() (v InputMediaPhoto, ok bool) { + if !s.IsInputMediaPhoto() { return v, false } - return s.ReplyKeyboardRemove, true + return s.InputMediaPhoto, true } -// NewReplyKeyboardRemoveSendAnimationReplyMarkup returns new SendAnimationReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveSendAnimationReplyMarkup(v ReplyKeyboardRemove) SendAnimationReplyMarkup { - var s SendAnimationReplyMarkup - s.SetReplyKeyboardRemove(v) +// NewInputMediaPhotoSendMediaGroupMediaItem returns new SendMediaGroupMediaItem from InputMediaPhoto. +func NewInputMediaPhotoSendMediaGroupMediaItem(v InputMediaPhoto) SendMediaGroupMediaItem { + var s SendMediaGroupMediaItem + s.SetInputMediaPhoto(v) return s } -// SetForceReply sets SendAnimationReplyMarkup to ForceReply. -func (s *SendAnimationReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplySendAnimationReplyMarkup - s.ForceReply = v +// SetInputMediaVideo sets SendMediaGroupMediaItem to InputMediaVideo. +func (s *SendMediaGroupMediaItem) SetInputMediaVideo(v InputMediaVideo) { + s.Type = InputMediaVideoSendMediaGroupMediaItem + s.InputMediaVideo = v } -// GetForceReply returns ForceReply and true boolean if SendAnimationReplyMarkup is ForceReply. -func (s SendAnimationReplyMarkup) GetForceReply() (v ForceReply, ok bool) { - if !s.IsForceReply() { +// GetInputMediaVideo returns InputMediaVideo and true boolean if SendMediaGroupMediaItem is InputMediaVideo. +func (s SendMediaGroupMediaItem) GetInputMediaVideo() (v InputMediaVideo, ok bool) { + if !s.IsInputMediaVideo() { return v, false } - return s.ForceReply, true + return s.InputMediaVideo, true } -// NewForceReplySendAnimationReplyMarkup returns new SendAnimationReplyMarkup from ForceReply. -func NewForceReplySendAnimationReplyMarkup(v ForceReply) SendAnimationReplyMarkup { - var s SendAnimationReplyMarkup - s.SetForceReply(v) +// NewInputMediaVideoSendMediaGroupMediaItem returns new SendMediaGroupMediaItem from InputMediaVideo. +func NewInputMediaVideoSendMediaGroupMediaItem(v InputMediaVideo) SendMediaGroupMediaItem { + var s SendMediaGroupMediaItem + s.SetInputMediaVideo(v) return s } -// Ref: #/components/schemas/sendAudio -type SendAudio struct { - ChatID ID `json:"chat_id"` - Audio string `json:"audio"` - Caption OptString `json:"caption"` - ParseMode OptString `json:"parse_mode"` - CaptionEntities []MessageEntity `json:"caption_entities"` - Duration OptInt `json:"duration"` - Performer OptString `json:"performer"` - Title OptString `json:"title"` - Thumb OptString `json:"thumb"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *SendAudioReplyMarkup `json:"reply_markup"` -} - -// SendAudioReplyMarkup represents sum type. -type SendAudioReplyMarkup struct { - Type SendAudioReplyMarkupType // switch on this field +// Ref: #/components/schemas/sendMessage +type SendMessage struct { + ChatID ID `json:"chat_id"` + Text string `json:"text"` + ParseMode OptString `json:"parse_mode"` + Entities []MessageEntity `json:"entities"` + DisableWebPagePreview OptBool `json:"disable_web_page_preview"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` +} + +// Ref: #/components/schemas/sendPhoto +type SendPhoto struct { + ChatID ID `json:"chat_id"` + Photo string `json:"photo"` + Caption OptString `json:"caption"` + ParseMode OptString `json:"parse_mode"` + CaptionEntities []MessageEntity `json:"caption_entities"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` +} + +// Ref: #/components/schemas/sendPoll +type SendPoll struct { + ChatID ID `json:"chat_id"` + Question string `json:"question"` + Options []string `json:"options"` + IsAnonymous OptBool `json:"is_anonymous"` + Type OptString `json:"type"` + AllowsMultipleAnswers OptBool `json:"allows_multiple_answers"` + CorrectOptionID OptInt `json:"correct_option_id"` + Explanation OptString `json:"explanation"` + ExplanationParseMode OptString `json:"explanation_parse_mode"` + ExplanationEntities []MessageEntity `json:"explanation_entities"` + OpenPeriod OptInt `json:"open_period"` + CloseDate OptInt `json:"close_date"` + IsClosed OptBool `json:"is_closed"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` +} + +// Ref: #/components/schemas/SendReplyMarkup +// SendReplyMarkup represents sum type. +type SendReplyMarkup struct { + Type SendReplyMarkupType // switch on this field InlineKeyboardMarkup InlineKeyboardMarkup ReplyKeyboardMarkup ReplyKeyboardMarkup ReplyKeyboardRemove ReplyKeyboardRemove ForceReply ForceReply } -// SendAudioReplyMarkupType is oneOf type of SendAudioReplyMarkup. -type SendAudioReplyMarkupType string +// SendReplyMarkupType is oneOf type of SendReplyMarkup. +type SendReplyMarkupType string -// Possible values for SendAudioReplyMarkupType. +// Possible values for SendReplyMarkupType. const ( - InlineKeyboardMarkupSendAudioReplyMarkup SendAudioReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupSendAudioReplyMarkup SendAudioReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveSendAudioReplyMarkup SendAudioReplyMarkupType = "ReplyKeyboardRemove" - ForceReplySendAudioReplyMarkup SendAudioReplyMarkupType = "ForceReply" + InlineKeyboardMarkupSendReplyMarkup SendReplyMarkupType = "InlineKeyboardMarkup" + ReplyKeyboardMarkupSendReplyMarkup SendReplyMarkupType = "ReplyKeyboardMarkup" + ReplyKeyboardRemoveSendReplyMarkup SendReplyMarkupType = "ReplyKeyboardRemove" + ForceReplySendReplyMarkup SendReplyMarkupType = "ForceReply" ) -// IsInlineKeyboardMarkup reports whether SendAudioReplyMarkup is InlineKeyboardMarkup. -func (s SendAudioReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupSendAudioReplyMarkup +// IsInlineKeyboardMarkup reports whether SendReplyMarkup is InlineKeyboardMarkup. +func (s SendReplyMarkup) IsInlineKeyboardMarkup() bool { + return s.Type == InlineKeyboardMarkupSendReplyMarkup } -// IsReplyKeyboardMarkup reports whether SendAudioReplyMarkup is ReplyKeyboardMarkup. -func (s SendAudioReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupSendAudioReplyMarkup +// IsReplyKeyboardMarkup reports whether SendReplyMarkup is ReplyKeyboardMarkup. +func (s SendReplyMarkup) IsReplyKeyboardMarkup() bool { + return s.Type == ReplyKeyboardMarkupSendReplyMarkup } -// IsReplyKeyboardRemove reports whether SendAudioReplyMarkup is ReplyKeyboardRemove. -func (s SendAudioReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveSendAudioReplyMarkup +// IsReplyKeyboardRemove reports whether SendReplyMarkup is ReplyKeyboardRemove. +func (s SendReplyMarkup) IsReplyKeyboardRemove() bool { + return s.Type == ReplyKeyboardRemoveSendReplyMarkup } -// IsForceReply reports whether SendAudioReplyMarkup is ForceReply. -func (s SendAudioReplyMarkup) IsForceReply() bool { return s.Type == ForceReplySendAudioReplyMarkup } +// IsForceReply reports whether SendReplyMarkup is ForceReply. +func (s SendReplyMarkup) IsForceReply() bool { return s.Type == ForceReplySendReplyMarkup } -// SetInlineKeyboardMarkup sets SendAudioReplyMarkup to InlineKeyboardMarkup. -func (s *SendAudioReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupSendAudioReplyMarkup +// SetInlineKeyboardMarkup sets SendReplyMarkup to InlineKeyboardMarkup. +func (s *SendReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { + s.Type = InlineKeyboardMarkupSendReplyMarkup s.InlineKeyboardMarkup = v } -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendAudioReplyMarkup is InlineKeyboardMarkup. -func (s SendAudioReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { +// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendReplyMarkup is InlineKeyboardMarkup. +func (s SendReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { if !s.IsInlineKeyboardMarkup() { return v, false } return s.InlineKeyboardMarkup, true } -// NewInlineKeyboardMarkupSendAudioReplyMarkup returns new SendAudioReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupSendAudioReplyMarkup(v InlineKeyboardMarkup) SendAudioReplyMarkup { - var s SendAudioReplyMarkup +// NewInlineKeyboardMarkupSendReplyMarkup returns new SendReplyMarkup from InlineKeyboardMarkup. +func NewInlineKeyboardMarkupSendReplyMarkup(v InlineKeyboardMarkup) SendReplyMarkup { + var s SendReplyMarkup s.SetInlineKeyboardMarkup(v) return s } -// SetReplyKeyboardMarkup sets SendAudioReplyMarkup to ReplyKeyboardMarkup. -func (s *SendAudioReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupSendAudioReplyMarkup +// SetReplyKeyboardMarkup sets SendReplyMarkup to ReplyKeyboardMarkup. +func (s *SendReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { + s.Type = ReplyKeyboardMarkupSendReplyMarkup s.ReplyKeyboardMarkup = v } -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendAudioReplyMarkup is ReplyKeyboardMarkup. -func (s SendAudioReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { +// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendReplyMarkup is ReplyKeyboardMarkup. +func (s SendReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { if !s.IsReplyKeyboardMarkup() { return v, false } return s.ReplyKeyboardMarkup, true } -// NewReplyKeyboardMarkupSendAudioReplyMarkup returns new SendAudioReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupSendAudioReplyMarkup(v ReplyKeyboardMarkup) SendAudioReplyMarkup { - var s SendAudioReplyMarkup +// NewReplyKeyboardMarkupSendReplyMarkup returns new SendReplyMarkup from ReplyKeyboardMarkup. +func NewReplyKeyboardMarkupSendReplyMarkup(v ReplyKeyboardMarkup) SendReplyMarkup { + var s SendReplyMarkup s.SetReplyKeyboardMarkup(v) return s } -// SetReplyKeyboardRemove sets SendAudioReplyMarkup to ReplyKeyboardRemove. -func (s *SendAudioReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveSendAudioReplyMarkup +// SetReplyKeyboardRemove sets SendReplyMarkup to ReplyKeyboardRemove. +func (s *SendReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { + s.Type = ReplyKeyboardRemoveSendReplyMarkup s.ReplyKeyboardRemove = v } -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendAudioReplyMarkup is ReplyKeyboardRemove. -func (s SendAudioReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { +// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendReplyMarkup is ReplyKeyboardRemove. +func (s SendReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { if !s.IsReplyKeyboardRemove() { return v, false } return s.ReplyKeyboardRemove, true } -// NewReplyKeyboardRemoveSendAudioReplyMarkup returns new SendAudioReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveSendAudioReplyMarkup(v ReplyKeyboardRemove) SendAudioReplyMarkup { - var s SendAudioReplyMarkup +// NewReplyKeyboardRemoveSendReplyMarkup returns new SendReplyMarkup from ReplyKeyboardRemove. +func NewReplyKeyboardRemoveSendReplyMarkup(v ReplyKeyboardRemove) SendReplyMarkup { + var s SendReplyMarkup s.SetReplyKeyboardRemove(v) return s } -// SetForceReply sets SendAudioReplyMarkup to ForceReply. -func (s *SendAudioReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplySendAudioReplyMarkup +// SetForceReply sets SendReplyMarkup to ForceReply. +func (s *SendReplyMarkup) SetForceReply(v ForceReply) { + s.Type = ForceReplySendReplyMarkup s.ForceReply = v } -// GetForceReply returns ForceReply and true boolean if SendAudioReplyMarkup is ForceReply. -func (s SendAudioReplyMarkup) GetForceReply() (v ForceReply, ok bool) { +// GetForceReply returns ForceReply and true boolean if SendReplyMarkup is ForceReply. +func (s SendReplyMarkup) GetForceReply() (v ForceReply, ok bool) { if !s.IsForceReply() { return v, false } return s.ForceReply, true } -// NewForceReplySendAudioReplyMarkup returns new SendAudioReplyMarkup from ForceReply. -func NewForceReplySendAudioReplyMarkup(v ForceReply) SendAudioReplyMarkup { - var s SendAudioReplyMarkup +// NewForceReplySendReplyMarkup returns new SendReplyMarkup from ForceReply. +func NewForceReplySendReplyMarkup(v ForceReply) SendReplyMarkup { + var s SendReplyMarkup s.SetForceReply(v) return s } -// Ref: #/components/schemas/sendChatAction -type SendChatAction struct { - ChatID ID `json:"chat_id"` - Action string `json:"action"` +// Ref: #/components/schemas/sendSticker +type SendSticker struct { + ChatID ID `json:"chat_id"` + Sticker string `json:"sticker"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` } -// Ref: #/components/schemas/sendContact -type SendContact struct { - ChatID ID `json:"chat_id"` - PhoneNumber string `json:"phone_number"` - FirstName string `json:"first_name"` - LastName OptString `json:"last_name"` - Vcard OptString `json:"vcard"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *SendContactReplyMarkup `json:"reply_markup"` +// Ref: #/components/schemas/sendVenue +type SendVenue struct { + ChatID ID `json:"chat_id"` + Latitude float64 `json:"latitude"` + Longitude float64 `json:"longitude"` + Title string `json:"title"` + Address string `json:"address"` + FoursquareID OptString `json:"foursquare_id"` + FoursquareType OptString `json:"foursquare_type"` + GooglePlaceID OptString `json:"google_place_id"` + GooglePlaceType OptString `json:"google_place_type"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` } -// SendContactReplyMarkup represents sum type. -type SendContactReplyMarkup struct { - Type SendContactReplyMarkupType // switch on this field - InlineKeyboardMarkup InlineKeyboardMarkup - ReplyKeyboardMarkup ReplyKeyboardMarkup - ReplyKeyboardRemove ReplyKeyboardRemove - ForceReply ForceReply +// Ref: #/components/schemas/sendVideo +type SendVideo struct { + ChatID ID `json:"chat_id"` + Video string `json:"video"` + Duration OptInt `json:"duration"` + Width OptInt `json:"width"` + Height OptInt `json:"height"` + Thumb OptString `json:"thumb"` + Caption OptString `json:"caption"` + ParseMode OptString `json:"parse_mode"` + CaptionEntities []MessageEntity `json:"caption_entities"` + SupportsStreaming OptBool `json:"supports_streaming"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` } -// SendContactReplyMarkupType is oneOf type of SendContactReplyMarkup. -type SendContactReplyMarkupType string - -// Possible values for SendContactReplyMarkupType. -const ( - InlineKeyboardMarkupSendContactReplyMarkup SendContactReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupSendContactReplyMarkup SendContactReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveSendContactReplyMarkup SendContactReplyMarkupType = "ReplyKeyboardRemove" - ForceReplySendContactReplyMarkup SendContactReplyMarkupType = "ForceReply" -) - -// IsInlineKeyboardMarkup reports whether SendContactReplyMarkup is InlineKeyboardMarkup. -func (s SendContactReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupSendContactReplyMarkup +// Ref: #/components/schemas/sendVideoNote +type SendVideoNote struct { + ChatID ID `json:"chat_id"` + VideoNote string `json:"video_note"` + Duration OptInt `json:"duration"` + Length OptInt `json:"length"` + Thumb OptString `json:"thumb"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` } -// IsReplyKeyboardMarkup reports whether SendContactReplyMarkup is ReplyKeyboardMarkup. -func (s SendContactReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupSendContactReplyMarkup +// Ref: #/components/schemas/sendVoice +type SendVoice struct { + ChatID ID `json:"chat_id"` + Voice string `json:"voice"` + Caption OptString `json:"caption"` + ParseMode OptString `json:"parse_mode"` + CaptionEntities []MessageEntity `json:"caption_entities"` + Duration OptInt `json:"duration"` + DisableNotification OptBool `json:"disable_notification"` + ReplyToMessageID OptInt `json:"reply_to_message_id"` + AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` + ReplyMarkup *SendReplyMarkup `json:"reply_markup"` } -// IsReplyKeyboardRemove reports whether SendContactReplyMarkup is ReplyKeyboardRemove. -func (s SendContactReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveSendContactReplyMarkup +// Ref: #/components/schemas/setChatAdministratorCustomTitle +type SetChatAdministratorCustomTitle struct { + ChatID ID `json:"chat_id"` + UserID int64 `json:"user_id"` + CustomTitle string `json:"custom_title"` } -// IsForceReply reports whether SendContactReplyMarkup is ForceReply. -func (s SendContactReplyMarkup) IsForceReply() bool { - return s.Type == ForceReplySendContactReplyMarkup +// Ref: #/components/schemas/setChatDescription +type SetChatDescription struct { + ChatID ID `json:"chat_id"` + Description OptString `json:"description"` } -// SetInlineKeyboardMarkup sets SendContactReplyMarkup to InlineKeyboardMarkup. -func (s *SendContactReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupSendContactReplyMarkup - s.InlineKeyboardMarkup = v +// Ref: #/components/schemas/setChatPermissions +type SetChatPermissions struct { + ChatID ID `json:"chat_id"` + Permissions ChatPermissions `json:"permissions"` } -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendContactReplyMarkup is InlineKeyboardMarkup. -func (s SendContactReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { - if !s.IsInlineKeyboardMarkup() { - return v, false - } - return s.InlineKeyboardMarkup, true -} - -// NewInlineKeyboardMarkupSendContactReplyMarkup returns new SendContactReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupSendContactReplyMarkup(v InlineKeyboardMarkup) SendContactReplyMarkup { - var s SendContactReplyMarkup - s.SetInlineKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardMarkup sets SendContactReplyMarkup to ReplyKeyboardMarkup. -func (s *SendContactReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupSendContactReplyMarkup - s.ReplyKeyboardMarkup = v -} - -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendContactReplyMarkup is ReplyKeyboardMarkup. -func (s SendContactReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { - if !s.IsReplyKeyboardMarkup() { - return v, false - } - return s.ReplyKeyboardMarkup, true -} - -// NewReplyKeyboardMarkupSendContactReplyMarkup returns new SendContactReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupSendContactReplyMarkup(v ReplyKeyboardMarkup) SendContactReplyMarkup { - var s SendContactReplyMarkup - s.SetReplyKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardRemove sets SendContactReplyMarkup to ReplyKeyboardRemove. -func (s *SendContactReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveSendContactReplyMarkup - s.ReplyKeyboardRemove = v -} - -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendContactReplyMarkup is ReplyKeyboardRemove. -func (s SendContactReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { - if !s.IsReplyKeyboardRemove() { - return v, false - } - return s.ReplyKeyboardRemove, true -} - -// NewReplyKeyboardRemoveSendContactReplyMarkup returns new SendContactReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveSendContactReplyMarkup(v ReplyKeyboardRemove) SendContactReplyMarkup { - var s SendContactReplyMarkup - s.SetReplyKeyboardRemove(v) - return s -} - -// SetForceReply sets SendContactReplyMarkup to ForceReply. -func (s *SendContactReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplySendContactReplyMarkup - s.ForceReply = v -} - -// GetForceReply returns ForceReply and true boolean if SendContactReplyMarkup is ForceReply. -func (s SendContactReplyMarkup) GetForceReply() (v ForceReply, ok bool) { - if !s.IsForceReply() { - return v, false - } - return s.ForceReply, true -} - -// NewForceReplySendContactReplyMarkup returns new SendContactReplyMarkup from ForceReply. -func NewForceReplySendContactReplyMarkup(v ForceReply) SendContactReplyMarkup { - var s SendContactReplyMarkup - s.SetForceReply(v) - return s -} - -// Ref: #/components/schemas/sendDice -type SendDice struct { - ChatID ID `json:"chat_id"` - Emoji OptString `json:"emoji"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *SendDiceReplyMarkup `json:"reply_markup"` -} - -// SendDiceReplyMarkup represents sum type. -type SendDiceReplyMarkup struct { - Type SendDiceReplyMarkupType // switch on this field - InlineKeyboardMarkup InlineKeyboardMarkup - ReplyKeyboardMarkup ReplyKeyboardMarkup - ReplyKeyboardRemove ReplyKeyboardRemove - ForceReply ForceReply -} - -// SendDiceReplyMarkupType is oneOf type of SendDiceReplyMarkup. -type SendDiceReplyMarkupType string - -// Possible values for SendDiceReplyMarkupType. -const ( - InlineKeyboardMarkupSendDiceReplyMarkup SendDiceReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupSendDiceReplyMarkup SendDiceReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveSendDiceReplyMarkup SendDiceReplyMarkupType = "ReplyKeyboardRemove" - ForceReplySendDiceReplyMarkup SendDiceReplyMarkupType = "ForceReply" -) - -// IsInlineKeyboardMarkup reports whether SendDiceReplyMarkup is InlineKeyboardMarkup. -func (s SendDiceReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupSendDiceReplyMarkup -} - -// IsReplyKeyboardMarkup reports whether SendDiceReplyMarkup is ReplyKeyboardMarkup. -func (s SendDiceReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupSendDiceReplyMarkup -} - -// IsReplyKeyboardRemove reports whether SendDiceReplyMarkup is ReplyKeyboardRemove. -func (s SendDiceReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveSendDiceReplyMarkup -} - -// IsForceReply reports whether SendDiceReplyMarkup is ForceReply. -func (s SendDiceReplyMarkup) IsForceReply() bool { return s.Type == ForceReplySendDiceReplyMarkup } - -// SetInlineKeyboardMarkup sets SendDiceReplyMarkup to InlineKeyboardMarkup. -func (s *SendDiceReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupSendDiceReplyMarkup - s.InlineKeyboardMarkup = v -} - -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendDiceReplyMarkup is InlineKeyboardMarkup. -func (s SendDiceReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { - if !s.IsInlineKeyboardMarkup() { - return v, false - } - return s.InlineKeyboardMarkup, true -} - -// NewInlineKeyboardMarkupSendDiceReplyMarkup returns new SendDiceReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupSendDiceReplyMarkup(v InlineKeyboardMarkup) SendDiceReplyMarkup { - var s SendDiceReplyMarkup - s.SetInlineKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardMarkup sets SendDiceReplyMarkup to ReplyKeyboardMarkup. -func (s *SendDiceReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupSendDiceReplyMarkup - s.ReplyKeyboardMarkup = v -} - -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendDiceReplyMarkup is ReplyKeyboardMarkup. -func (s SendDiceReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { - if !s.IsReplyKeyboardMarkup() { - return v, false - } - return s.ReplyKeyboardMarkup, true -} - -// NewReplyKeyboardMarkupSendDiceReplyMarkup returns new SendDiceReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupSendDiceReplyMarkup(v ReplyKeyboardMarkup) SendDiceReplyMarkup { - var s SendDiceReplyMarkup - s.SetReplyKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardRemove sets SendDiceReplyMarkup to ReplyKeyboardRemove. -func (s *SendDiceReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveSendDiceReplyMarkup - s.ReplyKeyboardRemove = v -} - -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendDiceReplyMarkup is ReplyKeyboardRemove. -func (s SendDiceReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { - if !s.IsReplyKeyboardRemove() { - return v, false - } - return s.ReplyKeyboardRemove, true -} - -// NewReplyKeyboardRemoveSendDiceReplyMarkup returns new SendDiceReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveSendDiceReplyMarkup(v ReplyKeyboardRemove) SendDiceReplyMarkup { - var s SendDiceReplyMarkup - s.SetReplyKeyboardRemove(v) - return s -} - -// SetForceReply sets SendDiceReplyMarkup to ForceReply. -func (s *SendDiceReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplySendDiceReplyMarkup - s.ForceReply = v -} - -// GetForceReply returns ForceReply and true boolean if SendDiceReplyMarkup is ForceReply. -func (s SendDiceReplyMarkup) GetForceReply() (v ForceReply, ok bool) { - if !s.IsForceReply() { - return v, false - } - return s.ForceReply, true -} - -// NewForceReplySendDiceReplyMarkup returns new SendDiceReplyMarkup from ForceReply. -func NewForceReplySendDiceReplyMarkup(v ForceReply) SendDiceReplyMarkup { - var s SendDiceReplyMarkup - s.SetForceReply(v) - return s -} - -// Ref: #/components/schemas/sendDocument -type SendDocument struct { - ChatID ID `json:"chat_id"` - Document string `json:"document"` - Thumb OptString `json:"thumb"` - Caption OptString `json:"caption"` - ParseMode OptString `json:"parse_mode"` - CaptionEntities []MessageEntity `json:"caption_entities"` - DisableContentTypeDetection OptBool `json:"disable_content_type_detection"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *SendDocumentReplyMarkup `json:"reply_markup"` -} - -// SendDocumentReplyMarkup represents sum type. -type SendDocumentReplyMarkup struct { - Type SendDocumentReplyMarkupType // switch on this field - InlineKeyboardMarkup InlineKeyboardMarkup - ReplyKeyboardMarkup ReplyKeyboardMarkup - ReplyKeyboardRemove ReplyKeyboardRemove - ForceReply ForceReply -} - -// SendDocumentReplyMarkupType is oneOf type of SendDocumentReplyMarkup. -type SendDocumentReplyMarkupType string - -// Possible values for SendDocumentReplyMarkupType. -const ( - InlineKeyboardMarkupSendDocumentReplyMarkup SendDocumentReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupSendDocumentReplyMarkup SendDocumentReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveSendDocumentReplyMarkup SendDocumentReplyMarkupType = "ReplyKeyboardRemove" - ForceReplySendDocumentReplyMarkup SendDocumentReplyMarkupType = "ForceReply" -) - -// IsInlineKeyboardMarkup reports whether SendDocumentReplyMarkup is InlineKeyboardMarkup. -func (s SendDocumentReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupSendDocumentReplyMarkup -} - -// IsReplyKeyboardMarkup reports whether SendDocumentReplyMarkup is ReplyKeyboardMarkup. -func (s SendDocumentReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupSendDocumentReplyMarkup -} - -// IsReplyKeyboardRemove reports whether SendDocumentReplyMarkup is ReplyKeyboardRemove. -func (s SendDocumentReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveSendDocumentReplyMarkup -} - -// IsForceReply reports whether SendDocumentReplyMarkup is ForceReply. -func (s SendDocumentReplyMarkup) IsForceReply() bool { - return s.Type == ForceReplySendDocumentReplyMarkup -} - -// SetInlineKeyboardMarkup sets SendDocumentReplyMarkup to InlineKeyboardMarkup. -func (s *SendDocumentReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupSendDocumentReplyMarkup - s.InlineKeyboardMarkup = v -} - -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendDocumentReplyMarkup is InlineKeyboardMarkup. -func (s SendDocumentReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { - if !s.IsInlineKeyboardMarkup() { - return v, false - } - return s.InlineKeyboardMarkup, true -} - -// NewInlineKeyboardMarkupSendDocumentReplyMarkup returns new SendDocumentReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupSendDocumentReplyMarkup(v InlineKeyboardMarkup) SendDocumentReplyMarkup { - var s SendDocumentReplyMarkup - s.SetInlineKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardMarkup sets SendDocumentReplyMarkup to ReplyKeyboardMarkup. -func (s *SendDocumentReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupSendDocumentReplyMarkup - s.ReplyKeyboardMarkup = v -} - -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendDocumentReplyMarkup is ReplyKeyboardMarkup. -func (s SendDocumentReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { - if !s.IsReplyKeyboardMarkup() { - return v, false - } - return s.ReplyKeyboardMarkup, true -} - -// NewReplyKeyboardMarkupSendDocumentReplyMarkup returns new SendDocumentReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupSendDocumentReplyMarkup(v ReplyKeyboardMarkup) SendDocumentReplyMarkup { - var s SendDocumentReplyMarkup - s.SetReplyKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardRemove sets SendDocumentReplyMarkup to ReplyKeyboardRemove. -func (s *SendDocumentReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveSendDocumentReplyMarkup - s.ReplyKeyboardRemove = v -} - -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendDocumentReplyMarkup is ReplyKeyboardRemove. -func (s SendDocumentReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { - if !s.IsReplyKeyboardRemove() { - return v, false - } - return s.ReplyKeyboardRemove, true -} - -// NewReplyKeyboardRemoveSendDocumentReplyMarkup returns new SendDocumentReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveSendDocumentReplyMarkup(v ReplyKeyboardRemove) SendDocumentReplyMarkup { - var s SendDocumentReplyMarkup - s.SetReplyKeyboardRemove(v) - return s -} - -// SetForceReply sets SendDocumentReplyMarkup to ForceReply. -func (s *SendDocumentReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplySendDocumentReplyMarkup - s.ForceReply = v -} - -// GetForceReply returns ForceReply and true boolean if SendDocumentReplyMarkup is ForceReply. -func (s SendDocumentReplyMarkup) GetForceReply() (v ForceReply, ok bool) { - if !s.IsForceReply() { - return v, false - } - return s.ForceReply, true -} - -// NewForceReplySendDocumentReplyMarkup returns new SendDocumentReplyMarkup from ForceReply. -func NewForceReplySendDocumentReplyMarkup(v ForceReply) SendDocumentReplyMarkup { - var s SendDocumentReplyMarkup - s.SetForceReply(v) - return s -} - -// Ref: #/components/schemas/sendGame -type SendGame struct { - ChatID int64 `json:"chat_id"` - GameShortName string `json:"game_short_name"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup OptInlineKeyboardMarkup `json:"reply_markup"` -} - -// Ref: #/components/schemas/sendInvoice -type SendInvoice struct { - ChatID ID `json:"chat_id"` - Title string `json:"title"` - Description string `json:"description"` - Payload string `json:"payload"` - ProviderToken string `json:"provider_token"` - Currency string `json:"currency"` - Prices []LabeledPrice `json:"prices"` - MaxTipAmount OptInt `json:"max_tip_amount"` - SuggestedTipAmounts []int `json:"suggested_tip_amounts"` - StartParameter OptString `json:"start_parameter"` - ProviderData OptString `json:"provider_data"` - PhotoURL OptString `json:"photo_url"` - PhotoSize OptInt `json:"photo_size"` - PhotoWidth OptInt `json:"photo_width"` - PhotoHeight OptInt `json:"photo_height"` - NeedName OptBool `json:"need_name"` - NeedPhoneNumber OptBool `json:"need_phone_number"` - NeedEmail OptBool `json:"need_email"` - NeedShippingAddress OptBool `json:"need_shipping_address"` - SendPhoneNumberToProvider OptBool `json:"send_phone_number_to_provider"` - SendEmailToProvider OptBool `json:"send_email_to_provider"` - IsFlexible OptBool `json:"is_flexible"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup OptInlineKeyboardMarkup `json:"reply_markup"` -} - -// Ref: #/components/schemas/sendLocation -type SendLocation struct { - ChatID ID `json:"chat_id"` - Latitude float64 `json:"latitude"` - Longitude float64 `json:"longitude"` - HorizontalAccuracy OptFloat64 `json:"horizontal_accuracy"` - LivePeriod OptInt `json:"live_period"` - Heading OptInt `json:"heading"` - ProximityAlertRadius OptInt `json:"proximity_alert_radius"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *SendLocationReplyMarkup `json:"reply_markup"` -} - -// SendLocationReplyMarkup represents sum type. -type SendLocationReplyMarkup struct { - Type SendLocationReplyMarkupType // switch on this field - InlineKeyboardMarkup InlineKeyboardMarkup - ReplyKeyboardMarkup ReplyKeyboardMarkup - ReplyKeyboardRemove ReplyKeyboardRemove - ForceReply ForceReply -} - -// SendLocationReplyMarkupType is oneOf type of SendLocationReplyMarkup. -type SendLocationReplyMarkupType string - -// Possible values for SendLocationReplyMarkupType. -const ( - InlineKeyboardMarkupSendLocationReplyMarkup SendLocationReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupSendLocationReplyMarkup SendLocationReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveSendLocationReplyMarkup SendLocationReplyMarkupType = "ReplyKeyboardRemove" - ForceReplySendLocationReplyMarkup SendLocationReplyMarkupType = "ForceReply" -) - -// IsInlineKeyboardMarkup reports whether SendLocationReplyMarkup is InlineKeyboardMarkup. -func (s SendLocationReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupSendLocationReplyMarkup -} - -// IsReplyKeyboardMarkup reports whether SendLocationReplyMarkup is ReplyKeyboardMarkup. -func (s SendLocationReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupSendLocationReplyMarkup -} - -// IsReplyKeyboardRemove reports whether SendLocationReplyMarkup is ReplyKeyboardRemove. -func (s SendLocationReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveSendLocationReplyMarkup -} - -// IsForceReply reports whether SendLocationReplyMarkup is ForceReply. -func (s SendLocationReplyMarkup) IsForceReply() bool { - return s.Type == ForceReplySendLocationReplyMarkup -} - -// SetInlineKeyboardMarkup sets SendLocationReplyMarkup to InlineKeyboardMarkup. -func (s *SendLocationReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupSendLocationReplyMarkup - s.InlineKeyboardMarkup = v -} - -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendLocationReplyMarkup is InlineKeyboardMarkup. -func (s SendLocationReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { - if !s.IsInlineKeyboardMarkup() { - return v, false - } - return s.InlineKeyboardMarkup, true -} - -// NewInlineKeyboardMarkupSendLocationReplyMarkup returns new SendLocationReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupSendLocationReplyMarkup(v InlineKeyboardMarkup) SendLocationReplyMarkup { - var s SendLocationReplyMarkup - s.SetInlineKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardMarkup sets SendLocationReplyMarkup to ReplyKeyboardMarkup. -func (s *SendLocationReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupSendLocationReplyMarkup - s.ReplyKeyboardMarkup = v -} - -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendLocationReplyMarkup is ReplyKeyboardMarkup. -func (s SendLocationReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { - if !s.IsReplyKeyboardMarkup() { - return v, false - } - return s.ReplyKeyboardMarkup, true -} - -// NewReplyKeyboardMarkupSendLocationReplyMarkup returns new SendLocationReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupSendLocationReplyMarkup(v ReplyKeyboardMarkup) SendLocationReplyMarkup { - var s SendLocationReplyMarkup - s.SetReplyKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardRemove sets SendLocationReplyMarkup to ReplyKeyboardRemove. -func (s *SendLocationReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveSendLocationReplyMarkup - s.ReplyKeyboardRemove = v -} - -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendLocationReplyMarkup is ReplyKeyboardRemove. -func (s SendLocationReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { - if !s.IsReplyKeyboardRemove() { - return v, false - } - return s.ReplyKeyboardRemove, true -} - -// NewReplyKeyboardRemoveSendLocationReplyMarkup returns new SendLocationReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveSendLocationReplyMarkup(v ReplyKeyboardRemove) SendLocationReplyMarkup { - var s SendLocationReplyMarkup - s.SetReplyKeyboardRemove(v) - return s -} - -// SetForceReply sets SendLocationReplyMarkup to ForceReply. -func (s *SendLocationReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplySendLocationReplyMarkup - s.ForceReply = v -} - -// GetForceReply returns ForceReply and true boolean if SendLocationReplyMarkup is ForceReply. -func (s SendLocationReplyMarkup) GetForceReply() (v ForceReply, ok bool) { - if !s.IsForceReply() { - return v, false - } - return s.ForceReply, true -} - -// NewForceReplySendLocationReplyMarkup returns new SendLocationReplyMarkup from ForceReply. -func NewForceReplySendLocationReplyMarkup(v ForceReply) SendLocationReplyMarkup { - var s SendLocationReplyMarkup - s.SetForceReply(v) - return s -} - -// Ref: #/components/schemas/sendMediaGroup -type SendMediaGroup struct { - ChatID ID `json:"chat_id"` - Media []SendMediaGroupMediaItem `json:"media"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` -} - -// SendMediaGroupMediaItem represents sum type. -type SendMediaGroupMediaItem struct { - Type SendMediaGroupMediaItemType // switch on this field - InputMediaAudio InputMediaAudio - InputMediaDocument InputMediaDocument - InputMediaPhoto InputMediaPhoto - InputMediaVideo InputMediaVideo -} - -// SendMediaGroupMediaItemType is oneOf type of SendMediaGroupMediaItem. -type SendMediaGroupMediaItemType string - -// Possible values for SendMediaGroupMediaItemType. -const ( - InputMediaAudioSendMediaGroupMediaItem SendMediaGroupMediaItemType = "InputMediaAudio" - InputMediaDocumentSendMediaGroupMediaItem SendMediaGroupMediaItemType = "InputMediaDocument" - InputMediaPhotoSendMediaGroupMediaItem SendMediaGroupMediaItemType = "InputMediaPhoto" - InputMediaVideoSendMediaGroupMediaItem SendMediaGroupMediaItemType = "InputMediaVideo" -) - -// IsInputMediaAudio reports whether SendMediaGroupMediaItem is InputMediaAudio. -func (s SendMediaGroupMediaItem) IsInputMediaAudio() bool { - return s.Type == InputMediaAudioSendMediaGroupMediaItem -} - -// IsInputMediaDocument reports whether SendMediaGroupMediaItem is InputMediaDocument. -func (s SendMediaGroupMediaItem) IsInputMediaDocument() bool { - return s.Type == InputMediaDocumentSendMediaGroupMediaItem -} - -// IsInputMediaPhoto reports whether SendMediaGroupMediaItem is InputMediaPhoto. -func (s SendMediaGroupMediaItem) IsInputMediaPhoto() bool { - return s.Type == InputMediaPhotoSendMediaGroupMediaItem -} - -// IsInputMediaVideo reports whether SendMediaGroupMediaItem is InputMediaVideo. -func (s SendMediaGroupMediaItem) IsInputMediaVideo() bool { - return s.Type == InputMediaVideoSendMediaGroupMediaItem -} - -// SetInputMediaAudio sets SendMediaGroupMediaItem to InputMediaAudio. -func (s *SendMediaGroupMediaItem) SetInputMediaAudio(v InputMediaAudio) { - s.Type = InputMediaAudioSendMediaGroupMediaItem - s.InputMediaAudio = v -} - -// GetInputMediaAudio returns InputMediaAudio and true boolean if SendMediaGroupMediaItem is InputMediaAudio. -func (s SendMediaGroupMediaItem) GetInputMediaAudio() (v InputMediaAudio, ok bool) { - if !s.IsInputMediaAudio() { - return v, false - } - return s.InputMediaAudio, true -} - -// NewInputMediaAudioSendMediaGroupMediaItem returns new SendMediaGroupMediaItem from InputMediaAudio. -func NewInputMediaAudioSendMediaGroupMediaItem(v InputMediaAudio) SendMediaGroupMediaItem { - var s SendMediaGroupMediaItem - s.SetInputMediaAudio(v) - return s -} - -// SetInputMediaDocument sets SendMediaGroupMediaItem to InputMediaDocument. -func (s *SendMediaGroupMediaItem) SetInputMediaDocument(v InputMediaDocument) { - s.Type = InputMediaDocumentSendMediaGroupMediaItem - s.InputMediaDocument = v -} - -// GetInputMediaDocument returns InputMediaDocument and true boolean if SendMediaGroupMediaItem is InputMediaDocument. -func (s SendMediaGroupMediaItem) GetInputMediaDocument() (v InputMediaDocument, ok bool) { - if !s.IsInputMediaDocument() { - return v, false - } - return s.InputMediaDocument, true -} - -// NewInputMediaDocumentSendMediaGroupMediaItem returns new SendMediaGroupMediaItem from InputMediaDocument. -func NewInputMediaDocumentSendMediaGroupMediaItem(v InputMediaDocument) SendMediaGroupMediaItem { - var s SendMediaGroupMediaItem - s.SetInputMediaDocument(v) - return s -} - -// SetInputMediaPhoto sets SendMediaGroupMediaItem to InputMediaPhoto. -func (s *SendMediaGroupMediaItem) SetInputMediaPhoto(v InputMediaPhoto) { - s.Type = InputMediaPhotoSendMediaGroupMediaItem - s.InputMediaPhoto = v -} - -// GetInputMediaPhoto returns InputMediaPhoto and true boolean if SendMediaGroupMediaItem is InputMediaPhoto. -func (s SendMediaGroupMediaItem) GetInputMediaPhoto() (v InputMediaPhoto, ok bool) { - if !s.IsInputMediaPhoto() { - return v, false - } - return s.InputMediaPhoto, true -} - -// NewInputMediaPhotoSendMediaGroupMediaItem returns new SendMediaGroupMediaItem from InputMediaPhoto. -func NewInputMediaPhotoSendMediaGroupMediaItem(v InputMediaPhoto) SendMediaGroupMediaItem { - var s SendMediaGroupMediaItem - s.SetInputMediaPhoto(v) - return s -} - -// SetInputMediaVideo sets SendMediaGroupMediaItem to InputMediaVideo. -func (s *SendMediaGroupMediaItem) SetInputMediaVideo(v InputMediaVideo) { - s.Type = InputMediaVideoSendMediaGroupMediaItem - s.InputMediaVideo = v -} - -// GetInputMediaVideo returns InputMediaVideo and true boolean if SendMediaGroupMediaItem is InputMediaVideo. -func (s SendMediaGroupMediaItem) GetInputMediaVideo() (v InputMediaVideo, ok bool) { - if !s.IsInputMediaVideo() { - return v, false - } - return s.InputMediaVideo, true -} - -// NewInputMediaVideoSendMediaGroupMediaItem returns new SendMediaGroupMediaItem from InputMediaVideo. -func NewInputMediaVideoSendMediaGroupMediaItem(v InputMediaVideo) SendMediaGroupMediaItem { - var s SendMediaGroupMediaItem - s.SetInputMediaVideo(v) - return s -} - -// Ref: #/components/schemas/sendMessage -type SendMessage struct { - ChatID ID `json:"chat_id"` - Text string `json:"text"` - ParseMode OptString `json:"parse_mode"` - Entities []MessageEntity `json:"entities"` - DisableWebPagePreview OptBool `json:"disable_web_page_preview"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *SendMessageReplyMarkup `json:"reply_markup"` -} - -// SendMessageReplyMarkup represents sum type. -type SendMessageReplyMarkup struct { - Type SendMessageReplyMarkupType // switch on this field - InlineKeyboardMarkup InlineKeyboardMarkup - ReplyKeyboardMarkup ReplyKeyboardMarkup - ReplyKeyboardRemove ReplyKeyboardRemove - ForceReply ForceReply -} - -// SendMessageReplyMarkupType is oneOf type of SendMessageReplyMarkup. -type SendMessageReplyMarkupType string - -// Possible values for SendMessageReplyMarkupType. -const ( - InlineKeyboardMarkupSendMessageReplyMarkup SendMessageReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupSendMessageReplyMarkup SendMessageReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveSendMessageReplyMarkup SendMessageReplyMarkupType = "ReplyKeyboardRemove" - ForceReplySendMessageReplyMarkup SendMessageReplyMarkupType = "ForceReply" -) - -// IsInlineKeyboardMarkup reports whether SendMessageReplyMarkup is InlineKeyboardMarkup. -func (s SendMessageReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupSendMessageReplyMarkup -} - -// IsReplyKeyboardMarkup reports whether SendMessageReplyMarkup is ReplyKeyboardMarkup. -func (s SendMessageReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupSendMessageReplyMarkup -} - -// IsReplyKeyboardRemove reports whether SendMessageReplyMarkup is ReplyKeyboardRemove. -func (s SendMessageReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveSendMessageReplyMarkup -} - -// IsForceReply reports whether SendMessageReplyMarkup is ForceReply. -func (s SendMessageReplyMarkup) IsForceReply() bool { - return s.Type == ForceReplySendMessageReplyMarkup -} - -// SetInlineKeyboardMarkup sets SendMessageReplyMarkup to InlineKeyboardMarkup. -func (s *SendMessageReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupSendMessageReplyMarkup - s.InlineKeyboardMarkup = v -} - -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendMessageReplyMarkup is InlineKeyboardMarkup. -func (s SendMessageReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { - if !s.IsInlineKeyboardMarkup() { - return v, false - } - return s.InlineKeyboardMarkup, true -} - -// NewInlineKeyboardMarkupSendMessageReplyMarkup returns new SendMessageReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupSendMessageReplyMarkup(v InlineKeyboardMarkup) SendMessageReplyMarkup { - var s SendMessageReplyMarkup - s.SetInlineKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardMarkup sets SendMessageReplyMarkup to ReplyKeyboardMarkup. -func (s *SendMessageReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupSendMessageReplyMarkup - s.ReplyKeyboardMarkup = v -} - -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendMessageReplyMarkup is ReplyKeyboardMarkup. -func (s SendMessageReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { - if !s.IsReplyKeyboardMarkup() { - return v, false - } - return s.ReplyKeyboardMarkup, true -} - -// NewReplyKeyboardMarkupSendMessageReplyMarkup returns new SendMessageReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupSendMessageReplyMarkup(v ReplyKeyboardMarkup) SendMessageReplyMarkup { - var s SendMessageReplyMarkup - s.SetReplyKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardRemove sets SendMessageReplyMarkup to ReplyKeyboardRemove. -func (s *SendMessageReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveSendMessageReplyMarkup - s.ReplyKeyboardRemove = v -} - -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendMessageReplyMarkup is ReplyKeyboardRemove. -func (s SendMessageReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { - if !s.IsReplyKeyboardRemove() { - return v, false - } - return s.ReplyKeyboardRemove, true -} - -// NewReplyKeyboardRemoveSendMessageReplyMarkup returns new SendMessageReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveSendMessageReplyMarkup(v ReplyKeyboardRemove) SendMessageReplyMarkup { - var s SendMessageReplyMarkup - s.SetReplyKeyboardRemove(v) - return s -} - -// SetForceReply sets SendMessageReplyMarkup to ForceReply. -func (s *SendMessageReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplySendMessageReplyMarkup - s.ForceReply = v -} - -// GetForceReply returns ForceReply and true boolean if SendMessageReplyMarkup is ForceReply. -func (s SendMessageReplyMarkup) GetForceReply() (v ForceReply, ok bool) { - if !s.IsForceReply() { - return v, false - } - return s.ForceReply, true -} - -// NewForceReplySendMessageReplyMarkup returns new SendMessageReplyMarkup from ForceReply. -func NewForceReplySendMessageReplyMarkup(v ForceReply) SendMessageReplyMarkup { - var s SendMessageReplyMarkup - s.SetForceReply(v) - return s -} - -// Ref: #/components/schemas/sendPhoto -type SendPhoto struct { - ChatID ID `json:"chat_id"` - Photo string `json:"photo"` - Caption OptString `json:"caption"` - ParseMode OptString `json:"parse_mode"` - CaptionEntities []MessageEntity `json:"caption_entities"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *SendPhotoReplyMarkup `json:"reply_markup"` -} - -// SendPhotoReplyMarkup represents sum type. -type SendPhotoReplyMarkup struct { - Type SendPhotoReplyMarkupType // switch on this field - InlineKeyboardMarkup InlineKeyboardMarkup - ReplyKeyboardMarkup ReplyKeyboardMarkup - ReplyKeyboardRemove ReplyKeyboardRemove - ForceReply ForceReply -} - -// SendPhotoReplyMarkupType is oneOf type of SendPhotoReplyMarkup. -type SendPhotoReplyMarkupType string - -// Possible values for SendPhotoReplyMarkupType. -const ( - InlineKeyboardMarkupSendPhotoReplyMarkup SendPhotoReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupSendPhotoReplyMarkup SendPhotoReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveSendPhotoReplyMarkup SendPhotoReplyMarkupType = "ReplyKeyboardRemove" - ForceReplySendPhotoReplyMarkup SendPhotoReplyMarkupType = "ForceReply" -) - -// IsInlineKeyboardMarkup reports whether SendPhotoReplyMarkup is InlineKeyboardMarkup. -func (s SendPhotoReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupSendPhotoReplyMarkup -} - -// IsReplyKeyboardMarkup reports whether SendPhotoReplyMarkup is ReplyKeyboardMarkup. -func (s SendPhotoReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupSendPhotoReplyMarkup -} - -// IsReplyKeyboardRemove reports whether SendPhotoReplyMarkup is ReplyKeyboardRemove. -func (s SendPhotoReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveSendPhotoReplyMarkup -} - -// IsForceReply reports whether SendPhotoReplyMarkup is ForceReply. -func (s SendPhotoReplyMarkup) IsForceReply() bool { return s.Type == ForceReplySendPhotoReplyMarkup } - -// SetInlineKeyboardMarkup sets SendPhotoReplyMarkup to InlineKeyboardMarkup. -func (s *SendPhotoReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupSendPhotoReplyMarkup - s.InlineKeyboardMarkup = v -} - -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendPhotoReplyMarkup is InlineKeyboardMarkup. -func (s SendPhotoReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { - if !s.IsInlineKeyboardMarkup() { - return v, false - } - return s.InlineKeyboardMarkup, true -} - -// NewInlineKeyboardMarkupSendPhotoReplyMarkup returns new SendPhotoReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupSendPhotoReplyMarkup(v InlineKeyboardMarkup) SendPhotoReplyMarkup { - var s SendPhotoReplyMarkup - s.SetInlineKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardMarkup sets SendPhotoReplyMarkup to ReplyKeyboardMarkup. -func (s *SendPhotoReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupSendPhotoReplyMarkup - s.ReplyKeyboardMarkup = v -} - -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendPhotoReplyMarkup is ReplyKeyboardMarkup. -func (s SendPhotoReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { - if !s.IsReplyKeyboardMarkup() { - return v, false - } - return s.ReplyKeyboardMarkup, true -} - -// NewReplyKeyboardMarkupSendPhotoReplyMarkup returns new SendPhotoReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupSendPhotoReplyMarkup(v ReplyKeyboardMarkup) SendPhotoReplyMarkup { - var s SendPhotoReplyMarkup - s.SetReplyKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardRemove sets SendPhotoReplyMarkup to ReplyKeyboardRemove. -func (s *SendPhotoReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveSendPhotoReplyMarkup - s.ReplyKeyboardRemove = v -} - -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendPhotoReplyMarkup is ReplyKeyboardRemove. -func (s SendPhotoReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { - if !s.IsReplyKeyboardRemove() { - return v, false - } - return s.ReplyKeyboardRemove, true -} - -// NewReplyKeyboardRemoveSendPhotoReplyMarkup returns new SendPhotoReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveSendPhotoReplyMarkup(v ReplyKeyboardRemove) SendPhotoReplyMarkup { - var s SendPhotoReplyMarkup - s.SetReplyKeyboardRemove(v) - return s -} - -// SetForceReply sets SendPhotoReplyMarkup to ForceReply. -func (s *SendPhotoReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplySendPhotoReplyMarkup - s.ForceReply = v -} - -// GetForceReply returns ForceReply and true boolean if SendPhotoReplyMarkup is ForceReply. -func (s SendPhotoReplyMarkup) GetForceReply() (v ForceReply, ok bool) { - if !s.IsForceReply() { - return v, false - } - return s.ForceReply, true -} - -// NewForceReplySendPhotoReplyMarkup returns new SendPhotoReplyMarkup from ForceReply. -func NewForceReplySendPhotoReplyMarkup(v ForceReply) SendPhotoReplyMarkup { - var s SendPhotoReplyMarkup - s.SetForceReply(v) - return s -} - -// Ref: #/components/schemas/sendPoll -type SendPoll struct { - ChatID ID `json:"chat_id"` - Question string `json:"question"` - Options []string `json:"options"` - IsAnonymous OptBool `json:"is_anonymous"` - Type OptString `json:"type"` - AllowsMultipleAnswers OptBool `json:"allows_multiple_answers"` - CorrectOptionID OptInt `json:"correct_option_id"` - Explanation OptString `json:"explanation"` - ExplanationParseMode OptString `json:"explanation_parse_mode"` - ExplanationEntities []MessageEntity `json:"explanation_entities"` - OpenPeriod OptInt `json:"open_period"` - CloseDate OptInt `json:"close_date"` - IsClosed OptBool `json:"is_closed"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *SendPollReplyMarkup `json:"reply_markup"` -} - -// SendPollReplyMarkup represents sum type. -type SendPollReplyMarkup struct { - Type SendPollReplyMarkupType // switch on this field - InlineKeyboardMarkup InlineKeyboardMarkup - ReplyKeyboardMarkup ReplyKeyboardMarkup - ReplyKeyboardRemove ReplyKeyboardRemove - ForceReply ForceReply -} - -// SendPollReplyMarkupType is oneOf type of SendPollReplyMarkup. -type SendPollReplyMarkupType string - -// Possible values for SendPollReplyMarkupType. -const ( - InlineKeyboardMarkupSendPollReplyMarkup SendPollReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupSendPollReplyMarkup SendPollReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveSendPollReplyMarkup SendPollReplyMarkupType = "ReplyKeyboardRemove" - ForceReplySendPollReplyMarkup SendPollReplyMarkupType = "ForceReply" -) - -// IsInlineKeyboardMarkup reports whether SendPollReplyMarkup is InlineKeyboardMarkup. -func (s SendPollReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupSendPollReplyMarkup -} - -// IsReplyKeyboardMarkup reports whether SendPollReplyMarkup is ReplyKeyboardMarkup. -func (s SendPollReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupSendPollReplyMarkup -} - -// IsReplyKeyboardRemove reports whether SendPollReplyMarkup is ReplyKeyboardRemove. -func (s SendPollReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveSendPollReplyMarkup -} - -// IsForceReply reports whether SendPollReplyMarkup is ForceReply. -func (s SendPollReplyMarkup) IsForceReply() bool { return s.Type == ForceReplySendPollReplyMarkup } - -// SetInlineKeyboardMarkup sets SendPollReplyMarkup to InlineKeyboardMarkup. -func (s *SendPollReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupSendPollReplyMarkup - s.InlineKeyboardMarkup = v -} - -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendPollReplyMarkup is InlineKeyboardMarkup. -func (s SendPollReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { - if !s.IsInlineKeyboardMarkup() { - return v, false - } - return s.InlineKeyboardMarkup, true -} - -// NewInlineKeyboardMarkupSendPollReplyMarkup returns new SendPollReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupSendPollReplyMarkup(v InlineKeyboardMarkup) SendPollReplyMarkup { - var s SendPollReplyMarkup - s.SetInlineKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardMarkup sets SendPollReplyMarkup to ReplyKeyboardMarkup. -func (s *SendPollReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupSendPollReplyMarkup - s.ReplyKeyboardMarkup = v -} - -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendPollReplyMarkup is ReplyKeyboardMarkup. -func (s SendPollReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { - if !s.IsReplyKeyboardMarkup() { - return v, false - } - return s.ReplyKeyboardMarkup, true -} - -// NewReplyKeyboardMarkupSendPollReplyMarkup returns new SendPollReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupSendPollReplyMarkup(v ReplyKeyboardMarkup) SendPollReplyMarkup { - var s SendPollReplyMarkup - s.SetReplyKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardRemove sets SendPollReplyMarkup to ReplyKeyboardRemove. -func (s *SendPollReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveSendPollReplyMarkup - s.ReplyKeyboardRemove = v -} - -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendPollReplyMarkup is ReplyKeyboardRemove. -func (s SendPollReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { - if !s.IsReplyKeyboardRemove() { - return v, false - } - return s.ReplyKeyboardRemove, true -} - -// NewReplyKeyboardRemoveSendPollReplyMarkup returns new SendPollReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveSendPollReplyMarkup(v ReplyKeyboardRemove) SendPollReplyMarkup { - var s SendPollReplyMarkup - s.SetReplyKeyboardRemove(v) - return s -} - -// SetForceReply sets SendPollReplyMarkup to ForceReply. -func (s *SendPollReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplySendPollReplyMarkup - s.ForceReply = v -} - -// GetForceReply returns ForceReply and true boolean if SendPollReplyMarkup is ForceReply. -func (s SendPollReplyMarkup) GetForceReply() (v ForceReply, ok bool) { - if !s.IsForceReply() { - return v, false - } - return s.ForceReply, true -} - -// NewForceReplySendPollReplyMarkup returns new SendPollReplyMarkup from ForceReply. -func NewForceReplySendPollReplyMarkup(v ForceReply) SendPollReplyMarkup { - var s SendPollReplyMarkup - s.SetForceReply(v) - return s -} - -// Ref: #/components/schemas/sendSticker -type SendSticker struct { - ChatID ID `json:"chat_id"` - Sticker string `json:"sticker"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *SendStickerReplyMarkup `json:"reply_markup"` -} - -// SendStickerReplyMarkup represents sum type. -type SendStickerReplyMarkup struct { - Type SendStickerReplyMarkupType // switch on this field - InlineKeyboardMarkup InlineKeyboardMarkup - ReplyKeyboardMarkup ReplyKeyboardMarkup - ReplyKeyboardRemove ReplyKeyboardRemove - ForceReply ForceReply -} - -// SendStickerReplyMarkupType is oneOf type of SendStickerReplyMarkup. -type SendStickerReplyMarkupType string - -// Possible values for SendStickerReplyMarkupType. -const ( - InlineKeyboardMarkupSendStickerReplyMarkup SendStickerReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupSendStickerReplyMarkup SendStickerReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveSendStickerReplyMarkup SendStickerReplyMarkupType = "ReplyKeyboardRemove" - ForceReplySendStickerReplyMarkup SendStickerReplyMarkupType = "ForceReply" -) - -// IsInlineKeyboardMarkup reports whether SendStickerReplyMarkup is InlineKeyboardMarkup. -func (s SendStickerReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupSendStickerReplyMarkup -} - -// IsReplyKeyboardMarkup reports whether SendStickerReplyMarkup is ReplyKeyboardMarkup. -func (s SendStickerReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupSendStickerReplyMarkup -} - -// IsReplyKeyboardRemove reports whether SendStickerReplyMarkup is ReplyKeyboardRemove. -func (s SendStickerReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveSendStickerReplyMarkup -} - -// IsForceReply reports whether SendStickerReplyMarkup is ForceReply. -func (s SendStickerReplyMarkup) IsForceReply() bool { - return s.Type == ForceReplySendStickerReplyMarkup -} - -// SetInlineKeyboardMarkup sets SendStickerReplyMarkup to InlineKeyboardMarkup. -func (s *SendStickerReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupSendStickerReplyMarkup - s.InlineKeyboardMarkup = v -} - -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendStickerReplyMarkup is InlineKeyboardMarkup. -func (s SendStickerReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { - if !s.IsInlineKeyboardMarkup() { - return v, false - } - return s.InlineKeyboardMarkup, true -} - -// NewInlineKeyboardMarkupSendStickerReplyMarkup returns new SendStickerReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupSendStickerReplyMarkup(v InlineKeyboardMarkup) SendStickerReplyMarkup { - var s SendStickerReplyMarkup - s.SetInlineKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardMarkup sets SendStickerReplyMarkup to ReplyKeyboardMarkup. -func (s *SendStickerReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupSendStickerReplyMarkup - s.ReplyKeyboardMarkup = v -} - -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendStickerReplyMarkup is ReplyKeyboardMarkup. -func (s SendStickerReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { - if !s.IsReplyKeyboardMarkup() { - return v, false - } - return s.ReplyKeyboardMarkup, true -} - -// NewReplyKeyboardMarkupSendStickerReplyMarkup returns new SendStickerReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupSendStickerReplyMarkup(v ReplyKeyboardMarkup) SendStickerReplyMarkup { - var s SendStickerReplyMarkup - s.SetReplyKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardRemove sets SendStickerReplyMarkup to ReplyKeyboardRemove. -func (s *SendStickerReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveSendStickerReplyMarkup - s.ReplyKeyboardRemove = v -} - -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendStickerReplyMarkup is ReplyKeyboardRemove. -func (s SendStickerReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { - if !s.IsReplyKeyboardRemove() { - return v, false - } - return s.ReplyKeyboardRemove, true -} - -// NewReplyKeyboardRemoveSendStickerReplyMarkup returns new SendStickerReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveSendStickerReplyMarkup(v ReplyKeyboardRemove) SendStickerReplyMarkup { - var s SendStickerReplyMarkup - s.SetReplyKeyboardRemove(v) - return s -} - -// SetForceReply sets SendStickerReplyMarkup to ForceReply. -func (s *SendStickerReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplySendStickerReplyMarkup - s.ForceReply = v -} - -// GetForceReply returns ForceReply and true boolean if SendStickerReplyMarkup is ForceReply. -func (s SendStickerReplyMarkup) GetForceReply() (v ForceReply, ok bool) { - if !s.IsForceReply() { - return v, false - } - return s.ForceReply, true -} - -// NewForceReplySendStickerReplyMarkup returns new SendStickerReplyMarkup from ForceReply. -func NewForceReplySendStickerReplyMarkup(v ForceReply) SendStickerReplyMarkup { - var s SendStickerReplyMarkup - s.SetForceReply(v) - return s -} - -// Ref: #/components/schemas/sendVenue -type SendVenue struct { - ChatID ID `json:"chat_id"` - Latitude float64 `json:"latitude"` - Longitude float64 `json:"longitude"` - Title string `json:"title"` - Address string `json:"address"` - FoursquareID OptString `json:"foursquare_id"` - FoursquareType OptString `json:"foursquare_type"` - GooglePlaceID OptString `json:"google_place_id"` - GooglePlaceType OptString `json:"google_place_type"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *SendVenueReplyMarkup `json:"reply_markup"` -} - -// SendVenueReplyMarkup represents sum type. -type SendVenueReplyMarkup struct { - Type SendVenueReplyMarkupType // switch on this field - InlineKeyboardMarkup InlineKeyboardMarkup - ReplyKeyboardMarkup ReplyKeyboardMarkup - ReplyKeyboardRemove ReplyKeyboardRemove - ForceReply ForceReply -} - -// SendVenueReplyMarkupType is oneOf type of SendVenueReplyMarkup. -type SendVenueReplyMarkupType string - -// Possible values for SendVenueReplyMarkupType. -const ( - InlineKeyboardMarkupSendVenueReplyMarkup SendVenueReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupSendVenueReplyMarkup SendVenueReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveSendVenueReplyMarkup SendVenueReplyMarkupType = "ReplyKeyboardRemove" - ForceReplySendVenueReplyMarkup SendVenueReplyMarkupType = "ForceReply" -) - -// IsInlineKeyboardMarkup reports whether SendVenueReplyMarkup is InlineKeyboardMarkup. -func (s SendVenueReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupSendVenueReplyMarkup -} - -// IsReplyKeyboardMarkup reports whether SendVenueReplyMarkup is ReplyKeyboardMarkup. -func (s SendVenueReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupSendVenueReplyMarkup -} - -// IsReplyKeyboardRemove reports whether SendVenueReplyMarkup is ReplyKeyboardRemove. -func (s SendVenueReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveSendVenueReplyMarkup -} - -// IsForceReply reports whether SendVenueReplyMarkup is ForceReply. -func (s SendVenueReplyMarkup) IsForceReply() bool { return s.Type == ForceReplySendVenueReplyMarkup } - -// SetInlineKeyboardMarkup sets SendVenueReplyMarkup to InlineKeyboardMarkup. -func (s *SendVenueReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupSendVenueReplyMarkup - s.InlineKeyboardMarkup = v -} - -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendVenueReplyMarkup is InlineKeyboardMarkup. -func (s SendVenueReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { - if !s.IsInlineKeyboardMarkup() { - return v, false - } - return s.InlineKeyboardMarkup, true -} - -// NewInlineKeyboardMarkupSendVenueReplyMarkup returns new SendVenueReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupSendVenueReplyMarkup(v InlineKeyboardMarkup) SendVenueReplyMarkup { - var s SendVenueReplyMarkup - s.SetInlineKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardMarkup sets SendVenueReplyMarkup to ReplyKeyboardMarkup. -func (s *SendVenueReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupSendVenueReplyMarkup - s.ReplyKeyboardMarkup = v -} - -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendVenueReplyMarkup is ReplyKeyboardMarkup. -func (s SendVenueReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { - if !s.IsReplyKeyboardMarkup() { - return v, false - } - return s.ReplyKeyboardMarkup, true -} - -// NewReplyKeyboardMarkupSendVenueReplyMarkup returns new SendVenueReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupSendVenueReplyMarkup(v ReplyKeyboardMarkup) SendVenueReplyMarkup { - var s SendVenueReplyMarkup - s.SetReplyKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardRemove sets SendVenueReplyMarkup to ReplyKeyboardRemove. -func (s *SendVenueReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveSendVenueReplyMarkup - s.ReplyKeyboardRemove = v -} - -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendVenueReplyMarkup is ReplyKeyboardRemove. -func (s SendVenueReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { - if !s.IsReplyKeyboardRemove() { - return v, false - } - return s.ReplyKeyboardRemove, true -} - -// NewReplyKeyboardRemoveSendVenueReplyMarkup returns new SendVenueReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveSendVenueReplyMarkup(v ReplyKeyboardRemove) SendVenueReplyMarkup { - var s SendVenueReplyMarkup - s.SetReplyKeyboardRemove(v) - return s -} - -// SetForceReply sets SendVenueReplyMarkup to ForceReply. -func (s *SendVenueReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplySendVenueReplyMarkup - s.ForceReply = v -} - -// GetForceReply returns ForceReply and true boolean if SendVenueReplyMarkup is ForceReply. -func (s SendVenueReplyMarkup) GetForceReply() (v ForceReply, ok bool) { - if !s.IsForceReply() { - return v, false - } - return s.ForceReply, true -} - -// NewForceReplySendVenueReplyMarkup returns new SendVenueReplyMarkup from ForceReply. -func NewForceReplySendVenueReplyMarkup(v ForceReply) SendVenueReplyMarkup { - var s SendVenueReplyMarkup - s.SetForceReply(v) - return s -} - -// Ref: #/components/schemas/sendVideo -type SendVideo struct { - ChatID ID `json:"chat_id"` - Video string `json:"video"` - Duration OptInt `json:"duration"` - Width OptInt `json:"width"` - Height OptInt `json:"height"` - Thumb OptString `json:"thumb"` - Caption OptString `json:"caption"` - ParseMode OptString `json:"parse_mode"` - CaptionEntities []MessageEntity `json:"caption_entities"` - SupportsStreaming OptBool `json:"supports_streaming"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *SendVideoReplyMarkup `json:"reply_markup"` -} - -// Ref: #/components/schemas/sendVideoNote -type SendVideoNote struct { - ChatID ID `json:"chat_id"` - VideoNote string `json:"video_note"` - Duration OptInt `json:"duration"` - Length OptInt `json:"length"` - Thumb OptString `json:"thumb"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *SendVideoNoteReplyMarkup `json:"reply_markup"` -} - -// SendVideoNoteReplyMarkup represents sum type. -type SendVideoNoteReplyMarkup struct { - Type SendVideoNoteReplyMarkupType // switch on this field - InlineKeyboardMarkup InlineKeyboardMarkup - ReplyKeyboardMarkup ReplyKeyboardMarkup - ReplyKeyboardRemove ReplyKeyboardRemove - ForceReply ForceReply -} - -// SendVideoNoteReplyMarkupType is oneOf type of SendVideoNoteReplyMarkup. -type SendVideoNoteReplyMarkupType string - -// Possible values for SendVideoNoteReplyMarkupType. -const ( - InlineKeyboardMarkupSendVideoNoteReplyMarkup SendVideoNoteReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupSendVideoNoteReplyMarkup SendVideoNoteReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveSendVideoNoteReplyMarkup SendVideoNoteReplyMarkupType = "ReplyKeyboardRemove" - ForceReplySendVideoNoteReplyMarkup SendVideoNoteReplyMarkupType = "ForceReply" -) - -// IsInlineKeyboardMarkup reports whether SendVideoNoteReplyMarkup is InlineKeyboardMarkup. -func (s SendVideoNoteReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupSendVideoNoteReplyMarkup -} - -// IsReplyKeyboardMarkup reports whether SendVideoNoteReplyMarkup is ReplyKeyboardMarkup. -func (s SendVideoNoteReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupSendVideoNoteReplyMarkup -} - -// IsReplyKeyboardRemove reports whether SendVideoNoteReplyMarkup is ReplyKeyboardRemove. -func (s SendVideoNoteReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveSendVideoNoteReplyMarkup -} - -// IsForceReply reports whether SendVideoNoteReplyMarkup is ForceReply. -func (s SendVideoNoteReplyMarkup) IsForceReply() bool { - return s.Type == ForceReplySendVideoNoteReplyMarkup -} - -// SetInlineKeyboardMarkup sets SendVideoNoteReplyMarkup to InlineKeyboardMarkup. -func (s *SendVideoNoteReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupSendVideoNoteReplyMarkup - s.InlineKeyboardMarkup = v -} - -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendVideoNoteReplyMarkup is InlineKeyboardMarkup. -func (s SendVideoNoteReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { - if !s.IsInlineKeyboardMarkup() { - return v, false - } - return s.InlineKeyboardMarkup, true -} - -// NewInlineKeyboardMarkupSendVideoNoteReplyMarkup returns new SendVideoNoteReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupSendVideoNoteReplyMarkup(v InlineKeyboardMarkup) SendVideoNoteReplyMarkup { - var s SendVideoNoteReplyMarkup - s.SetInlineKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardMarkup sets SendVideoNoteReplyMarkup to ReplyKeyboardMarkup. -func (s *SendVideoNoteReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupSendVideoNoteReplyMarkup - s.ReplyKeyboardMarkup = v -} - -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendVideoNoteReplyMarkup is ReplyKeyboardMarkup. -func (s SendVideoNoteReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { - if !s.IsReplyKeyboardMarkup() { - return v, false - } - return s.ReplyKeyboardMarkup, true -} - -// NewReplyKeyboardMarkupSendVideoNoteReplyMarkup returns new SendVideoNoteReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupSendVideoNoteReplyMarkup(v ReplyKeyboardMarkup) SendVideoNoteReplyMarkup { - var s SendVideoNoteReplyMarkup - s.SetReplyKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardRemove sets SendVideoNoteReplyMarkup to ReplyKeyboardRemove. -func (s *SendVideoNoteReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveSendVideoNoteReplyMarkup - s.ReplyKeyboardRemove = v -} - -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendVideoNoteReplyMarkup is ReplyKeyboardRemove. -func (s SendVideoNoteReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { - if !s.IsReplyKeyboardRemove() { - return v, false - } - return s.ReplyKeyboardRemove, true -} - -// NewReplyKeyboardRemoveSendVideoNoteReplyMarkup returns new SendVideoNoteReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveSendVideoNoteReplyMarkup(v ReplyKeyboardRemove) SendVideoNoteReplyMarkup { - var s SendVideoNoteReplyMarkup - s.SetReplyKeyboardRemove(v) - return s -} - -// SetForceReply sets SendVideoNoteReplyMarkup to ForceReply. -func (s *SendVideoNoteReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplySendVideoNoteReplyMarkup - s.ForceReply = v -} - -// GetForceReply returns ForceReply and true boolean if SendVideoNoteReplyMarkup is ForceReply. -func (s SendVideoNoteReplyMarkup) GetForceReply() (v ForceReply, ok bool) { - if !s.IsForceReply() { - return v, false - } - return s.ForceReply, true -} - -// NewForceReplySendVideoNoteReplyMarkup returns new SendVideoNoteReplyMarkup from ForceReply. -func NewForceReplySendVideoNoteReplyMarkup(v ForceReply) SendVideoNoteReplyMarkup { - var s SendVideoNoteReplyMarkup - s.SetForceReply(v) - return s -} - -// SendVideoReplyMarkup represents sum type. -type SendVideoReplyMarkup struct { - Type SendVideoReplyMarkupType // switch on this field - InlineKeyboardMarkup InlineKeyboardMarkup - ReplyKeyboardMarkup ReplyKeyboardMarkup - ReplyKeyboardRemove ReplyKeyboardRemove - ForceReply ForceReply -} - -// SendVideoReplyMarkupType is oneOf type of SendVideoReplyMarkup. -type SendVideoReplyMarkupType string - -// Possible values for SendVideoReplyMarkupType. -const ( - InlineKeyboardMarkupSendVideoReplyMarkup SendVideoReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupSendVideoReplyMarkup SendVideoReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveSendVideoReplyMarkup SendVideoReplyMarkupType = "ReplyKeyboardRemove" - ForceReplySendVideoReplyMarkup SendVideoReplyMarkupType = "ForceReply" -) - -// IsInlineKeyboardMarkup reports whether SendVideoReplyMarkup is InlineKeyboardMarkup. -func (s SendVideoReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupSendVideoReplyMarkup -} - -// IsReplyKeyboardMarkup reports whether SendVideoReplyMarkup is ReplyKeyboardMarkup. -func (s SendVideoReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupSendVideoReplyMarkup -} - -// IsReplyKeyboardRemove reports whether SendVideoReplyMarkup is ReplyKeyboardRemove. -func (s SendVideoReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveSendVideoReplyMarkup -} - -// IsForceReply reports whether SendVideoReplyMarkup is ForceReply. -func (s SendVideoReplyMarkup) IsForceReply() bool { return s.Type == ForceReplySendVideoReplyMarkup } - -// SetInlineKeyboardMarkup sets SendVideoReplyMarkup to InlineKeyboardMarkup. -func (s *SendVideoReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupSendVideoReplyMarkup - s.InlineKeyboardMarkup = v -} - -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendVideoReplyMarkup is InlineKeyboardMarkup. -func (s SendVideoReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { - if !s.IsInlineKeyboardMarkup() { - return v, false - } - return s.InlineKeyboardMarkup, true -} - -// NewInlineKeyboardMarkupSendVideoReplyMarkup returns new SendVideoReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupSendVideoReplyMarkup(v InlineKeyboardMarkup) SendVideoReplyMarkup { - var s SendVideoReplyMarkup - s.SetInlineKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardMarkup sets SendVideoReplyMarkup to ReplyKeyboardMarkup. -func (s *SendVideoReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupSendVideoReplyMarkup - s.ReplyKeyboardMarkup = v -} - -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendVideoReplyMarkup is ReplyKeyboardMarkup. -func (s SendVideoReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { - if !s.IsReplyKeyboardMarkup() { - return v, false - } - return s.ReplyKeyboardMarkup, true -} - -// NewReplyKeyboardMarkupSendVideoReplyMarkup returns new SendVideoReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupSendVideoReplyMarkup(v ReplyKeyboardMarkup) SendVideoReplyMarkup { - var s SendVideoReplyMarkup - s.SetReplyKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardRemove sets SendVideoReplyMarkup to ReplyKeyboardRemove. -func (s *SendVideoReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveSendVideoReplyMarkup - s.ReplyKeyboardRemove = v -} - -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendVideoReplyMarkup is ReplyKeyboardRemove. -func (s SendVideoReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { - if !s.IsReplyKeyboardRemove() { - return v, false - } - return s.ReplyKeyboardRemove, true -} - -// NewReplyKeyboardRemoveSendVideoReplyMarkup returns new SendVideoReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveSendVideoReplyMarkup(v ReplyKeyboardRemove) SendVideoReplyMarkup { - var s SendVideoReplyMarkup - s.SetReplyKeyboardRemove(v) - return s -} - -// SetForceReply sets SendVideoReplyMarkup to ForceReply. -func (s *SendVideoReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplySendVideoReplyMarkup - s.ForceReply = v -} - -// GetForceReply returns ForceReply and true boolean if SendVideoReplyMarkup is ForceReply. -func (s SendVideoReplyMarkup) GetForceReply() (v ForceReply, ok bool) { - if !s.IsForceReply() { - return v, false - } - return s.ForceReply, true -} - -// NewForceReplySendVideoReplyMarkup returns new SendVideoReplyMarkup from ForceReply. -func NewForceReplySendVideoReplyMarkup(v ForceReply) SendVideoReplyMarkup { - var s SendVideoReplyMarkup - s.SetForceReply(v) - return s -} - -// Ref: #/components/schemas/sendVoice -type SendVoice struct { - ChatID ID `json:"chat_id"` - Voice string `json:"voice"` - Caption OptString `json:"caption"` - ParseMode OptString `json:"parse_mode"` - CaptionEntities []MessageEntity `json:"caption_entities"` - Duration OptInt `json:"duration"` - DisableNotification OptBool `json:"disable_notification"` - ReplyToMessageID OptInt `json:"reply_to_message_id"` - AllowSendingWithoutReply OptBool `json:"allow_sending_without_reply"` - ReplyMarkup *SendVoiceReplyMarkup `json:"reply_markup"` -} - -// SendVoiceReplyMarkup represents sum type. -type SendVoiceReplyMarkup struct { - Type SendVoiceReplyMarkupType // switch on this field - InlineKeyboardMarkup InlineKeyboardMarkup - ReplyKeyboardMarkup ReplyKeyboardMarkup - ReplyKeyboardRemove ReplyKeyboardRemove - ForceReply ForceReply -} - -// SendVoiceReplyMarkupType is oneOf type of SendVoiceReplyMarkup. -type SendVoiceReplyMarkupType string - -// Possible values for SendVoiceReplyMarkupType. -const ( - InlineKeyboardMarkupSendVoiceReplyMarkup SendVoiceReplyMarkupType = "InlineKeyboardMarkup" - ReplyKeyboardMarkupSendVoiceReplyMarkup SendVoiceReplyMarkupType = "ReplyKeyboardMarkup" - ReplyKeyboardRemoveSendVoiceReplyMarkup SendVoiceReplyMarkupType = "ReplyKeyboardRemove" - ForceReplySendVoiceReplyMarkup SendVoiceReplyMarkupType = "ForceReply" -) - -// IsInlineKeyboardMarkup reports whether SendVoiceReplyMarkup is InlineKeyboardMarkup. -func (s SendVoiceReplyMarkup) IsInlineKeyboardMarkup() bool { - return s.Type == InlineKeyboardMarkupSendVoiceReplyMarkup -} - -// IsReplyKeyboardMarkup reports whether SendVoiceReplyMarkup is ReplyKeyboardMarkup. -func (s SendVoiceReplyMarkup) IsReplyKeyboardMarkup() bool { - return s.Type == ReplyKeyboardMarkupSendVoiceReplyMarkup -} - -// IsReplyKeyboardRemove reports whether SendVoiceReplyMarkup is ReplyKeyboardRemove. -func (s SendVoiceReplyMarkup) IsReplyKeyboardRemove() bool { - return s.Type == ReplyKeyboardRemoveSendVoiceReplyMarkup -} - -// IsForceReply reports whether SendVoiceReplyMarkup is ForceReply. -func (s SendVoiceReplyMarkup) IsForceReply() bool { return s.Type == ForceReplySendVoiceReplyMarkup } - -// SetInlineKeyboardMarkup sets SendVoiceReplyMarkup to InlineKeyboardMarkup. -func (s *SendVoiceReplyMarkup) SetInlineKeyboardMarkup(v InlineKeyboardMarkup) { - s.Type = InlineKeyboardMarkupSendVoiceReplyMarkup - s.InlineKeyboardMarkup = v -} - -// GetInlineKeyboardMarkup returns InlineKeyboardMarkup and true boolean if SendVoiceReplyMarkup is InlineKeyboardMarkup. -func (s SendVoiceReplyMarkup) GetInlineKeyboardMarkup() (v InlineKeyboardMarkup, ok bool) { - if !s.IsInlineKeyboardMarkup() { - return v, false - } - return s.InlineKeyboardMarkup, true -} - -// NewInlineKeyboardMarkupSendVoiceReplyMarkup returns new SendVoiceReplyMarkup from InlineKeyboardMarkup. -func NewInlineKeyboardMarkupSendVoiceReplyMarkup(v InlineKeyboardMarkup) SendVoiceReplyMarkup { - var s SendVoiceReplyMarkup - s.SetInlineKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardMarkup sets SendVoiceReplyMarkup to ReplyKeyboardMarkup. -func (s *SendVoiceReplyMarkup) SetReplyKeyboardMarkup(v ReplyKeyboardMarkup) { - s.Type = ReplyKeyboardMarkupSendVoiceReplyMarkup - s.ReplyKeyboardMarkup = v -} - -// GetReplyKeyboardMarkup returns ReplyKeyboardMarkup and true boolean if SendVoiceReplyMarkup is ReplyKeyboardMarkup. -func (s SendVoiceReplyMarkup) GetReplyKeyboardMarkup() (v ReplyKeyboardMarkup, ok bool) { - if !s.IsReplyKeyboardMarkup() { - return v, false - } - return s.ReplyKeyboardMarkup, true -} - -// NewReplyKeyboardMarkupSendVoiceReplyMarkup returns new SendVoiceReplyMarkup from ReplyKeyboardMarkup. -func NewReplyKeyboardMarkupSendVoiceReplyMarkup(v ReplyKeyboardMarkup) SendVoiceReplyMarkup { - var s SendVoiceReplyMarkup - s.SetReplyKeyboardMarkup(v) - return s -} - -// SetReplyKeyboardRemove sets SendVoiceReplyMarkup to ReplyKeyboardRemove. -func (s *SendVoiceReplyMarkup) SetReplyKeyboardRemove(v ReplyKeyboardRemove) { - s.Type = ReplyKeyboardRemoveSendVoiceReplyMarkup - s.ReplyKeyboardRemove = v -} - -// GetReplyKeyboardRemove returns ReplyKeyboardRemove and true boolean if SendVoiceReplyMarkup is ReplyKeyboardRemove. -func (s SendVoiceReplyMarkup) GetReplyKeyboardRemove() (v ReplyKeyboardRemove, ok bool) { - if !s.IsReplyKeyboardRemove() { - return v, false - } - return s.ReplyKeyboardRemove, true -} - -// NewReplyKeyboardRemoveSendVoiceReplyMarkup returns new SendVoiceReplyMarkup from ReplyKeyboardRemove. -func NewReplyKeyboardRemoveSendVoiceReplyMarkup(v ReplyKeyboardRemove) SendVoiceReplyMarkup { - var s SendVoiceReplyMarkup - s.SetReplyKeyboardRemove(v) - return s -} - -// SetForceReply sets SendVoiceReplyMarkup to ForceReply. -func (s *SendVoiceReplyMarkup) SetForceReply(v ForceReply) { - s.Type = ForceReplySendVoiceReplyMarkup - s.ForceReply = v -} - -// GetForceReply returns ForceReply and true boolean if SendVoiceReplyMarkup is ForceReply. -func (s SendVoiceReplyMarkup) GetForceReply() (v ForceReply, ok bool) { - if !s.IsForceReply() { - return v, false - } - return s.ForceReply, true -} - -// NewForceReplySendVoiceReplyMarkup returns new SendVoiceReplyMarkup from ForceReply. -func NewForceReplySendVoiceReplyMarkup(v ForceReply) SendVoiceReplyMarkup { - var s SendVoiceReplyMarkup - s.SetForceReply(v) - return s -} - -// Ref: #/components/schemas/setChatAdministratorCustomTitle -type SetChatAdministratorCustomTitle struct { - ChatID ID `json:"chat_id"` - UserID int64 `json:"user_id"` - CustomTitle string `json:"custom_title"` -} - -// Ref: #/components/schemas/setChatDescription -type SetChatDescription struct { - ChatID ID `json:"chat_id"` - Description OptString `json:"description"` -} - -// Ref: #/components/schemas/setChatPermissions -type SetChatPermissions struct { - ChatID ID `json:"chat_id"` - Permissions ChatPermissions `json:"permissions"` -} - -// Ref: #/components/schemas/setChatPhoto -type SetChatPhoto struct { - ChatID ID `json:"chat_id"` - Photo string `json:"photo"` +// Ref: #/components/schemas/setChatPhoto +type SetChatPhoto struct { + ChatID ID `json:"chat_id"` + Photo string `json:"photo"` } // Ref: #/components/schemas/setChatStickerSet @@ -7965,6 +6770,16 @@ type Sticker struct { FileSize OptInt `json:"file_size"` } +// Ref: #/components/schemas/StickerSet +type StickerSet struct { + Name string `json:"name"` + Title string `json:"title"` + IsAnimated bool `json:"is_animated"` + ContainsMasks bool `json:"contains_masks"` + Stickers []Sticker `json:"stickers"` + Thumb OptPhotoSize `json:"thumb"` +} + // Ref: #/components/schemas/stopMessageLiveLocation type StopMessageLiveLocation struct { ChatID *ID `json:"chat_id"` diff --git a/internal/oas/oas_server_gen.go b/internal/oas/oas_server_gen.go index 40d4cbd..8fad514 100644 --- a/internal/oas/oas_server_gen.go +++ b/internal/oas/oas_server_gen.go @@ -191,7 +191,7 @@ type Handler interface { // GetFile implements getFile operation. // // POST /getFile - GetFile(ctx context.Context, req GetFile) (Result, error) + GetFile(ctx context.Context, req GetFile) (ResultFile, error) // GetGameHighScores implements getGameHighScores operation. // // POST /getGameHighScores @@ -207,7 +207,7 @@ type Handler interface { // GetStickerSet implements getStickerSet operation. // // POST /getStickerSet - GetStickerSet(ctx context.Context, req GetStickerSet) (Result, error) + GetStickerSet(ctx context.Context, req GetStickerSet) (ResultStickerSet, error) // GetUpdates implements getUpdates operation. // // POST /getUpdates diff --git a/internal/oas/oas_validators_gen.go b/internal/oas/oas_validators_gen.go index 67955c1..6973ad8 100644 --- a/internal/oas/oas_validators_gen.go +++ b/internal/oas/oas_validators_gen.go @@ -729,30 +729,6 @@ func (s CopyMessage) Validate() error { } return nil } -func (s CopyMessageReplyMarkup) Validate() error { - switch s.Type { - case InlineKeyboardMarkupCopyMessageReplyMarkup: - if err := s.InlineKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardMarkupCopyMessageReplyMarkup: - if err := s.ReplyKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardRemoveCopyMessageReplyMarkup: - return nil // no validation needed - case ForceReplyCopyMessageReplyMarkup: - if err := s.ForceReply.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - func (s CreateChatInviteLink) Validate() error { var failures []validate.FieldError if err := func() error { @@ -6927,6 +6903,32 @@ func (s ResultPoll) Validate() error { } return nil } +func (s ResultStickerSet) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Result.Set { + if err := func() error { + if err := s.Result.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "result", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} func (s ResultUserProfilePhotos) Validate() error { var failures []validate.FieldError if err := func() error { @@ -7109,30 +7111,6 @@ func (s SendAnimation) Validate() error { } return nil } -func (s SendAnimationReplyMarkup) Validate() error { - switch s.Type { - case InlineKeyboardMarkupSendAnimationReplyMarkup: - if err := s.InlineKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardMarkupSendAnimationReplyMarkup: - if err := s.ReplyKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardRemoveSendAnimationReplyMarkup: - return nil // no validation needed - case ForceReplySendAnimationReplyMarkup: - if err := s.ForceReply.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - func (s SendAudio) Validate() error { var failures []validate.FieldError if err := func() error { @@ -7237,30 +7215,6 @@ func (s SendAudio) Validate() error { } return nil } -func (s SendAudioReplyMarkup) Validate() error { - switch s.Type { - case InlineKeyboardMarkupSendAudioReplyMarkup: - if err := s.InlineKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardMarkupSendAudioReplyMarkup: - if err := s.ReplyKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardRemoveSendAudioReplyMarkup: - return nil // no validation needed - case ForceReplySendAudioReplyMarkup: - if err := s.ForceReply.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - func (s SendContact) Validate() error { var failures []validate.FieldError if err := func() error { @@ -7314,30 +7268,6 @@ func (s SendContact) Validate() error { } return nil } -func (s SendContactReplyMarkup) Validate() error { - switch s.Type { - case InlineKeyboardMarkupSendContactReplyMarkup: - if err := s.InlineKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardMarkupSendContactReplyMarkup: - if err := s.ReplyKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardRemoveSendContactReplyMarkup: - return nil // no validation needed - case ForceReplySendContactReplyMarkup: - if err := s.ForceReply.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - func (s SendDice) Validate() error { var failures []validate.FieldError if err := func() error { @@ -7364,30 +7294,6 @@ func (s SendDice) Validate() error { } return nil } -func (s SendDiceReplyMarkup) Validate() error { - switch s.Type { - case InlineKeyboardMarkupSendDiceReplyMarkup: - if err := s.InlineKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardMarkupSendDiceReplyMarkup: - if err := s.ReplyKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardRemoveSendDiceReplyMarkup: - return nil // no validation needed - case ForceReplySendDiceReplyMarkup: - if err := s.ForceReply.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - func (s SendDocument) Validate() error { var failures []validate.FieldError if err := func() error { @@ -7466,30 +7372,6 @@ func (s SendDocument) Validate() error { } return nil } -func (s SendDocumentReplyMarkup) Validate() error { - switch s.Type { - case InlineKeyboardMarkupSendDocumentReplyMarkup: - if err := s.InlineKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardMarkupSendDocumentReplyMarkup: - if err := s.ReplyKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardRemoveSendDocumentReplyMarkup: - return nil // no validation needed - case ForceReplySendDocumentReplyMarkup: - if err := s.ForceReply.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - func (s SendGame) Validate() error { var failures []validate.FieldError if err := func() error { @@ -7807,30 +7689,6 @@ func (s SendLocation) Validate() error { } return nil } -func (s SendLocationReplyMarkup) Validate() error { - switch s.Type { - case InlineKeyboardMarkupSendLocationReplyMarkup: - if err := s.InlineKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardMarkupSendLocationReplyMarkup: - if err := s.ReplyKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardRemoveSendLocationReplyMarkup: - return nil // no validation needed - case ForceReplySendLocationReplyMarkup: - if err := s.ForceReply.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - func (s SendMediaGroup) Validate() error { var failures []validate.FieldError if err := func() error { @@ -7963,30 +7821,6 @@ func (s SendMessage) Validate() error { } return nil } -func (s SendMessageReplyMarkup) Validate() error { - switch s.Type { - case InlineKeyboardMarkupSendMessageReplyMarkup: - if err := s.InlineKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardMarkupSendMessageReplyMarkup: - if err := s.ReplyKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardRemoveSendMessageReplyMarkup: - return nil // no validation needed - case ForceReplySendMessageReplyMarkup: - if err := s.ForceReply.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - func (s SendPhoto) Validate() error { var failures []validate.FieldError if err := func() error { @@ -8065,30 +7899,6 @@ func (s SendPhoto) Validate() error { } return nil } -func (s SendPhotoReplyMarkup) Validate() error { - switch s.Type { - case InlineKeyboardMarkupSendPhotoReplyMarkup: - if err := s.InlineKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardMarkupSendPhotoReplyMarkup: - if err := s.ReplyKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardRemoveSendPhotoReplyMarkup: - return nil // no validation needed - case ForceReplySendPhotoReplyMarkup: - if err := s.ForceReply.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - func (s SendPoll) Validate() error { var failures []validate.FieldError if err := func() error { @@ -8197,21 +8007,21 @@ func (s SendPoll) Validate() error { } return nil } -func (s SendPollReplyMarkup) Validate() error { +func (s SendReplyMarkup) Validate() error { switch s.Type { - case InlineKeyboardMarkupSendPollReplyMarkup: + case InlineKeyboardMarkupSendReplyMarkup: if err := s.InlineKeyboardMarkup.Validate(); err != nil { return err } return nil - case ReplyKeyboardMarkupSendPollReplyMarkup: + case ReplyKeyboardMarkupSendReplyMarkup: if err := s.ReplyKeyboardMarkup.Validate(); err != nil { return err } return nil - case ReplyKeyboardRemoveSendPollReplyMarkup: + case ReplyKeyboardRemoveSendReplyMarkup: return nil // no validation needed - case ForceReplySendPollReplyMarkup: + case ForceReplySendReplyMarkup: if err := s.ForceReply.Validate(); err != nil { return err } @@ -8247,30 +8057,6 @@ func (s SendSticker) Validate() error { } return nil } -func (s SendStickerReplyMarkup) Validate() error { - switch s.Type { - case InlineKeyboardMarkupSendStickerReplyMarkup: - if err := s.InlineKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardMarkupSendStickerReplyMarkup: - if err := s.ReplyKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardRemoveSendStickerReplyMarkup: - return nil // no validation needed - case ForceReplySendStickerReplyMarkup: - if err := s.ForceReply.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - func (s SendVenue) Validate() error { var failures []validate.FieldError if err := func() error { @@ -8319,30 +8105,6 @@ func (s SendVenue) Validate() error { } return nil } -func (s SendVenueReplyMarkup) Validate() error { - switch s.Type { - case InlineKeyboardMarkupSendVenueReplyMarkup: - if err := s.InlineKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardMarkupSendVenueReplyMarkup: - if err := s.ReplyKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardRemoveSendVenueReplyMarkup: - return nil // no validation needed - case ForceReplySendVenueReplyMarkup: - if err := s.ForceReply.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - func (s SendVideo) Validate() error { var failures []validate.FieldError if err := func() error { @@ -8551,54 +8313,6 @@ func (s SendVideoNote) Validate() error { } return nil } -func (s SendVideoNoteReplyMarkup) Validate() error { - switch s.Type { - case InlineKeyboardMarkupSendVideoNoteReplyMarkup: - if err := s.InlineKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardMarkupSendVideoNoteReplyMarkup: - if err := s.ReplyKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardRemoveSendVideoNoteReplyMarkup: - return nil // no validation needed - case ForceReplySendVideoNoteReplyMarkup: - if err := s.ForceReply.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - -func (s SendVideoReplyMarkup) Validate() error { - switch s.Type { - case InlineKeyboardMarkupSendVideoReplyMarkup: - if err := s.InlineKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardMarkupSendVideoReplyMarkup: - if err := s.ReplyKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardRemoveSendVideoReplyMarkup: - return nil // no validation needed - case ForceReplySendVideoReplyMarkup: - if err := s.ForceReply.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - func (s SendVoice) Validate() error { var failures []validate.FieldError if err := func() error { @@ -8703,30 +8417,6 @@ func (s SendVoice) Validate() error { } return nil } -func (s SendVoiceReplyMarkup) Validate() error { - switch s.Type { - case InlineKeyboardMarkupSendVoiceReplyMarkup: - if err := s.InlineKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardMarkupSendVoiceReplyMarkup: - if err := s.ReplyKeyboardMarkup.Validate(); err != nil { - return err - } - return nil - case ReplyKeyboardRemoveSendVoiceReplyMarkup: - return nil // no validation needed - case ForceReplySendVoiceReplyMarkup: - if err := s.ForceReply.Validate(); err != nil { - return err - } - return nil - default: - return errors.Errorf("invalid type %q", s.Type) - } -} - func (s SetChatAdministratorCustomTitle) Validate() error { var failures []validate.FieldError if err := func() error { @@ -8982,6 +8672,60 @@ func (s Sticker) Validate() error { } return nil } +func (s StickerSet) Validate() error { + var failures []validate.FieldError + if err := func() error { + if s.Stickers == nil { + return errors.New("nil is invalid value") + } + var failures []validate.FieldError + for i, elem := range s.Stickers { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "stickers", + Error: err, + }) + } + if err := func() error { + if s.Thumb.Set { + if err := func() error { + if err := s.Thumb.Value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "thumb", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} func (s StopMessageLiveLocation) Validate() error { var failures []validate.FieldError if err := func() error {