Skip to content

Commit 317a647

Browse files
committed
Reword some parts of the docs
1 parent a80c5c1 commit 317a647

File tree

5 files changed

+29
-27
lines changed

5 files changed

+29
-27
lines changed

docs/source/topics/advanced-usage.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ sending messages with IDs only thanks to cached access hashes.
103103
There are three different InputPeer types, one for each kind of Telegram entity.
104104
Whenever an InputPeer is needed you must pass one of these:
105105

106-
- :class:`~pyrogram.api.types.InputPeerUser` - Users
107-
- :class:`~pyrogram.api.types.InputPeerChat` - Basic Chats
108-
- :class:`~pyrogram.api.types.InputPeerChannel` - Either Channels or Supergroups
106+
- :class:`~pyrogram.api.types.InputPeerUser` - Users
107+
- :class:`~pyrogram.api.types.InputPeerChat` - Basic Chats
108+
- :class:`~pyrogram.api.types.InputPeerChannel` - Either Channels or Supergroups
109109

110110
But you don't necessarily have to manually instantiate each object because, luckily for you, Pyrogram already provides
111111
:meth:`~pyrogram.Client.resolve_peer` as a convenience utility method that returns the correct InputPeer
@@ -120,9 +120,9 @@ kind of ID.
120120

121121
For example, given the ID *123456789*, here's how Pyrogram can tell entities apart:
122122

123-
- ``+ID`` User: *123456789*
124-
- ``-ID`` Chat: *-123456789*
125-
- ``-100ID`` Channel or Supergroup: *-100123456789*
123+
- ``+ID`` User: *123456789*
124+
- ``-ID`` Chat: *-123456789*
125+
- ``-100ID`` Channel or Supergroup: *-100123456789*
126126

127127
So, every time you take a raw ID, make sure to translate it into the correct ID when you want to use it with an
128128
high-level method.

docs/source/topics/config-file.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
Configuration File
22
==================
33

4-
As already mentioned in previous sections, Pyrogram can be configured by the use of an INI file.
5-
This page explains how this file is structured in Pyrogram, how to use it and why.
4+
As already mentioned in previous pages, Pyrogram can be configured by the use of an INI file.
5+
This page explains how this file is structured, how to use it and why.
66

77
Introduction
88
------------
99

1010
The idea behind using a configuration file is to help keeping your code free of private settings information such as
11-
the API Key and Proxy without having you to even deal with how to load such settings. The configuration file, usually
11+
the API Key and Proxy, without having you to even deal with how to load such settings. The configuration file, usually
1212
referred as ``config.ini`` file, is automatically loaded from the root of your working directory; all you need to do is
1313
fill in the necessary parts.
1414

docs/source/topics/create-filters.rst

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ Custom Filters
1313
--------------
1414

1515
An example to demonstrate how custom filters work is to show how to create and use one for the
16-
:class:`~pyrogram.CallbackQueryHandler`. Note that callback queries updates are only received by bots; create and
17-
:doc:`authorize your bot <../start/auth>`, then send a message with an inline keyboard to yourself. This allows you to
18-
test your filter by pressing the inline button:
16+
:class:`~pyrogram.CallbackQueryHandler`. Note that callback queries updates are only received by bots as result of a
17+
user pressing an inline button attached to the bot's message; create and :doc:`authorize your bot <../start/auth>`,
18+
then send a message with an inline keyboard to yourself. This allows you to test your filter by pressing the inline
19+
button:
1920

2021
.. code-block:: python
2122
@@ -25,7 +26,7 @@ test your filter by pressing the inline button:
2526
"username", # Change this to your username or id
2627
"Pyrogram's custom filter test",
2728
reply_markup=InlineKeyboardMarkup(
28-
[[InlineKeyboardButton("Press me", b"pyrogram")]]
29+
[[InlineKeyboardButton("Press me", "pyrogram")]]
2930
)
3031
)
3132
@@ -36,22 +37,22 @@ For this basic filter we will be using only the first two parameters of :meth:`~
3637

3738
The code below creates a simple filter for hardcoded, static callback data. This filter will only allow callback queries
3839
containing "Pyrogram" as data, that is, the function *func* you pass returns True in case the callback query data
39-
equals to ``b"Pyrogram"``.
40+
equals to ``"Pyrogram"``.
4041

4142
.. code-block:: python
4243
4344
static_data = Filters.create(
4445
name="StaticdData",
45-
func=lambda flt, callback_query: callback_query.data == b"Pyrogram"
46+
func=lambda flt, query: query.data == "Pyrogram"
4647
)
4748
4849
The ``lambda`` operator in python is used to create small anonymous functions and is perfect for this example, the same
4950
could be achieved with a normal function, but we don't really need it as it makes sense only inside the filter's scope:
5051

5152
.. code-block:: python
5253
53-
def func(flt, callback_query):
54-
return callback_query.data == b"Pyrogram"
54+
def func(flt, query):
55+
return query.data == "Pyrogram"
5556
5657
static_data = Filters.create(
5758
name="StaticData",
@@ -63,8 +64,8 @@ The filter usage remains the same:
6364
.. code-block:: python
6465
6566
@app.on_callback_query(static_data)
66-
def pyrogram_data(client, callback_query):
67-
client.answer_callback_query(callback_query.id, "it works!")
67+
def pyrogram_data(_, query):
68+
query.answer("it works!")
6869
6970
Filters with Arguments
7071
----------------------
@@ -79,14 +80,14 @@ This is how a dynamic custom filter looks like:
7980
def dynamic_data(data):
8081
return Filters.create(
8182
name="DynamicData",
82-
func=lambda flt, callback_query: flt.data == callback_query.data,
83-
data=data # "data" kwarg is accessed with "filter.data"
83+
func=lambda flt, query: flt.data == query.data,
84+
data=data # "data" kwarg is accessed with "flt.data"
8485
)
8586
8687
And its usage:
8788

8889
.. code-block:: python
8990
90-
@app.on_callback_query(dynamic_data(b"Pyrogram"))
91-
def pyrogram_data(client, callback_query):
92-
client.answer_callback_query(callback_query.id, "it works!")
91+
@app.on_callback_query(dynamic_data("Pyrogram"))
92+
def pyrogram_data(_, query):
93+
query.answer("it works!")

docs/source/topics/more-on-updates.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ For example, take these two handlers:
2929
print("Just Text")
3030
3131
Here, ``just_text`` is never executed because ``text_or_sticker``, which has been registered first, already handles
32-
texts (``Filters.text`` is shared and conflicting). To enable it, register the function using a different group:
32+
texts (``Filters.text`` is shared and conflicting). To enable it, register the handler using a different group:
3333

3434
.. code-block:: python
3535
3636
@app.on_message(Filters.text, group=1)
3737
def just_text(client, message):
3838
print("Just Text")
3939
40-
Or, if you want ``just_text`` to be fired *before* ``text_or_sticker`` (note ``-1``, which is less than ``0``):
40+
Or, if you want ``just_text`` to be executed *before* ``text_or_sticker`` (note ``-1``, which is less than ``0``):
4141

4242
.. code-block:: python
4343

docs/source/topics/use-filters.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ Let's start right away with a simple example:
2525
def my_handler(client, message):
2626
print(message)
2727
28-
- or, without decorators. Here filters are passed as the second argument of the handler constructor:
28+
- or, without decorators. Here filters are passed as the second argument of the handler constructor; the first is the
29+
callback function itself:
2930

3031
.. code-block:: python
3132
:emphasize-lines: 8

0 commit comments

Comments
 (0)