v1.1
This commit is contained in:
+8
-5
@@ -1,24 +1,27 @@
|
||||
import sys
|
||||
from asyncio import WindowsSelectorEventLoopPolicy, set_event_loop_policy
|
||||
from asyncio import set_event_loop_policy
|
||||
from platform import system
|
||||
|
||||
from .logger import BotLogger, RequestLogger, ClientLogger
|
||||
from .main.handler import Handler
|
||||
from kurocore.database import Database
|
||||
|
||||
|
||||
class Bot:
|
||||
__slots__ = ('config', 'is_running', 'middlewares', 'tasks')
|
||||
|
||||
def __init__(self, config):
|
||||
def __init__(self, config, load_db=False):
|
||||
BotLogger(config)
|
||||
RequestLogger(config)
|
||||
ClientLogger(config)
|
||||
self.config = config
|
||||
# Database(self.config)
|
||||
if load_db:
|
||||
Database(self.config)
|
||||
self.is_running = False
|
||||
self.middlewares = []
|
||||
self.tasks = []
|
||||
if sys.version_info >= (3, 8) and sys.platform.lower().startswith("win"):
|
||||
from asyncio import WindowsSelectorEventLoopPolicy
|
||||
set_event_loop_policy(WindowsSelectorEventLoopPolicy())
|
||||
|
||||
def add_plugin(self, plugin):
|
||||
@@ -55,5 +58,5 @@ class Bot:
|
||||
handler.run()
|
||||
except KeyboardInterrupt:
|
||||
handler.shutdown()
|
||||
# if Database.db and not Database.db.is_closed():
|
||||
# Database.db.close()
|
||||
if Database.db and not Database.db.is_closed():
|
||||
Database.db.close()
|
||||
|
||||
Reference in New Issue
Block a user