From 4a761d0611a3b78e206906ce0e8dc9c5a7b21c97 Mon Sep 17 00:00:00 2001 From: ErgoZ Date: Tue, 8 Sep 2015 20:43:28 +0300 Subject: [PATCH] Add ability to set custom filename (fix InputFile class) For commands that uses InputFile class --- telegram/inputfile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/telegram/inputfile.py b/telegram/inputfile.py index 0d27ff194..ee77fe0e3 100644 --- a/telegram/inputfile.py +++ b/telegram/inputfile.py @@ -67,7 +67,10 @@ class InputFile(object): if isinstance(self.input_file, file): self.input_file_content = self.input_file.read() - self.filename = os.path.basename(self.input_file.name) + if self.data.has_key('filename') and self.data['filename']: + self.filename = self.data['filename'] + else: + self.filename = os.path.basename(self.input_file.name) self.mimetype = mimetypes.guess_type(self.filename)[0] or \ DEFAULT_MIME_TYPE