From c1bb900d918af3c8618acd4b6aa0e77c85df3668 Mon Sep 17 00:00:00 2001 From: eternnoir Date: Tue, 14 Jul 2015 13:24:32 +0800 Subject: [PATCH] send file, photo ...etc. by ID support. #35 --- telebot/apihelper.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 0715f2b..534835b 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -87,7 +87,11 @@ def forward_message(token, chat_id, from_chat_id, message_id): def send_photo(token, chat_id, photo, caption=None, reply_to_message_id=None, reply_markup=None): method_url = r'sendPhoto' payload = {'chat_id': chat_id} - files = {'photo': photo} + files = None + if isinstance(photo, file): + files = {'photo': photo} + else: + payload['photo'] = photo if caption: payload['caption'] = caption if reply_to_message_id: @@ -116,7 +120,11 @@ def send_chat_action(token, chat_id, action): def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_markup=None): method_url = get_method_by_type(data_type) payload = {'chat_id': chat_id} - files = {data_type: data} + files = None + if isinstance(data, file): + files = {data_type: data} + else: + payload[data_type] = data if reply_to_message_id: payload['reply_to_message_id'] = reply_to_message_id if reply_markup: