add list unmarshallers
This commit is contained in:
parent
cc7d37acc2
commit
ec36320d03
394
client/type.go
394
client/type.go
|
@ -5288,6 +5288,25 @@ func (*MessageSenders) GetType() string {
|
||||||
return TypeMessageSenders
|
return TypeMessageSenders
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (messageSenders *MessageSenders) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
TotalCount int32 `json:"total_count"`
|
||||||
|
Senders []json.RawMessage `json:"senders"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
messageSenders.TotalCount = tmp.TotalCount
|
||||||
|
|
||||||
|
fieldSenders, _ := UnmarshalListOfMessageSender(tmp.Senders)
|
||||||
|
messageSenders.Senders = fieldSenders
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// The message was originally sent by a known user
|
// The message was originally sent by a known user
|
||||||
type MessageForwardOriginUser struct {
|
type MessageForwardOriginUser struct {
|
||||||
meta
|
meta
|
||||||
|
@ -5489,6 +5508,31 @@ func (*MessageReplyInfo) GetType() string {
|
||||||
return TypeMessageReplyInfo
|
return TypeMessageReplyInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (messageReplyInfo *MessageReplyInfo) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
ReplyCount int32 `json:"reply_count"`
|
||||||
|
RecentRepliers []json.RawMessage `json:"recent_repliers"`
|
||||||
|
LastReadInboxMessageId int64 `json:"last_read_inbox_message_id"`
|
||||||
|
LastReadOutboxMessageId int64 `json:"last_read_outbox_message_id"`
|
||||||
|
LastMessageId int64 `json:"last_message_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
messageReplyInfo.ReplyCount = tmp.ReplyCount
|
||||||
|
messageReplyInfo.LastReadInboxMessageId = tmp.LastReadInboxMessageId
|
||||||
|
messageReplyInfo.LastReadOutboxMessageId = tmp.LastReadOutboxMessageId
|
||||||
|
messageReplyInfo.LastMessageId = tmp.LastMessageId
|
||||||
|
|
||||||
|
fieldRecentRepliers, _ := UnmarshalListOfMessageSender(tmp.RecentRepliers)
|
||||||
|
messageReplyInfo.RecentRepliers = fieldRecentRepliers
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Contains information about interactions with a message
|
// Contains information about interactions with a message
|
||||||
type MessageInteractionInfo struct {
|
type MessageInteractionInfo struct {
|
||||||
meta
|
meta
|
||||||
|
@ -6319,6 +6363,22 @@ func (*ChatLists) GetType() string {
|
||||||
return TypeChatLists
|
return TypeChatLists
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (chatLists *ChatLists) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
ChatLists []json.RawMessage `json:"chat_lists"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldChatLists, _ := UnmarshalListOfChatList(tmp.ChatLists)
|
||||||
|
chatLists.ChatLists = fieldChatLists
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// The chat is sponsored by the user's MTProxy server
|
// The chat is sponsored by the user's MTProxy server
|
||||||
type ChatSourceMtprotoProxy struct {
|
type ChatSourceMtprotoProxy struct {
|
||||||
meta
|
meta
|
||||||
|
@ -8202,6 +8262,22 @@ func (*RichTexts) RichTextType() string {
|
||||||
return TypeRichTexts
|
return TypeRichTexts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (richTexts *RichTexts) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
Texts []json.RawMessage `json:"texts"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldTexts, _ := UnmarshalListOfRichText(tmp.Texts)
|
||||||
|
richTexts.Texts = fieldTexts
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Contains a caption of an instant view web page block, consisting of a text and a trailing credit
|
// Contains a caption of an instant view web page block, consisting of a text and a trailing credit
|
||||||
type PageBlockCaption struct {
|
type PageBlockCaption struct {
|
||||||
meta
|
meta
|
||||||
|
@ -8272,6 +8348,25 @@ func (*PageBlockListItem) GetType() string {
|
||||||
return TypePageBlockListItem
|
return TypePageBlockListItem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pageBlockListItem *PageBlockListItem) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
Label string `json:"label"`
|
||||||
|
PageBlocks []json.RawMessage `json:"page_blocks"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
pageBlockListItem.Label = tmp.Label
|
||||||
|
|
||||||
|
fieldPageBlocks, _ := UnmarshalListOfPageBlock(tmp.PageBlocks)
|
||||||
|
pageBlockListItem.PageBlocks = fieldPageBlocks
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// The content should be left-aligned
|
// The content should be left-aligned
|
||||||
type PageBlockHorizontalAlignmentLeft struct {
|
type PageBlockHorizontalAlignmentLeft struct {
|
||||||
meta
|
meta
|
||||||
|
@ -9367,6 +9462,33 @@ func (*PageBlockEmbeddedPost) PageBlockType() string {
|
||||||
return TypePageBlockEmbeddedPost
|
return TypePageBlockEmbeddedPost
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pageBlockEmbeddedPost *PageBlockEmbeddedPost) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
Url string `json:"url"`
|
||||||
|
Author string `json:"author"`
|
||||||
|
AuthorPhoto *Photo `json:"author_photo"`
|
||||||
|
Date int32 `json:"date"`
|
||||||
|
PageBlocks []json.RawMessage `json:"page_blocks"`
|
||||||
|
Caption *PageBlockCaption `json:"caption"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
pageBlockEmbeddedPost.Url = tmp.Url
|
||||||
|
pageBlockEmbeddedPost.Author = tmp.Author
|
||||||
|
pageBlockEmbeddedPost.AuthorPhoto = tmp.AuthorPhoto
|
||||||
|
pageBlockEmbeddedPost.Date = tmp.Date
|
||||||
|
pageBlockEmbeddedPost.Caption = tmp.Caption
|
||||||
|
|
||||||
|
fieldPageBlocks, _ := UnmarshalListOfPageBlock(tmp.PageBlocks)
|
||||||
|
pageBlockEmbeddedPost.PageBlocks = fieldPageBlocks
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// A collage
|
// A collage
|
||||||
type PageBlockCollage struct {
|
type PageBlockCollage struct {
|
||||||
meta
|
meta
|
||||||
|
@ -9396,6 +9518,25 @@ func (*PageBlockCollage) PageBlockType() string {
|
||||||
return TypePageBlockCollage
|
return TypePageBlockCollage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pageBlockCollage *PageBlockCollage) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
PageBlocks []json.RawMessage `json:"page_blocks"`
|
||||||
|
Caption *PageBlockCaption `json:"caption"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
pageBlockCollage.Caption = tmp.Caption
|
||||||
|
|
||||||
|
fieldPageBlocks, _ := UnmarshalListOfPageBlock(tmp.PageBlocks)
|
||||||
|
pageBlockCollage.PageBlocks = fieldPageBlocks
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// A slideshow
|
// A slideshow
|
||||||
type PageBlockSlideshow struct {
|
type PageBlockSlideshow struct {
|
||||||
meta
|
meta
|
||||||
|
@ -9425,6 +9566,25 @@ func (*PageBlockSlideshow) PageBlockType() string {
|
||||||
return TypePageBlockSlideshow
|
return TypePageBlockSlideshow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pageBlockSlideshow *PageBlockSlideshow) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
PageBlocks []json.RawMessage `json:"page_blocks"`
|
||||||
|
Caption *PageBlockCaption `json:"caption"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
pageBlockSlideshow.Caption = tmp.Caption
|
||||||
|
|
||||||
|
fieldPageBlocks, _ := UnmarshalListOfPageBlock(tmp.PageBlocks)
|
||||||
|
pageBlockSlideshow.PageBlocks = fieldPageBlocks
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// A link to a chat
|
// A link to a chat
|
||||||
type PageBlockChatLink struct {
|
type PageBlockChatLink struct {
|
||||||
meta
|
meta
|
||||||
|
@ -9545,9 +9705,9 @@ func (*PageBlockDetails) PageBlockType() string {
|
||||||
|
|
||||||
func (pageBlockDetails *PageBlockDetails) UnmarshalJSON(data []byte) error {
|
func (pageBlockDetails *PageBlockDetails) UnmarshalJSON(data []byte) error {
|
||||||
var tmp struct {
|
var tmp struct {
|
||||||
Header json.RawMessage `json:"header"`
|
Header json.RawMessage `json:"header"`
|
||||||
PageBlocks []PageBlock `json:"page_blocks"`
|
PageBlocks []json.RawMessage `json:"page_blocks"`
|
||||||
IsOpen bool `json:"is_open"`
|
IsOpen bool `json:"is_open"`
|
||||||
}
|
}
|
||||||
|
|
||||||
err := json.Unmarshal(data, &tmp)
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
@ -9555,12 +9715,14 @@ func (pageBlockDetails *PageBlockDetails) UnmarshalJSON(data []byte) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
pageBlockDetails.PageBlocks = tmp.PageBlocks
|
|
||||||
pageBlockDetails.IsOpen = tmp.IsOpen
|
pageBlockDetails.IsOpen = tmp.IsOpen
|
||||||
|
|
||||||
fieldHeader, _ := UnmarshalRichText(tmp.Header)
|
fieldHeader, _ := UnmarshalRichText(tmp.Header)
|
||||||
pageBlockDetails.Header = fieldHeader
|
pageBlockDetails.Header = fieldHeader
|
||||||
|
|
||||||
|
fieldPageBlocks, _ := UnmarshalListOfPageBlock(tmp.PageBlocks)
|
||||||
|
pageBlockDetails.PageBlocks = fieldPageBlocks
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9678,6 +9840,31 @@ func (*WebPageInstantView) GetType() string {
|
||||||
return TypeWebPageInstantView
|
return TypeWebPageInstantView
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (webPageInstantView *WebPageInstantView) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
PageBlocks []json.RawMessage `json:"page_blocks"`
|
||||||
|
ViewCount int32 `json:"view_count"`
|
||||||
|
Version int32 `json:"version"`
|
||||||
|
IsRtl bool `json:"is_rtl"`
|
||||||
|
IsFull bool `json:"is_full"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
webPageInstantView.ViewCount = tmp.ViewCount
|
||||||
|
webPageInstantView.Version = tmp.Version
|
||||||
|
webPageInstantView.IsRtl = tmp.IsRtl
|
||||||
|
webPageInstantView.IsFull = tmp.IsFull
|
||||||
|
|
||||||
|
fieldPageBlocks, _ := UnmarshalListOfPageBlock(tmp.PageBlocks)
|
||||||
|
webPageInstantView.PageBlocks = fieldPageBlocks
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Describes a web page preview
|
// Describes a web page preview
|
||||||
type WebPage struct {
|
type WebPage struct {
|
||||||
meta
|
meta
|
||||||
|
@ -10795,12 +10982,12 @@ func (*InputIdentityDocument) GetType() string {
|
||||||
|
|
||||||
func (inputIdentityDocument *InputIdentityDocument) UnmarshalJSON(data []byte) error {
|
func (inputIdentityDocument *InputIdentityDocument) UnmarshalJSON(data []byte) error {
|
||||||
var tmp struct {
|
var tmp struct {
|
||||||
Number string `json:"number"`
|
Number string `json:"number"`
|
||||||
ExpiryDate *Date `json:"expiry_date"`
|
ExpiryDate *Date `json:"expiry_date"`
|
||||||
FrontSide json.RawMessage `json:"front_side"`
|
FrontSide json.RawMessage `json:"front_side"`
|
||||||
ReverseSide json.RawMessage `json:"reverse_side"`
|
ReverseSide json.RawMessage `json:"reverse_side"`
|
||||||
Selfie json.RawMessage `json:"selfie"`
|
Selfie json.RawMessage `json:"selfie"`
|
||||||
Translation []InputFile `json:"translation"`
|
Translation []json.RawMessage `json:"translation"`
|
||||||
}
|
}
|
||||||
|
|
||||||
err := json.Unmarshal(data, &tmp)
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
@ -10810,7 +10997,6 @@ func (inputIdentityDocument *InputIdentityDocument) UnmarshalJSON(data []byte) e
|
||||||
|
|
||||||
inputIdentityDocument.Number = tmp.Number
|
inputIdentityDocument.Number = tmp.Number
|
||||||
inputIdentityDocument.ExpiryDate = tmp.ExpiryDate
|
inputIdentityDocument.ExpiryDate = tmp.ExpiryDate
|
||||||
inputIdentityDocument.Translation = tmp.Translation
|
|
||||||
|
|
||||||
fieldFrontSide, _ := UnmarshalInputFile(tmp.FrontSide)
|
fieldFrontSide, _ := UnmarshalInputFile(tmp.FrontSide)
|
||||||
inputIdentityDocument.FrontSide = fieldFrontSide
|
inputIdentityDocument.FrontSide = fieldFrontSide
|
||||||
|
@ -10821,6 +11007,9 @@ func (inputIdentityDocument *InputIdentityDocument) UnmarshalJSON(data []byte) e
|
||||||
fieldSelfie, _ := UnmarshalInputFile(tmp.Selfie)
|
fieldSelfie, _ := UnmarshalInputFile(tmp.Selfie)
|
||||||
inputIdentityDocument.Selfie = fieldSelfie
|
inputIdentityDocument.Selfie = fieldSelfie
|
||||||
|
|
||||||
|
fieldTranslation, _ := UnmarshalListOfInputFile(tmp.Translation)
|
||||||
|
inputIdentityDocument.Translation = fieldTranslation
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10874,6 +11063,26 @@ func (*InputPersonalDocument) GetType() string {
|
||||||
return TypeInputPersonalDocument
|
return TypeInputPersonalDocument
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (inputPersonalDocument *InputPersonalDocument) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
Files []json.RawMessage `json:"files"`
|
||||||
|
Translation []json.RawMessage `json:"translation"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldFiles, _ := UnmarshalListOfInputFile(tmp.Files)
|
||||||
|
inputPersonalDocument.Files = fieldFiles
|
||||||
|
|
||||||
|
fieldTranslation, _ := UnmarshalListOfInputFile(tmp.Translation)
|
||||||
|
inputPersonalDocument.Translation = fieldTranslation
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// A Telegram Passport element containing the user's personal details
|
// A Telegram Passport element containing the user's personal details
|
||||||
type PassportElementPersonalDetails struct {
|
type PassportElementPersonalDetails struct {
|
||||||
meta
|
meta
|
||||||
|
@ -11599,6 +11808,22 @@ func (*PassportElements) GetType() string {
|
||||||
return TypePassportElements
|
return TypePassportElements
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (passportElements *PassportElements) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
Elements []json.RawMessage `json:"elements"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldElements, _ := UnmarshalListOfPassportElement(tmp.Elements)
|
||||||
|
passportElements.Elements = fieldElements
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// The element contains an error in an unspecified place. The error will be considered resolved when new data is added
|
// The element contains an error in an unspecified place. The error will be considered resolved when new data is added
|
||||||
type PassportElementErrorSourceUnspecified struct {
|
type PassportElementErrorSourceUnspecified struct {
|
||||||
meta
|
meta
|
||||||
|
@ -12007,6 +12232,25 @@ func (*PassportElementsWithErrors) GetType() string {
|
||||||
return TypePassportElementsWithErrors
|
return TypePassportElementsWithErrors
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (passportElementsWithErrors *PassportElementsWithErrors) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
Elements []json.RawMessage `json:"elements"`
|
||||||
|
Errors []*PassportElementError `json:"errors"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
passportElementsWithErrors.Errors = tmp.Errors
|
||||||
|
|
||||||
|
fieldElements, _ := UnmarshalListOfPassportElement(tmp.Elements)
|
||||||
|
passportElementsWithErrors.Elements = fieldElements
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Contains encrypted Telegram Passport data credentials
|
// Contains encrypted Telegram Passport data credentials
|
||||||
type EncryptedCredentials struct {
|
type EncryptedCredentials struct {
|
||||||
meta
|
meta
|
||||||
|
@ -13578,6 +13822,22 @@ func (*MessagePassportDataSent) MessageContentType() string {
|
||||||
return TypeMessagePassportDataSent
|
return TypeMessagePassportDataSent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (messagePassportDataSent *MessagePassportDataSent) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
Types []json.RawMessage `json:"types"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldTypes, _ := UnmarshalListOfPassportElementType(tmp.Types)
|
||||||
|
messagePassportDataSent.Types = fieldTypes
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Telegram Passport data has been received; for bots only
|
// Telegram Passport data has been received; for bots only
|
||||||
type MessagePassportDataReceived struct {
|
type MessagePassportDataReceived struct {
|
||||||
meta
|
meta
|
||||||
|
@ -18448,6 +18708,31 @@ func (*InlineQueryResults) GetType() string {
|
||||||
return TypeInlineQueryResults
|
return TypeInlineQueryResults
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (inlineQueryResults *InlineQueryResults) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
InlineQueryId JsonInt64 `json:"inline_query_id"`
|
||||||
|
NextOffset string `json:"next_offset"`
|
||||||
|
Results []json.RawMessage `json:"results"`
|
||||||
|
SwitchPmText string `json:"switch_pm_text"`
|
||||||
|
SwitchPmParameter string `json:"switch_pm_parameter"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
inlineQueryResults.InlineQueryId = tmp.InlineQueryId
|
||||||
|
inlineQueryResults.NextOffset = tmp.NextOffset
|
||||||
|
inlineQueryResults.SwitchPmText = tmp.SwitchPmText
|
||||||
|
inlineQueryResults.SwitchPmParameter = tmp.SwitchPmParameter
|
||||||
|
|
||||||
|
fieldResults, _ := UnmarshalListOfInlineQueryResult(tmp.Results)
|
||||||
|
inlineQueryResults.Results = fieldResults
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// The payload for a general callback button
|
// The payload for a general callback button
|
||||||
type CallbackQueryPayloadData struct {
|
type CallbackQueryPayloadData struct {
|
||||||
meta
|
meta
|
||||||
|
@ -21963,6 +22248,22 @@ func (*JsonValueArray) JsonValueType() string {
|
||||||
return TypeJsonValueArray
|
return TypeJsonValueArray
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (jsonValueArray *JsonValueArray) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
Values []json.RawMessage `json:"values"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldValues, _ := UnmarshalListOfJsonValue(tmp.Values)
|
||||||
|
jsonValueArray.Values = fieldValues
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Represents a JSON object
|
// Represents a JSON object
|
||||||
type JsonValueObject struct {
|
type JsonValueObject struct {
|
||||||
meta
|
meta
|
||||||
|
@ -22221,6 +22522,22 @@ func (*UserPrivacySettingRules) GetType() string {
|
||||||
return TypeUserPrivacySettingRules
|
return TypeUserPrivacySettingRules
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (userPrivacySettingRules *UserPrivacySettingRules) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
Rules []json.RawMessage `json:"rules"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldRules, _ := UnmarshalListOfUserPrivacySettingRule(tmp.Rules)
|
||||||
|
userPrivacySettingRules.Rules = fieldRules
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// A privacy setting for managing whether the user's online status is visible
|
// A privacy setting for managing whether the user's online status is visible
|
||||||
type UserPrivacySettingShowStatus struct {
|
type UserPrivacySettingShowStatus struct {
|
||||||
meta
|
meta
|
||||||
|
@ -23658,6 +23975,25 @@ func (*NetworkStatistics) GetType() string {
|
||||||
return TypeNetworkStatistics
|
return TypeNetworkStatistics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (networkStatistics *NetworkStatistics) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
SinceDate int32 `json:"since_date"`
|
||||||
|
Entries []json.RawMessage `json:"entries"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
networkStatistics.SinceDate = tmp.SinceDate
|
||||||
|
|
||||||
|
fieldEntries, _ := UnmarshalListOfNetworkStatisticsEntry(tmp.Entries)
|
||||||
|
networkStatistics.Entries = fieldEntries
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Contains auto-download settings
|
// Contains auto-download settings
|
||||||
type AutoDownloadSettings struct {
|
type AutoDownloadSettings struct {
|
||||||
meta
|
meta
|
||||||
|
@ -27521,6 +27857,26 @@ func (*UpdateSuggestedActions) UpdateType() string {
|
||||||
return TypeUpdateSuggestedActions
|
return TypeUpdateSuggestedActions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (updateSuggestedActions *UpdateSuggestedActions) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
AddedActions []json.RawMessage `json:"added_actions"`
|
||||||
|
RemovedActions []json.RawMessage `json:"removed_actions"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldAddedActions, _ := UnmarshalListOfSuggestedAction(tmp.AddedActions)
|
||||||
|
updateSuggestedActions.AddedActions = fieldAddedActions
|
||||||
|
|
||||||
|
fieldRemovedActions, _ := UnmarshalListOfSuggestedAction(tmp.RemovedActions)
|
||||||
|
updateSuggestedActions.RemovedActions = fieldRemovedActions
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// A new incoming inline query; for bots only
|
// A new incoming inline query; for bots only
|
||||||
type UpdateNewInlineQuery struct {
|
type UpdateNewInlineQuery struct {
|
||||||
meta
|
meta
|
||||||
|
@ -27926,6 +28282,22 @@ func (*Updates) GetType() string {
|
||||||
return TypeUpdates
|
return TypeUpdates
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (updates *Updates) UnmarshalJSON(data []byte) error {
|
||||||
|
var tmp struct {
|
||||||
|
Updates []json.RawMessage `json:"updates"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(data, &tmp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldUpdates, _ := UnmarshalListOfUpdate(tmp.Updates)
|
||||||
|
updates.Updates = fieldUpdates
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// The log is written to stderr or an OS specific log
|
// The log is written to stderr or an OS specific log
|
||||||
type LogStreamDefault struct {
|
type LogStreamDefault struct {
|
||||||
meta
|
meta
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -285,10 +285,9 @@ func (entity *tdlibType) GetClass() *tlparser.Class {
|
||||||
func (entity *tdlibType) HasClassProperties() bool {
|
func (entity *tdlibType) HasClassProperties() bool {
|
||||||
for _, prop := range entity.GetType().Properties {
|
for _, prop := range entity.GetType().Properties {
|
||||||
tdlibTypeProperty := TdlibTypeProperty(prop.Name, prop.Type, entity.schema)
|
tdlibTypeProperty := TdlibTypeProperty(prop.Name, prop.Type, entity.schema)
|
||||||
if tdlibTypeProperty.IsClass() && !tdlibTypeProperty.IsList() {
|
if tdlibTypeProperty.IsClass() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -3,7 +3,6 @@ package codegen
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/zelenin/go-tdlib/tlparser"
|
"github.com/zelenin/go-tdlib/tlparser"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -125,11 +124,15 @@ func (*%s) GetType() string {
|
||||||
for _, property := range typ.Properties {
|
for _, property := range typ.Properties {
|
||||||
tdlibTypeProperty := TdlibTypeProperty(property.Name, property.Type, schema)
|
tdlibTypeProperty := TdlibTypeProperty(property.Name, property.Type, schema)
|
||||||
|
|
||||||
if !tdlibTypeProperty.IsClass() || tdlibTypeProperty.IsList() {
|
if !tdlibTypeProperty.IsClass() {
|
||||||
buf.WriteString(fmt.Sprintf(" %s %s `json:\"%s\"`\n", tdlibTypeProperty.ToGoName(), tdlibTypeProperty.ToGoType(), property.Name))
|
buf.WriteString(fmt.Sprintf(" %s %s `json:\"%s\"`\n", tdlibTypeProperty.ToGoName(), tdlibTypeProperty.ToGoType(), property.Name))
|
||||||
countSimpleProperties++
|
countSimpleProperties++
|
||||||
} else {
|
} else {
|
||||||
buf.WriteString(fmt.Sprintf(" %s %s `json:\"%s\"`\n", tdlibTypeProperty.ToGoName(), "json.RawMessage", property.Name))
|
if tdlibTypeProperty.IsList() {
|
||||||
|
buf.WriteString(fmt.Sprintf(" %s %s `json:\"%s\"`\n", tdlibTypeProperty.ToGoName(), "[]json.RawMessage", property.Name))
|
||||||
|
} else {
|
||||||
|
buf.WriteString(fmt.Sprintf(" %s %s `json:\"%s\"`\n", tdlibTypeProperty.ToGoName(), "json.RawMessage", property.Name))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +148,7 @@ func (*%s) GetType() string {
|
||||||
for _, property := range typ.Properties {
|
for _, property := range typ.Properties {
|
||||||
tdlibTypeProperty := TdlibTypeProperty(property.Name, property.Type, schema)
|
tdlibTypeProperty := TdlibTypeProperty(property.Name, property.Type, schema)
|
||||||
|
|
||||||
if !tdlibTypeProperty.IsClass() || tdlibTypeProperty.IsList() {
|
if !tdlibTypeProperty.IsClass() {
|
||||||
buf.WriteString(fmt.Sprintf(" %s.%s = tmp.%s\n", typ.Name, tdlibTypeProperty.ToGoName(), tdlibTypeProperty.ToGoName()))
|
buf.WriteString(fmt.Sprintf(" %s.%s = tmp.%s\n", typ.Name, tdlibTypeProperty.ToGoName(), tdlibTypeProperty.ToGoName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,6 +166,12 @@ func (*%s) GetType() string {
|
||||||
|
|
||||||
`, tdlibTypeProperty.ToGoName(), tdlibTypeProperty.ToGoType(), tdlibTypeProperty.ToGoName(), typ.Name, tdlibTypeProperty.ToGoName(), tdlibTypeProperty.ToGoName()))
|
`, tdlibTypeProperty.ToGoName(), tdlibTypeProperty.ToGoType(), tdlibTypeProperty.ToGoName(), typ.Name, tdlibTypeProperty.ToGoName(), tdlibTypeProperty.ToGoName()))
|
||||||
}
|
}
|
||||||
|
if tdlibTypeProperty.IsClass() && tdlibTypeProperty.IsList() {
|
||||||
|
buf.WriteString(fmt.Sprintf(` field%s, _ := UnmarshalListOf%s(tmp.%s)
|
||||||
|
%s.%s = field%s
|
||||||
|
|
||||||
|
`, tdlibTypeProperty.ToGoName(), tdlibTypeProperty.GetClass().ToGoType(), tdlibTypeProperty.ToGoName(), typ.Name, tdlibTypeProperty.ToGoName(), tdlibTypeProperty.ToGoName()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.WriteString(` return nil
|
buf.WriteString(` return nil
|
||||||
|
|
|
@ -46,6 +46,23 @@ func GenerateUnmarshalers(schema *tlparser.Schema, packageName string) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
buf.WriteString(fmt.Sprintf(`func UnmarshalListOf%s(dataList []json.RawMessage) ([]%s, error) {
|
||||||
|
list := []%s{}
|
||||||
|
|
||||||
|
for _, data := range dataList {
|
||||||
|
entity, err := Unmarshal%s(data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list = append(list, entity)
|
||||||
|
}
|
||||||
|
|
||||||
|
return list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
`, tdlibClass.ToGoType(), tdlibClass.ToGoType(), tdlibClass.ToGoType(), tdlibClass.ToGoType()))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, typ := range schema.Types {
|
for _, typ := range schema.Types {
|
||||||
|
|
Loading…
Reference in a new issue