@@ -56,19 +56,23 @@ func fullMessage() *Message {
5656 MediaGroupID : "mg" ,
5757 AuthorSignature : "auth" ,
5858 Text : "hello" ,
59- Entities : []MessageEntity {{Type : EntityBold , Offset : 0 , Length : 5 }, {Type : EntityTextMention , Offset : 1 , Length : 2 , User : user , URL : "u" , Language : "go" , CustomEmojiID : "e" }},
60- Caption : "cap" ,
61- CaptionEntities : []MessageEntity {{Type : EntityItalic , Offset : 0 , Length : 3 }},
62- Animation : & Animation {FileID : "a" , FileUniqueID : "au" , Width : 1 , Height : 2 , Duration : 3 , Thumbnail : thumb , FileName : "a.gif" , MIMEType : "image/gif" , FileSize : 4 },
63- Audio : & Audio {FileID : "b" , FileUniqueID : "bu" , Duration : 10 , Performer : "p" , Title : "t" , FileName : "b.mp3" , MIMEType : "audio/mpeg" , FileSize : 5 , Thumbnail : thumb },
64- Document : & Document {FileID : "c" , FileUniqueID : "cu" , Thumbnail : thumb , FileName : "c.pdf" , MIMEType : "application/pdf" , FileSize : 6 },
65- Photo : []PhotoSize {{FileID : "p1" , FileUniqueID : "p1u" , Width : 100 , Height : 200 , FileSize : 7 }},
66- Sticker : & Sticker {FileID : "s" , FileUniqueID : "su" , Type : StickerRegular , Width : 512 , Height : 512 , IsAnimated : true , IsVideo : true , Thumbnail : thumb , Emoji : "🙂" , SetName : "set" , FileSize : 8 },
67- Video : & Video {FileID : "v" , FileUniqueID : "vu" , Width : 640 , Height : 480 , Duration : 12 , Thumbnail : thumb , FileName : "v.mp4" , MIMEType : "video/mp4" , FileSize : 9 },
68- VideoNote : & VideoNote {FileID : "vn" , FileUniqueID : "vnu" , Length : 240 , Duration : 6 , Thumbnail : thumb , FileSize : 11 },
69- Voice : & Voice {FileID : "vo" , FileUniqueID : "vou" , Duration : 4 , MIMEType : "audio/ogg" , FileSize : 12 },
70- Contact : & Contact {PhoneNumber : "+1" , FirstName : "Ada" , LastName : "L" , UserID : 1 , VCard : "vc" },
71- Dice : & Dice {Emoji : DiceDart , Value : 6 },
59+ Entities : []MessageEntity {
60+ {Type : EntityBold , Offset : 0 , Length : 5 },
61+ {Type : EntityTextMention , Offset : 1 , Length : 2 , User : user , URL : "u" , Language : "go" , CustomEmojiID : "e" },
62+ {Type : EntityDateTime , Offset : 3 , Length : 4 , UnixTime : 1781027109 , DateTimeFormat : "wdt" },
63+ },
64+ Caption : "cap" ,
65+ CaptionEntities : []MessageEntity {{Type : EntityItalic , Offset : 0 , Length : 3 }},
66+ Animation : & Animation {FileID : "a" , FileUniqueID : "au" , Width : 1 , Height : 2 , Duration : 3 , Thumbnail : thumb , FileName : "a.gif" , MIMEType : "image/gif" , FileSize : 4 },
67+ Audio : & Audio {FileID : "b" , FileUniqueID : "bu" , Duration : 10 , Performer : "p" , Title : "t" , FileName : "b.mp3" , MIMEType : "audio/mpeg" , FileSize : 5 , Thumbnail : thumb },
68+ Document : & Document {FileID : "c" , FileUniqueID : "cu" , Thumbnail : thumb , FileName : "c.pdf" , MIMEType : "application/pdf" , FileSize : 6 },
69+ Photo : []PhotoSize {{FileID : "p1" , FileUniqueID : "p1u" , Width : 100 , Height : 200 , FileSize : 7 }},
70+ Sticker : & Sticker {FileID : "s" , FileUniqueID : "su" , Type : StickerRegular , Width : 512 , Height : 512 , IsAnimated : true , IsVideo : true , Thumbnail : thumb , Emoji : "🙂" , SetName : "set" , FileSize : 8 },
71+ Video : & Video {FileID : "v" , FileUniqueID : "vu" , Width : 640 , Height : 480 , Duration : 12 , Thumbnail : thumb , FileName : "v.mp4" , MIMEType : "video/mp4" , FileSize : 9 },
72+ VideoNote : & VideoNote {FileID : "vn" , FileUniqueID : "vnu" , Length : 240 , Duration : 6 , Thumbnail : thumb , FileSize : 11 },
73+ Voice : & Voice {FileID : "vo" , FileUniqueID : "vou" , Duration : 4 , MIMEType : "audio/ogg" , FileSize : 12 },
74+ Contact : & Contact {PhoneNumber : "+1" , FirstName : "Ada" , LastName : "L" , UserID : 1 , VCard : "vc" },
75+ Dice : & Dice {Emoji : DiceDart , Value : 6 },
7276 Poll : & Poll {
7377 ID : "poll1" ,
7478 Question : "q?" ,
@@ -164,6 +168,7 @@ func TestLeafEntitiesJSON(t *testing.T) {
164168 jsonRoundTrip (t , Voice {FileID : "vo" , FileUniqueID : "vou" , Duration : 3 , MIMEType : "m" , FileSize : 10 })
165169 jsonRoundTrip (t , Sticker {FileID : "s" , FileUniqueID : "su" , Type : StickerMask , Width : 1 , Height : 2 , IsAnimated : true , IsVideo : true , Thumbnail : thumb , Emoji : "x" , SetName : "set" , FileSize : 11 })
166170 jsonRoundTrip (t , MessageEntity {Type : EntityTextLink , Offset : 1 , Length : 2 , URL : "u" , User : & User {ID : 1 , FirstName : "A" }, Language : "go" , CustomEmojiID : "e" })
171+ jsonRoundTrip (t , MessageEntity {Type : EntityDateTime , Offset : 0 , Length : 10 , UnixTime : 1781027109 , DateTimeFormat : "wdt" })
167172 jsonRoundTrip (t , Contact {PhoneNumber : "+1" , FirstName : "A" , LastName : "B" , UserID : 1 , VCard : "v" })
168173 jsonRoundTrip (t , Dice {Emoji : DiceBasketball , Value : 5 })
169174 jsonRoundTrip (t , Location {Longitude : 1.5 , Latitude : 2.25 , HorizontalAccuracy : 0.5 , LivePeriod : 60 , Heading : 90 , ProximityAlertRadius : 10 })
@@ -219,6 +224,8 @@ func TestDecodeTypeMismatch(t *testing.T) {
219224 `{"photo":5}` , // array field, number value
220225 `{"reply_markup":{"inline_keyboard":7}}` , // nested array, number value
221226 `{"forward_origin":{"type":"user","date":"x"}}` , // union variant, bad field
227+ `{"entities":[{"unix_time":"string"}]}` , // int field, string value
228+ `{"entities":[{"date_time_format":12345}]}` , // string field, number value
222229 }
223230 for _ , c := range cases {
224231 var m Message
0 commit comments