@@ -257,13 +257,14 @@ def send_photo(token, chat_id, photo, caption=None, reply_to_message_id=None, re
257257
258258def send_media_group (token , chat_id , media , disable_notification = None , reply_to_message_id = None ):
259259 method_url = r'sendMediaGroup'
260- media_json = _convert_list_json_serializable (media )
260+ media_json , files = _convert_input_media (media )
261261 payload = {'chat_id' : chat_id , 'media' : media_json }
262262 if disable_notification :
263263 payload ['disable_notification' ] = disable_notification
264264 if reply_to_message_id :
265265 payload ['reply_to_message_id' ] = reply_to_message_id
266- return _make_request (token , method_url , params = payload )
266+ return _make_request (token , method_url , params = payload , method = 'post' if files else 'get' ,
267+ files = files if files else None )
267268
268269
269270def send_location (token , chat_id , latitude , longitude , live_period = None , reply_to_message_id = None , reply_markup = None ,
@@ -916,6 +917,19 @@ def _convert_markup(markup):
916917 return markup
917918
918919
920+ def _convert_input_media (array ):
921+ media = []
922+ files = {}
923+ for input_media in array :
924+ if isinstance (input_media , types .JsonSerializable ):
925+ media_dict = input_media .to_dic ()
926+ if media_dict ['media' ].startswith ('attach://' ):
927+ key = media_dict ['media' ].replace ('attach://' , '' )
928+ files [key ] = input_media .media
929+ media .append (media_dict )
930+ return json .dumps (media ), files
931+
932+
919933def _no_encode (func ):
920934 def wrapper (key , val ):
921935 if key == 'filename' :
0 commit comments