Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ htmlcov/
.coverage
.coverage.*
.cache
.pytest_cache
nosetests.xml
coverage.xml
*,cover
Expand Down
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `njittam <https://github.com/njittam>`_
- `Noam Meltzer <https://github.com/tsnoam>`_
- `Oleg Shlyazhko <https://github.com/ollmer>`_
- `Oleg Sushchenko <https://github.com/feuillemorte>`_
- `overquota <https://github.com/overquota>`_
- `Patrick Hofmann <https://github.com/PH89>`_
- `Pieter Schutz <https://github.com/eldinnie>`_
Expand Down
20 changes: 20 additions & 0 deletions telegram/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,26 @@ def reply_html(self, *args, **kwargs):

return self.bot.send_message(self.chat_id, *args, **kwargs)

def reply_media_group(self, *args, **kwargs):
"""Shortcut for::

bot.reply_media_group(update.message.chat_id, *args, **kwargs)

Keyword Args:
quote (:obj:`bool`, optional): If set to ``True``, the media group is sent as an
actual reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``,
this parameter will be ignored. Default: ``True`` in group chats and ``False`` in
private chats.

Returns:
List[:class:`telegram.Message`]: An array of the sent Messages.

Raises:
:class:`telegram.TelegramError`
"""
self._quote(kwargs)
return self.bot.send_media_group(self.chat_id, *args, **kwargs)

def reply_photo(self, *args, **kwargs):
"""Shortcut for::

Expand Down
14 changes: 14 additions & 0 deletions tests/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,20 @@ def test(*args, **kwargs):
reply_to_message_id=message.message_id,
quote=True)

def test_reply_media_group(self, monkeypatch, message):
def test(*args, **kwargs):
id = args[1] == message.chat_id
media = kwargs['media'] == 'reply_media_group'
if kwargs.get('reply_to_message_id'):
reply = kwargs['reply_to_message_id'] == message.message_id
else:
reply = True
return id and media and reply

monkeypatch.setattr('telegram.Bot.send_media_group', test)
assert message.reply_media_group(media='reply_media_group')
assert message.reply_media_group(media='reply_media_group', quote=True)

def test_reply_photo(self, monkeypatch, message):
def test(*args, **kwargs):
id = args[1] == message.chat_id
Expand Down