1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Added option to delete messages.

Added option to delete messages.

Some bots do not support this method now, waiting for an official api
release.
This commit is contained in:
Kylmakalle 2017-05-07 17:37:03 +03:00
parent 8bf226e6bf
commit f7cfb98b60
2 changed files with 16 additions and 0 deletions

View File

@ -33,6 +33,7 @@ class TeleBot:
getMe
sendMessage
forwardMessage
deleteMessage
sendPhoto
sendAudio
sendDocument
@ -408,6 +409,15 @@ class TeleBot:
return types.Message.de_json(
apihelper.forward_message(self.token, chat_id, from_chat_id, message_id, disable_notification))
def delete_message(self, chat_id, message_id):
"""
Use this method to delete message. Returns True on success.
:param chat_id: in which chat to delete
:param message_id: which message to delete
:return: API reply.
"""
return types.Message.de_json(apihelper.delete_message(self.token, chat_id, message_id))
def send_photo(self, chat_id, photo, caption=None, reply_to_message_id=None, reply_markup=None,
disable_notification=None):
"""

View File

@ -446,6 +446,12 @@ def edit_message_reply_markup(token, chat_id=None, message_id=None, inline_messa
return _make_request(token, method_url, params=payload)
def delete_message(token, chat_id=None, message_id=None):
method_url = r'deleteMessage'
payload = {'chat_id': chat_id, 'message_id': message_id}
return _make_request(token, method_url, params=payload)
# Game
def send_game(token, chat_id, game_short_name, disable_notification=None, reply_to_message_id=None, reply_markup=None):