Skip to content

Commit c2c5452

Browse files
evgfilim1jh0ker
authored andcommitted
Updated docstring in deleteMessage methods (python-telegram-bot#618)
* Removed "undocumented" notice * Updated docstring according to Bot API documentation * Removed extra line
1 parent 9aa5522 commit c2c5452

4 files changed

Lines changed: 7 additions & 12 deletions

File tree

telegram/bot.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,20 @@ def send_message(self,
244244
@log
245245
@message
246246
def delete_message(self, chat_id, message_id):
247-
"""Use this method to delete messages which were sent not later than 48 hours ago.
247+
"""Use this method to delete a message. A message can only be deleted if it was sent less
248+
than 48 hours ago. Any such recently sent outgoing message may be deleted. Additionally,
249+
if the bot is an administrator in a group chat, it can delete any message. If the bot is
250+
an administrator in a supergroup, it can delete messages from any other user and service
251+
messages about people joining or leaving the group (other types of service messages may
252+
only be removed by the group creator). In channels, bots can only remove their own
253+
messages.
248254
249255
Args:
250256
chat_id (int|str): Unique identifier for the target chat or
251257
username of the target channel (in the format
252258
@channelusername).
253259
message_id (int): Unique message identifier.
254260
255-
Note:
256-
This method is not documented, so it's not guaranteed to work. Also, its behaviour can
257-
be changed at any time.
258-
259261
Returns:
260262
bool: On success, `True` is returned.
261263

telegram/message.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,10 +551,6 @@ def delete(self, *args, **kwargs):
551551
... message_id=message.message_id,
552552
... *args, **kwargs)
553553
554-
Note:
555-
This method is not documented, so it's not guaranteed to work. Also, its behaviour can
556-
be changed at any time.
557-
558554
Returns:
559555
bool: On success, `True` is returned.
560556

tests/test_bot.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ def test_deleteMessage(self):
9696
@timeout(10)
9797
def test_deleteMessage_old_message(self):
9898
with self.assertRaisesRegexp(telegram.TelegramError, "can't be deleted"):
99-
# NOTE: This behaviour can be changed in future because `deleteMessage` method is not
100-
# documented in Bot API reference now.
10199
# Considering that the first message is old enough
102100
self._bot.delete_message(chat_id=self._chat_id, message_id=1)
103101

tests/test_message.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ def test_delete2(self):
152152
reply_to_message_id=1)
153153

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

158157
def test_equality(self):

0 commit comments

Comments
 (0)