Initial commit
This commit is contained in:
42
main.py
Normal file
42
main.py
Normal file
@@ -0,0 +1,42 @@
|
||||
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()
|
Reference in New Issue
Block a user