Small refactor is done

This commit is contained in:
Profitroll 2023-05-23 15:14:50 +02:00
parent 2bced5186a
commit 54ee135660
2 changed files with 7 additions and 6 deletions

10
main.py
View File

@ -1,11 +1,13 @@
import contextlib
import logging import logging
from os import getpid from os import getpid
from modules.app import PyroClient
# Uncomment this and the line below client declaration # Uncomment this and the line below client declaration
# in order to use context manager in your commands. # in order to use context manager in your commands.
# from convopyro import Conversation # from convopyro import Conversation
from modules.app import PyroClient
logging.basicConfig( logging.basicConfig(
level=logging.INFO, level=logging.INFO,
@ -15,12 +17,10 @@ logging.basicConfig(
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
try: with contextlib.suppress(ImportError):
import uvloop import uvloop
uvloop.install() uvloop.install()
except ImportError:
pass
def main(): def main():
@ -30,7 +30,7 @@ def main():
try: try:
client.run() client.run()
except KeyboardInterrupt: except KeyboardInterrupt:
logger.warning(f"Forcefully shutting down with PID {getpid()}...") logger.warning("Forcefully shutting down with PID %s...", getpid())
finally: finally:
exit() exit()

View File

@ -25,6 +25,7 @@ class PyroClient(Client):
plugins=dict(root="plugins", exclude=config["disabled_plugins"]), plugins=dict(root="plugins", exclude=config["disabled_plugins"]),
sleep_threshold=120, sleep_threshold=120,
) )
self.start_time = 0
async def start(self): async def start(self):
await super().start() await super().start()
@ -56,4 +57,4 @@ class PyroClient(Client):
except BadRequest: except BadRequest:
logger.warning("Unable to send message to report chat.") logger.warning("Unable to send message to report chat.")
await super().stop() await super().stop()
logger.warning(f"Bot stopped with PID {getpid()}.") logger.warning("Bot stopped with PID %s.", getpid())