import logging
from os import getpid

from convopyro import Conversation

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


def main():
    client = PyroClient()
    Conversation(client)

    try:
        client.run()
    except KeyboardInterrupt:
        logger.warning(f"Forcefully shutting down with PID {getpid()}...")
    finally:
        exit()


if __name__ == "__main__":
    main()
