From 23863c587c918e1017fd7250ec5dc3600d65e3c2 Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Tue, 30 May 2017 22:50:44 +0300 Subject: [PATCH] Refactor send document --- aiogram/bot.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/aiogram/bot.py b/aiogram/bot.py index 5f0773c1..52c86e25 100644 --- a/aiogram/bot.py +++ b/aiogram/bot.py @@ -158,3 +158,15 @@ class AIOGramBot: payload = generate_payload(**locals(), exclude=[_METHOD]) return await self._send_file(_METHOD, audio, payload) + + async def send_document(self, chat_id, document, caption=None, disable_notification=None, reply_to_message_id=None, + reply_markup=None): + _METHOD = 'document' + if reply_markup and hasattr(reply_markup, 'to_json'): + reply_markup = json.dumps(reply_markup.to_json()) + + if hasattr(reply_to_message_id, 'message_id'): + reply_to_message_id = reply_to_message_id.message_id + + payload = generate_payload(**locals(), exclude=['document']) + return await self._send_file(_METHOD, document, payload)