mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-23 23:34:28 +00:00
Merge branch 'master' into docs
This commit is contained in:
commit
b21cdc94a7
41
README.rst
41
README.rst
@ -13,12 +13,10 @@ Table of Contents
|
||||
|
||||
- `Installation`_
|
||||
|
||||
- `Setup`_
|
||||
- `Configuration`_
|
||||
|
||||
- `Usage`_
|
||||
|
||||
- `Development`_
|
||||
|
||||
- `Documentation`_
|
||||
|
||||
- `Contribution`_
|
||||
@ -80,8 +78,8 @@ Installation
|
||||
|
||||
$ pip install --upgrade pyrogram
|
||||
|
||||
Setup
|
||||
-----
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
- 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`_:
|
||||
@ -95,40 +93,22 @@ Setup
|
||||
Usage
|
||||
-----
|
||||
|
||||
- You can now start by running the code below from a new Python file.
|
||||
- And here's how Pyrogram looks:
|
||||
|
||||
.. code:: python
|
||||
|
||||
from pyrogram import Client
|
||||
|
||||
# Create and start a new Client
|
||||
client = Client(session_name="example")
|
||||
|
||||
client = Client("example")
|
||||
client.start()
|
||||
|
||||
# Send a text message to yourself (Saved Messages)
|
||||
client.send_message(
|
||||
chat_id="me",
|
||||
text="Hi there! I'm using Pyrogram"
|
||||
)
|
||||
|
||||
# When done, stop the Client
|
||||
client.send_message("me", "Hi there! I'm using Pyrogram")
|
||||
client.send_photo("me", "/home/dan/pic.jpg", "Nice photo!")
|
||||
|
||||
client.stop()
|
||||
|
||||
That's all you need for getting started with Pyrogram. For more detailed information,
|
||||
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.
|
||||
please refer to the Documentation_.
|
||||
|
||||
|
||||
Documentation
|
||||
@ -136,6 +116,7 @@ Documentation
|
||||
|
||||
- The entire Pyrogram's documentation resides at https://docs.pyrogram.ml.
|
||||
|
||||
|
||||
Contribution
|
||||
============
|
||||
|
||||
|
@ -1240,6 +1240,7 @@ class Client:
|
||||
)
|
||||
|
||||
def delete_messages(self,
|
||||
chat_id: int or str,
|
||||
message_ids: list,
|
||||
revoke: bool = None):
|
||||
"""Use this method to delete messages, including service messages, with the following limitations:
|
||||
@ -1251,24 +1252,41 @@ class Client:
|
||||
- If the user has *can_delete_messages* permission in a supergroup or a channel, it can delete any message there.
|
||||
|
||||
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`):
|
||||
List of identifiers of the messages to delete.
|
||||
|
||||
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:
|
||||
:class:`pyrogram.Error`
|
||||
"""
|
||||
# TODO: Maybe "revoke" is superfluous.
|
||||
# If I want to delete a message, chances are I want it to
|
||||
# be deleted even from the other side
|
||||
return self.send(
|
||||
functions.messages.DeleteMessages(
|
||||
id=message_ids,
|
||||
revoke=revoke or None
|
||||
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.
|
||||
# If I want to delete a message, chances are I want it to
|
||||
# be deleted even from the other side
|
||||
return self.send(
|
||||
functions.messages.DeleteMessages(
|
||||
id=message_ids,
|
||||
revoke=revoke or None
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
# TODO: Remove redundant code
|
||||
def save_file(self, path: str, file_id: int = None, file_part: int = 0):
|
||||
|
Loading…
Reference in New Issue
Block a user