Merge branch 'master' into docs

This commit is contained in:
Dan 2018-01-13 15:53:40 +01:00
commit b21cdc94a7
2 changed files with 38 additions and 39 deletions

View File

@ -13,12 +13,10 @@ Table of Contents
- `Installation`_ - `Installation`_
- `Setup`_ - `Configuration`_
- `Usage`_ - `Usage`_
- `Development`_
- `Documentation`_ - `Documentation`_
- `Contribution`_ - `Contribution`_
@ -80,8 +78,8 @@ Installation
$ pip install --upgrade pyrogram $ pip install --upgrade pyrogram
Setup Configuration
----- -------------
- Create a new ``config.ini`` file at the root of your working directory, copy-paste - Create a new ``config.ini`` file at the root of your working directory, copy-paste
the following and replace the **api_id** and **api_hash** values with `your own`_: the following and replace the **api_id** and **api_hash** values with `your own`_:
@ -95,40 +93,22 @@ Setup
Usage Usage
----- -----
- You can now start by running the code below from a new Python file. - And here's how Pyrogram looks:
.. code:: python .. code:: python
from pyrogram import Client from pyrogram import Client
# Create and start a new Client client = Client("example")
client = Client(session_name="example")
client.start() client.start()
# Send a text message to yourself (Saved Messages) client.send_message("me", "Hi there! I'm using Pyrogram")
client.send_message( client.send_photo("me", "/home/dan/pic.jpg", "Nice photo!")
chat_id="me",
text="Hi there! I'm using Pyrogram"
)
# When done, stop the Client
client.stop() client.stop()
That's all you need for getting started with Pyrogram. For more detailed information, That's all you need for getting started with Pyrogram. For more detailed information,
please refer to the documentation: please refer to the Documentation_.
- Docs: https://docs.pyrogram.ml.
Development
===========
The library is still in its early stages, thus lots of functionalities aiming to
make working with Telegram's API easy are yet to be added and documented.
However, being the core functionalities already implemented, every Telegram API
method listed in the API scheme can be used right away; the goal is therefore to
build a powerful, simple to use, `bot-like`_ interface on top of those low-level
functions.
Documentation Documentation
@ -136,6 +116,7 @@ Documentation
- The entire Pyrogram's documentation resides at https://docs.pyrogram.ml. - The entire Pyrogram's documentation resides at https://docs.pyrogram.ml.
Contribution Contribution
============ ============

View File

@ -1240,6 +1240,7 @@ class Client:
) )
def delete_messages(self, def delete_messages(self,
chat_id: int or str,
message_ids: list, message_ids: list,
revoke: bool = None): revoke: bool = None):
"""Use this method to delete messages, including service messages, with the following limitations: """Use this method to delete messages, including service messages, with the following limitations:
@ -1251,15 +1252,32 @@ class Client:
- If the user has *can_delete_messages* permission in a supergroup or a channel, it can delete any message there. - If the user has *can_delete_messages* permission in a supergroup or a channel, it can delete any message there.
Args: Args:
chat_id (:obj:`int` or :obj:`str`):
Unique identifier for the target chat or username of the target channel/supergroup
(in the format @username). For your personal cloud storage (Saved Messages) you can
simply use "me" or "self".
message_ids (:obj:`list`): message_ids (:obj:`list`):
List of identifiers of the messages to delete. List of identifiers of the messages to delete.
revoke (:obj:`bool`, optional): revoke (:obj:`bool`, optional):
Deletes messages on both parts (for private chats). Deletes messages on both parts.
This is only for private cloud chats and normal groups, messages on
channels and supergroups are always revoked (i.e.: deleted for everyone).
Raises: Raises:
:class:`pyrogram.Error` :class:`pyrogram.Error`
""" """
peer = self.resolve_peer(chat_id)
if isinstance(peer, types.InputPeerChannel):
return self.send(
functions.channels.DeleteMessages(
channel=peer,
id=message_ids
)
)
else:
# TODO: Maybe "revoke" is superfluous. # TODO: Maybe "revoke" is superfluous.
# If I want to delete a message, chances are I want it to # If I want to delete a message, chances are I want it to
# be deleted even from the other side # be deleted even from the other side