Skip to content

Conversation

@MarcoBuster
Copy link
Member

In upcoming Telegram bots API upgrade, bots will able to delete messages sent by itself and sent by users in a supergroup where the bot is admin.
I've added two new methods, message.delete() and chat.delete_message().

Example usage:

@bot.command("delete") def delete(chat, message, args): if message.reply_to_message: message.reply_to_message.delete() else: message.reply("Reply to a message to delete it!") return message.delete() msg = chat.send("Message deleted, sir!") time.sleep(5) chat.delete_message(msg) # Or msg.delete()
return self._api.call("sendContact", args, expect=_objects().Message)

@_require_api
def delete_message(self, message):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to add the docstring.

message = message.message_id

return self._api.call("deleteMessage", {
"chat_id": self.id, "message_id": message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put all of these on their own line, with a traling comma in all of them?

{ "chat_id": self.id, "message_id": message, }
def delete(self):
"""Delete the message"""
return self._api.call("deleteMessage", {"chat_id": self.chat.id,
"message_id": self.message_id})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the same style for the parameters as the other method.

Delete the selected message.
A message can be deleted only if is sent by the bot or sent in a supergroup by an user where the bot is admin.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to add the versionadded (0.4) and the documentation for the parameter.

Delete the message self.
A message can be deleted only if is sent by the bot or sent in a supergroup by an user where the bot is admin.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to add the versionadded (0.4)

@pietroalbini pietroalbini added this to the botogram 0.4 milestone May 7, 2017
@MarcoBuster
Copy link
Member Author

@pietroalbini Done, it's all ok, right?

pietroalbini
pietroalbini previously approved these changes May 7, 2017
Copy link
Contributor

@pietroalbini pietroalbini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

pietroalbini
pietroalbini previously approved these changes May 7, 2017
Copy link
Contributor

@pietroalbini pietroalbini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MarcoBuster
Copy link
Member Author

MarcoBuster commented May 21, 2017

@pietroalbini Maybe we're ready to merge?

@pietroalbini
Copy link
Contributor

Can you add in the docs that in supergroups it's possibile to delete some service messages?


.. py:method:: delete()
Delete the message self.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What? "Delete this message. The message can be deleted only if... It can also be deleted if it's one of the supported service messages."


.. py:method:: delete_message(message)
Delete the selected message.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Delete the message with the provided ID"

Copy link
Member Author

@MarcoBuster MarcoBuster Jun 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...or botogram.Message object

Copy link
Contributor

@pietroalbini pietroalbini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pietroalbini pietroalbini merged commit 2ce9f50 into python-botogram:master Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants