Fix Empty Captions not Being Passed by Bot.copy_message (#2651)

This commit is contained in:
DonalDuck004 2021-09-09 07:50:04 +02:00 committed by GitHub
parent 0c5085022c
commit a25c76e6a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View file

@ -39,6 +39,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `daimajia <https://github.com/daimajia>`_
- `Daniel Reed <https://github.com/nmlorg>`_
- `D David Livingston <https://github.com/daviddl9>`_
- `DonalDuck004 <https://github.com/DonalDuck004>`_
- `Eana Hufwe <https://github.com/blueset>`_
- `Ehsan Online <https://github.com/ehsanonline>`_
- `Eli Gao <https://github.com/eligao>`_

View file

@ -5296,7 +5296,7 @@ class Bot(TelegramObject):
'disable_notification': disable_notification,
'allow_sending_without_reply': allow_sending_without_reply,
}
if caption:
if caption is not None:
data['caption'] = caption
if caption_entities:
data['caption_entities'] = caption_entities

View file

@ -2024,7 +2024,8 @@ class TestBot:
@flaky(3, 1)
@pytest.mark.parametrize('json_keyboard', [True, False])
def test_copy_message(self, monkeypatch, bot, chat_id, media_message, json_keyboard):
@pytest.mark.parametrize('caption', ["<b>Test</b>", '', None])
def test_copy_message(self, monkeypatch, bot, chat_id, media_message, json_keyboard, caption):
keyboard = InlineKeyboardMarkup(
[[InlineKeyboardButton(text="test", callback_data="test2")]]
)
@ -2033,7 +2034,7 @@ class TestBot:
assert data["chat_id"] == chat_id
assert data["from_chat_id"] == chat_id
assert data["message_id"] == media_message.message_id
assert data["caption"] == "<b>Test</b>"
assert data.get("caption") == caption
assert data["parse_mode"] == ParseMode.HTML
assert data["reply_to_message_id"] == media_message.message_id
assert data["reply_markup"] == keyboard.to_json()
@ -2046,7 +2047,7 @@ class TestBot:
chat_id,
from_chat_id=chat_id,
message_id=media_message.message_id,
caption="<b>Test</b>",
caption=caption,
caption_entities=[MessageEntity(MessageEntity.BOLD, 0, 4)],
parse_mode=ParseMode.HTML,
reply_to_message_id=media_message.message_id,