mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-08 17:13:56 +00:00
Fix filename in InputFile and provide to change filename in send_document.
This commit is contained in:
parent
e9a3ca6c8e
commit
7ffeb8ff57
3 changed files with 12 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from .bot import Bot
|
||||
from .utils.versions import Version, Stage
|
||||
|
||||
VERSION = Version(0, 4, 1, stage=Stage.DEV, build=0)
|
||||
VERSION = Version(0, 4, 2, stage=Stage.DEV, build=0)
|
||||
|
||||
__version__ = VERSION.version
|
||||
|
|
|
|||
|
|
@ -164,8 +164,6 @@ class BaseBot:
|
|||
# You can use file ID or URL in the most of requests
|
||||
payload[file_type] = file
|
||||
files = None
|
||||
elif isinstance(file, (io.IOBase, io.FileIO)):
|
||||
files = {file_type: file.read()}
|
||||
else:
|
||||
files = {file_type: file}
|
||||
|
||||
|
|
@ -435,7 +433,8 @@ class BaseBot:
|
|||
disable_notification: Optional[Boolean] = None,
|
||||
reply_to_message_id: Optional[Integer] = None,
|
||||
reply_markup: Optional[Union[
|
||||
types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String]] = None) -> Dict:
|
||||
types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String]] = None,
|
||||
filename: Optional[str]=None) -> Dict:
|
||||
"""
|
||||
Use this method to send general files. On success, the sent Message is returned.
|
||||
Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
|
||||
|
|
@ -456,10 +455,13 @@ class BaseBot:
|
|||
:param reply_markup: Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String] (Optional)
|
||||
- Additional interface options. A JSON-serialized object for an inline keyboard,
|
||||
custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
||||
:param filename: Set file name
|
||||
:return: On success, the sent Message is returned.
|
||||
"""
|
||||
reply_markup = prepare_arg(reply_markup)
|
||||
payload = generate_payload(**locals(), exclude=['document'])
|
||||
if filename:
|
||||
document = (filename, document)
|
||||
payload = generate_payload(**locals(), exclude=['document', 'filename'])
|
||||
|
||||
return await self.send_file('document', api.Methods.SEND_DOCUMENT, document, payload)
|
||||
|
||||
|
|
|
|||
|
|
@ -272,7 +272,8 @@ class Bot(BaseBot):
|
|||
reply_to_message_id: Optional[Integer] = None,
|
||||
reply_markup: Optional[Union[
|
||||
types.InlineKeyboardMarkup,
|
||||
types.ReplyKeyboardMarkup, Dict, String]] = None) -> types.Message:
|
||||
types.ReplyKeyboardMarkup, Dict, String]] = None,
|
||||
filename: Optional[str] = None) -> types.Message:
|
||||
"""
|
||||
Use this method to send general files. On success, the sent Message is returned.
|
||||
Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
|
||||
|
|
@ -293,12 +294,14 @@ class Bot(BaseBot):
|
|||
:param reply_markup: Union[types.InlineKeyboardMarkup, types.ReplyKeyboardMarkup, Dict, String] (Optional)
|
||||
- Additional interface options. A JSON-serialized object for an inline keyboard,
|
||||
custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
||||
:param filename: Set file name
|
||||
:return: On success, the sent Message is returned. (serialized)
|
||||
"""
|
||||
raw = super(Bot, self).send_document(chat_id=chat_id, document=document, caption=caption,
|
||||
disable_notification=disable_notification,
|
||||
reply_to_message_id=reply_to_message_id,
|
||||
reply_markup=reply_markup)
|
||||
reply_markup=reply_markup,
|
||||
filename=filename)
|
||||
return self.prepare_object(types.Message.deserialize(await raw))
|
||||
|
||||
async def send_video(self, chat_id: Union[Integer, String],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue