Changed main structure

This commit is contained in:
Profitroll 2023-05-14 21:27:07 +02:00
parent 21a860f83a
commit cc24b3c740

17
main.py
View File

@ -1,9 +1,6 @@
import asyncio
import logging
from os import getpid
from pyrogram.sync import idle
from modules.app import PyroClient
logging.basicConfig(
@ -22,21 +19,17 @@ except ImportError:
pass
async def main():
def main():
client = PyroClient()
try:
await client.start()
await idle()
client.run()
except KeyboardInterrupt:
logger.warning(f"Forcefully shutting down with PID {getpid()}...")
finally:
await client.stop()
client.__exit__()
exit()
if __name__ == "__main__":
event_policy = asyncio.get_event_loop_policy()
event_loop = event_policy.new_event_loop()
asyncio.set_event_loop(event_loop)
event_loop.run_until_complete(main())
event_loop.close()
main()