pyrofork icon indicating copy to clipboard operation
pyrofork copied to clipboard

can't handle messages with await client.start(), but can with client.run()

Open gmankab opened this issue 7 months ago • 1 comments

Checklist

  • [X] I am sure the error is coming from Pyrofork's code and not elsewhere
  • [X] I have searched in the issue tracker for similar bug reports, including closed ones
  • [X] I ran pip3 install -U git+https://github.com/Mayuri-Chan/pyrofork and reproduced the issue using the latest development version

Description

if i use await client.start() to start client, code can't hadle messages, but if i use client.run(), it works fine

Steps to reproduce

see code example

Code example

this code works just fine, and prints all messages

from pyrogram import Client


client = Client('tg_bot')


@client.on_message()
async def on_msg(_, msg):
    print(f'new msg {msg.id}')


client.run()

this code expected to work same, but it doesn't handle messages and doesn't print anything

from pyrogram import Client, idle
import asyncio


client = Client('tg_bot')


@client.on_message()
async def on_msg(_, msg):
    print(f'new msg {msg.id}')


async def main():
    await client.start()
    await idle()


asyncio.run(main())

Logs

No response

gmankab avatar Jul 14 '24 06:07 gmankab