@@ -91,13 +91,14 @@ Stop Propagation
9191In order to prevent further propagation of an update in the dispatching phase, you can do *one * of the following:
9292
9393- Call the update's bound-method ``.stop_propagation() `` (preferred way).
94- - Manually ``raise StopPropagation `` error (more suitable for raw updates only).
94+ - Manually ``raise StopPropagation `` exception (more suitable for raw updates only).
9595
9696.. note ::
9797
98- Note that ``.stop_propagation() `` is just an elegant and intuitive way to raise a ``StopPropagation `` error;
99- this means that any code coming *after * calling it won't be executed as your function just raised a custom exception
100- to signal the dispatcher not to propagate the update anymore.
98+ Internally, the propagation is stopped by handling a custom exception. ``.stop_propagation() `` is just an elegant
99+ and intuitive way to ``raise StopPropagation ``; this also means that any code coming *after * calling the method
100+ won't be executed as your function just raised an exception to signal the dispatcher not to propagate the
101+ update anymore.
101102
102103Example with ``stop_propagation() ``:
103104
@@ -139,10 +140,82 @@ Example with ``raise StopPropagation``:
139140 def _ (client , message ):
140141 print (2 )
141142
142- The handler in group number 2 will never be executed because the propagation was stopped before. The output of both
143- examples will be:
143+ Each handler is registered in a different group, but the handler in group number 2 will never be executed because the
144+ propagation was stopped earlier. The output of both (equivalent) examples will be:
144145
145146.. code-block :: text
146147
147148 0
148149 1
150+
151+ Continue Propagation
152+ ^^^^^^^^^^^^^^^^^^^^
153+
154+ As opposed to `stopping the update propagation <#stop-propagation >`_ and also as an alternative to the
155+ `handler groups <#handler-groups >`_, you can signal the internal dispatcher to continue the update propagation within
156+ the group regardless of the next handler's filters. This allows you to register multiple handlers with overlapping
157+ filters in the same group; to let the dispatcher process the next handler you can do *one * of the following in each
158+ handler you want to grant permission to continue:
159+
160+ - Call the update's bound-method ``.continue_propagation() `` (preferred way).
161+ - Manually ``raise ContinuePropagation `` exception (more suitable for raw updates only).
162+
163+ .. note ::
164+
165+ Internally, the propagation is continued by handling a custom exception. ``.continue_propagation() `` is just an
166+ elegant and intuitive way to ``raise ContinuePropagation ``; this also means that any code coming *after * calling the
167+ method won't be executed as your function just raised an exception to signal the dispatcher to continue with the
168+ next available handler.
169+
170+
171+ Example with ``continue_propagation() ``:
172+
173+ .. code-block :: python
174+
175+ @app.on_message (Filters.private)
176+ def _ (client , message ):
177+ print (0 )
178+ message.continue_propagation()
179+
180+
181+ @app.on_message (Filters.private)
182+ def _ (client , message ):
183+ print (1 )
184+ message.continue_propagation()
185+
186+
187+ @app.on_message (Filters.private)
188+ def _ (client , message ):
189+ print (2 )
190+
191+ Example with ``raise ContinuePropagation ``:
192+
193+ .. code-block :: python
194+
195+ from pyrogram import ContinuePropagation
196+
197+ @app.on_message (Filters.private)
198+ def _ (client , message ):
199+ print (0 )
200+ raise ContinuePropagation
201+
202+
203+ @app.on_message (Filters.private)
204+ def _ (client , message ):
205+ print (1 )
206+ raise ContinuePropagation
207+
208+
209+ @app.on_message (Filters.private)
210+ def _ (client , message ):
211+ print (2 )
212+
213+ Three handlers are registered in the same group, and all of them will be executed because the propagation was continued
214+ in each handler (except in the last one, where is useless to do so since there is no more handlers after).
215+ The output of both (equivalent) examples will be:
216+
217+ .. code-block :: text
218+
219+ 0
220+ 1
221+ 2
0 commit comments