mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 21:10:29 +00:00
Add add_event_handler and deprecate add_update_handler
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import logging
|
||||
import os
|
||||
import threading
|
||||
import warnings
|
||||
from datetime import timedelta, datetime
|
||||
from signal import signal, SIGINT, SIGTERM, SIGABRT
|
||||
from threading import Lock
|
||||
@@ -589,24 +588,6 @@ class TelegramBareClient:
|
||||
self.updates.process(self(GetStateRequest()))
|
||||
self._last_state = datetime.now()
|
||||
|
||||
def add_update_handler(self, handler):
|
||||
"""Adds an update handler (a function which takes a TLObject,
|
||||
an update, as its parameter) and listens for updates"""
|
||||
if self.updates.workers is None:
|
||||
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)
|
||||
|
||||
def remove_update_handler(self, handler):
|
||||
self.updates.handlers.remove(handler)
|
||||
|
||||
def list_update_handlers(self):
|
||||
return self.updates.handlers[:]
|
||||
|
||||
# endregion
|
||||
|
||||
# region Constant read
|
||||
|
Reference in New Issue
Block a user