import pyrogram client = pyrogram.Client("Session-Name")
[pyrogram] api_id=1234567 api_HASH=1108f129f7afa345076448421e535bbd bot_token=1234567890:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
import _thread def some_long_process(param1, param2): # do something that takes long time param2.reply_text('Process Over.') ... @client.on_message( pyrogram.filters.command('do_big') ) def do_big(_c, message): _thread.start_new_thread(some_long_process, (_c, message))
You can pass on the
client and the message
parameter to some function, which takes a long time to complete, and has to notify the user when it completes. During this process, some times the bot might stop responding to other users, or become slow.
_thread module to start a new thread which runs
in background without disturbing your bot, and making it faster to the core.