@@ -26,12 +26,12 @@ For example, take these two handlers:
2626.. code-block :: python
2727
2828 @app.on_message (filters.text | filters.sticker)
29- def text_or_sticker (client , message ):
29+ async def text_or_sticker (client , message ):
3030 print (" Text or Sticker" )
3131
3232
3333 @app.on_message (filters.text)
34- def just_text (client , message ):
34+ async def just_text (client , message ):
3535 print (" Just Text" )
3636
3737 Here, ``just_text `` is never executed because ``text_or_sticker ``, which has been registered first, already handles
@@ -40,15 +40,15 @@ texts (``filters.text`` is shared and conflicting). To enable it, register the h
4040.. code-block :: python
4141
4242 @app.on_message (filters.text, group = 1 )
43- def just_text (client , message ):
43+ async def just_text (client , message ):
4444 print (" Just Text" )
4545
4646 Or, if you want ``just_text `` to be executed *before * ``text_or_sticker `` (note ``-1 ``, which is less than ``0 ``):
4747
4848.. code-block :: python
4949
5050 @app.on_message (filters.text, group = - 1 )
51- def just_text (client , message ):
51+ async def just_text (client , message ):
5252 print (" Just Text" )
5353
5454 With :meth: `~pyrogram.Client.add_handler ` (without decorators) the same can be achieved with:
@@ -68,17 +68,17 @@ continue to propagate the same update to the next groups until all the handlers
6868.. code-block :: python
6969
7070 @app.on_message (filters.private)
71- def _ (client , message ):
71+ async def _ (client , message ):
7272 print (0 )
7373
7474
7575 @app.on_message (filters.private, group = 1 )
76- def _ (client , message ):
76+ async def _ (client , message ):
7777 raise Exception (" Unhandled exception!" ) # Simulate an unhandled exception
7878
7979
8080 @app.on_message (filters.private, group = 2 )
81- def _ (client , message ):
81+ async def _ (client , message ):
8282 print (2 )
8383
8484 All these handlers will handle the same kind of messages, that are, messages sent or received in private chats.
@@ -110,18 +110,18 @@ Example with ``stop_propagation()``:
110110.. code-block :: python
111111
112112 @app.on_message (filters.private)
113- def _ (client , message ):
113+ async def _ (client , message ):
114114 print (0 )
115115
116116
117117 @app.on_message (filters.private, group = 1 )
118- def _ (client , message ):
118+ async def _ (client , message ):
119119 print (1 )
120120 message.stop_propagation()
121121
122122
123123 @app.on_message (filters.private, group = 2 )
124- def _ (client , message ):
124+ async def _ (client , message ):
125125 print (2 )
126126
127127 Example with ``raise StopPropagation ``:
@@ -131,18 +131,18 @@ Example with ``raise StopPropagation``:
131131 from pyrogram import StopPropagation
132132
133133 @app.on_message (filters.private)
134- def _ (client , message ):
134+ async def _ (client , message ):
135135 print (0 )
136136
137137
138138 @app.on_message (filters.private, group = 1 )
139- def _ (client , message ):
139+ async ef _(client, message):
140140 print (1 )
141141 raise StopPropagation
142142
143143
144144 @app.on_message (filters.private, group = 2 )
145- def _ (client , message ):
145+ async def _ (client , message ):
146146 print (2 )
147147
148148 Each handler is registered in a different group, but the handler in group number 2 will never be executed because the
@@ -178,19 +178,19 @@ Example with ``continue_propagation()``:
178178.. code-block :: python
179179
180180 @app.on_message (filters.private)
181- def _ (client , message ):
181+ async def _ (client , message ):
182182 print (0 )
183183 message.continue_propagation()
184184
185185
186186 @app.on_message (filters.private)
187- def _ (client , message ):
187+ async def _ (client , message ):
188188 print (1 )
189189 message.continue_propagation()
190190
191191
192192 @app.on_message (filters.private)
193- def _ (client , message ):
193+ async def _ (client , message ):
194194 print (2 )
195195
196196 Example with ``raise ContinuePropagation ``:
@@ -200,19 +200,19 @@ Example with ``raise ContinuePropagation``:
200200 from pyrogram import ContinuePropagation
201201
202202 @app.on_message (filters.private)
203- def _ (client , message ):
203+ async def _ (client , message ):
204204 print (0 )
205205 raise ContinuePropagation
206206
207207
208208 @app.on_message (filters.private)
209- def _ (client , message ):
209+ async def _ (client , message ):
210210 print (1 )
211211 raise ContinuePropagation
212212
213213
214214 @app.on_message (filters.private)
215- def _ (client , message ):
215+ async def _ (client , message ):
216216 print (2 )
217217
218218 Three handlers are registered in the same group, and all of them will be executed because the propagation was continued
0 commit comments