mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-22 23:27:49 +01:00
dispatcher: honour the priority of groups
This commit is contained in:
parent
8a087dce69
commit
4ac8f86156
1 changed files with 7 additions and 2 deletions
|
@ -96,6 +96,9 @@ class Dispatcher(object):
|
||||||
self.update_queue = update_queue
|
self.update_queue = update_queue
|
||||||
|
|
||||||
self.handlers = {}
|
self.handlers = {}
|
||||||
|
""":type: dict[int, list[Handler]"""
|
||||||
|
self.groups = []
|
||||||
|
""":type: list[int]"""
|
||||||
self.error_handlers = []
|
self.error_handlers = []
|
||||||
|
|
||||||
self.logger = logging.getLogger(__name__)
|
self.logger = logging.getLogger(__name__)
|
||||||
|
@ -170,8 +173,8 @@ class Dispatcher(object):
|
||||||
self.dispatchError(None, update)
|
self.dispatchError(None, update)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
for group in self.handlers.values():
|
for group in self.groups:
|
||||||
for handler in group:
|
for handler in self.handlers[group]:
|
||||||
try:
|
try:
|
||||||
if handler.checkUpdate(update):
|
if handler.checkUpdate(update):
|
||||||
handler.handleUpdate(update, self)
|
handler.handleUpdate(update, self)
|
||||||
|
@ -220,6 +223,8 @@ class Dispatcher(object):
|
||||||
|
|
||||||
if group not in self.handlers:
|
if group not in self.handlers:
|
||||||
self.handlers[group] = list()
|
self.handlers[group] = list()
|
||||||
|
self.groups.append(group)
|
||||||
|
self.groups = sorted(self.groups)
|
||||||
|
|
||||||
self.handlers[group].append(handler)
|
self.handlers[group].append(handler)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue