From 54ee13566082629d342672be04d6ed2c9ffff0c1 Mon Sep 17 00:00:00 2001 From: profitroll Date: Tue, 23 May 2023 15:14:50 +0200 Subject: [PATCH] Small refactor is done --- main.py | 10 +++++----- modules/app.py | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index b5b2549..bc65869 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,13 @@ +import contextlib import logging from os import getpid +from modules.app import PyroClient + # Uncomment this and the line below client declaration # in order to use context manager in your commands. # from convopyro import Conversation -from modules.app import PyroClient logging.basicConfig( level=logging.INFO, @@ -15,12 +17,10 @@ logging.basicConfig( logger = logging.getLogger(__name__) -try: +with contextlib.suppress(ImportError): import uvloop uvloop.install() -except ImportError: - pass def main(): @@ -30,7 +30,7 @@ def main(): try: client.run() except KeyboardInterrupt: - logger.warning(f"Forcefully shutting down with PID {getpid()}...") + logger.warning("Forcefully shutting down with PID %s...", getpid()) finally: exit() diff --git a/modules/app.py b/modules/app.py index 7525086..b2c84a3 100644 --- a/modules/app.py +++ b/modules/app.py @@ -25,6 +25,7 @@ class PyroClient(Client): plugins=dict(root="plugins", exclude=config["disabled_plugins"]), sleep_threshold=120, ) + self.start_time = 0 async def start(self): await super().start() @@ -56,4 +57,4 @@ class PyroClient(Client): except BadRequest: logger.warning("Unable to send message to report chat.") await super().stop() - logger.warning(f"Bot stopped with PID {getpid()}.") + logger.warning("Bot stopped with PID %s.", getpid())