mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-10 16:12:22 +03:00
Fix and enhance "no workers set" warning
This commit is contained in:
parent
9937d58a2d
commit
7596f2b797
|
@ -756,8 +756,12 @@ class TelegramBareClient:
|
||||||
def add_update_handler(self, handler):
|
def add_update_handler(self, handler):
|
||||||
"""Adds an update handler (a function which takes a TLObject,
|
"""Adds an update handler (a function which takes a TLObject,
|
||||||
an update, as its parameter) and listens for updates"""
|
an update, as its parameter) and listens for updates"""
|
||||||
if not self.updates.get_workers:
|
if self.updates.workers is None:
|
||||||
warnings.warn("There are no update workers running, so adding an update handler will have no effect.")
|
warnings.warn(
|
||||||
|
"You have not setup any workers, so you won't receive updates."
|
||||||
|
" Pass update_workers=4 when creating the TelegramClient,"
|
||||||
|
" or set client.self.updates.workers = 4"
|
||||||
|
)
|
||||||
|
|
||||||
self.updates.handlers.append(handler)
|
self.updates.handlers.append(handler)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user