This repository has been archived on 2024-10-15. You can view files and clone it, but cannot push or open issues or pull requests.
PyrogramBotBase/main.py
2023-04-01 14:25:41 +02:00

43 lines
850 B
Python

import asyncio
import logging
from os import getpid
from pyrogram.sync import idle
from modules.app import PyroClient
logging.basicConfig(
level=logging.INFO,
format="%(name)s.%(funcName)s | %(levelname)s | %(message)s",
datefmt="[%X]",
)
logger = logging.getLogger(__name__)
try:
import uvloop
uvloop.install()
except ImportError:
pass
async def main():
client = PyroClient()
try:
await client.start()
await idle()
except KeyboardInterrupt:
logger.warning(f"Forcefully shutting down with PID {getpid()}...")
finally:
await client.stop()
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()