3131import os
3232import sys
3333
34- from future .moves .urllib .request import urlopen
35-
3634from telegram import TelegramError
3735
3836DEFAULT_MIME_TYPE = 'application/octet-stream'
@@ -49,32 +47,28 @@ def __init__(self, data):
4947 if 'audio' in data :
5048 self .input_name = 'audio'
5149 self .input_file = data .pop ('audio' )
52- if 'document' in data :
50+ elif 'document' in data :
5351 self .input_name = 'document'
5452 self .input_file = data .pop ('document' )
55- if 'photo' in data :
53+ elif 'photo' in data :
5654 self .input_name = 'photo'
5755 self .input_file = data .pop ('photo' )
58- if 'sticker' in data :
56+ elif 'sticker' in data :
5957 self .input_name = 'sticker'
6058 self .input_file = data .pop ('sticker' )
61- if 'video' in data :
59+ elif 'video' in data :
6260 self .input_name = 'video'
6361 self .input_file = data .pop ('video' )
64- if 'voice' in data :
62+ elif 'voice' in data :
6563 self .input_name = 'voice'
6664 self .input_file = data .pop ('voice' )
67- if 'certificate' in data :
65+ elif 'certificate' in data :
6866 self .input_name = 'certificate'
6967 self .input_file = data .pop ('certificate' )
70-
71- if str (self .input_file ).startswith ('http' ):
72- from_url = True
73- self .input_file = urlopen (self .input_file )
7468 else :
75- from_url = False
69+ raise TelegramError ( 'Unknown inputfile type' )
7670
77- if hasattr (self .input_file , 'read' ) or from_url :
71+ if hasattr (self .input_file , 'read' ):
7872 self .filename = None
7973 self .input_file_content = self .input_file .read ()
8074 if 'filename' in data :
@@ -83,8 +77,6 @@ def __init__(self, data):
8377 # on py2.7, pylint fails to understand this properly
8478 # pylint: disable=E1101
8579 self .filename = os .path .basename (self .input_file .name )
86- elif from_url :
87- self .filename = os .path .basename (self .input_file .url ).split ('?' )[0 ].split ('&' )[0 ]
8880
8981 try :
9082 self .mimetype = InputFile .is_image (self .input_file_content )
@@ -186,6 +178,6 @@ def is_inputfile(data):
186178 if file_type :
187179 file_content = data [file_type [0 ]]
188180
189- return hasattr (file_content , 'read' ) or str ( file_content ). startswith ( 'http' )
181+ return hasattr (file_content , 'read' )
190182
191183 return False
0 commit comments