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
12 changes: 7 additions & 5 deletions telegram/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,20 @@ def send_message(self,
@log
@message
def delete_message(self, chat_id, message_id):
"""Use this method to delete messages which were sent not later than 48 hours ago.
"""Use this method to delete a message. A message can only be deleted if it was sent less
than 48 hours ago. Any such recently sent outgoing message may be deleted. Additionally,
if the bot is an administrator in a group chat, it can delete any message. If the bot is
an administrator in a supergroup, it can delete messages from any other user and service
messages about people joining or leaving the group (other types of service messages may
only be removed by the group creator). In channels, bots can only remove their own
messages.

Args:
chat_id (int|str): Unique identifier for the target chat or
username of the target channel (in the format
@channelusername).
message_id (int): Unique message identifier.

Note:
This method is not documented, so it's not guaranteed to work. Also, its behaviour can
be changed at any time.

Returns:
bool: On success, `True` is returned.

Expand Down
4 changes: 0 additions & 4 deletions telegram/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,6 @@ def delete(self, *args, **kwargs):
... message_id=message.message_id,
... *args, **kwargs)

Note:
This method is not documented, so it's not guaranteed to work. Also, its behaviour can
be changed at any time.

Returns:
bool: On success, `True` is returned.

Expand Down
2 changes: 0 additions & 2 deletions tests/test_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ def test_deleteMessage(self):
@timeout(10)
def test_deleteMessage_old_message(self):
with self.assertRaisesRegexp(telegram.TelegramError, "can't be deleted"):
# NOTE: This behaviour can be changed in future because `deleteMessage` method is not
# documented in Bot API reference now.
# Considering that the first message is old enough
self._bot.delete_message(chat_id=self._chat_id, message_id=1)

Expand Down
1 change: 0 additions & 1 deletion tests/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ def test_delete2(self):
reply_to_message_id=1)

with self.assertRaisesRegexp(telegram.TelegramError, "can't be deleted"):
# NOTE: This behaviour can be changed in future. See `tests/test_bot.py` for more info
message.reply_to_message.delete()

def test_equality(self):
Expand Down