在telegram.org api架构中,message
类型定义如下:
消息#c09be45f flags:#out:flags.1?true提到:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true id:int from_id:flags .8?int to_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?int reply_to_msg_id:flags.3?int date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup实体: flags.7?向量视图:flags.10?int edit_date:flags.15?int = Message;
请注意,可选参数media:flags.9?MessageMedia
定义为类型MessageMedia
。但是没有定义MessageMedia
,所以我的客户端不知道如何序列化/反序列化它。
MessageMedia
的类型是什么,以及如何处理可能未定义的其他类型?
答案 0 :(得分:0)
理解这一点的最佳方式是media:flags.9?MessageMedia
代表一般类型或他们说a base type
可以是以下任何类型:
messageMediaEmpty#3ded6320 = MessageMedia;
messageMediaPhoto#3d8ce53d photo:Photo caption:string = MessageMedia;
messageMediaGeo#56e0d474 geo:GeoPoint = MessageMedia;
messageMediaContact#5e7d2f39 phone_number:string first_name:string last_name:string user_id:int = MessageMedia;
messageMediaUnsupported#9f84f49e = MessageMedia;
messageMediaDocument#f3e02ea8 document:Document caption:string = MessageMedia;
messageMediaWebPage#a32dd600 webpage:WebPage = MessageMedia;
messageMediaVenue#7912b71f geo:GeoPoint title:string address:string provider:string venue_id:string = MessageMedia;
此模式在Telegram API中很常见