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

40 lines
761 B
Python
Raw Normal View History

2023-05-23 16:14:50 +03:00
import contextlib
2023-04-01 15:25:41 +03:00
import logging
from os import getpid
2023-05-23 16:14:50 +03:00
from modules.app import PyroClient
2023-05-14 23:09:04 +03:00
# Uncomment this and the line below client declaration
# in order to use context manager in your commands.
# from convopyro import Conversation
2023-04-01 15:25:41 +03:00
logging.basicConfig(
level=logging.INFO,
format="%(name)s.%(funcName)s | %(levelname)s | %(message)s",
datefmt="[%X]",
)
logger = logging.getLogger(__name__)
2023-05-23 16:14:50 +03:00
with contextlib.suppress(ImportError):
2023-04-01 15:25:41 +03:00
import uvloop
uvloop.install()
2023-05-14 22:27:07 +03:00
def main():
2023-04-01 15:25:41 +03:00
client = PyroClient()
2023-05-14 23:09:04 +03:00
# Conversation(client)
2023-04-01 15:25:41 +03:00
try:
2023-05-14 22:27:07 +03:00
client.run()
2023-04-01 15:25:41 +03:00
except KeyboardInterrupt:
2023-05-23 16:14:50 +03:00
logger.warning("Forcefully shutting down with PID %s...", getpid())
2023-04-01 15:25:41 +03:00
finally:
2023-05-14 22:27:07 +03:00
exit()
2023-04-01 15:25:41 +03:00
if __name__ == "__main__":
2023-05-14 22:29:23 +03:00
main()