forked from e4c6/DiscordGPT-3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainers.py
51 lines (42 loc) · 1.19 KB
/
containers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from dependency_injector import containers, providers
from discord.ext import commands
from Cogs.Maincog import MainCog
from Implementation.ApiClient import ApiClient
from Implementation.DbHandler import DbHandler
from Implementation.LoggingHandler import LoggingHandler
from Services.BotService import BotService
class Container(containers.DeclarativeContainer):
config = providers.Configuration()
logger = providers.Singleton(
LoggingHandler,
log_level=config.LOG_LEVEL
)
api_client = providers.Singleton(
ApiClient,
logger=logger
)
db_handler = providers.Singleton(
DbHandler,
logger=logger,
mongo_uri=config.MONGO_URI,
mongo_db_name=config.MONGO_DBNAME
)
bot = providers.Singleton(
commands.Bot,
command_prefix=config.PREFIX,
help_command=None
)
main_cog = providers.Singleton(
MainCog,
logger=logger,
discord_bot=bot,
db_handler=db_handler,
api_client=api_client,
)
service = providers.Factory(
BotService,
logger=logger,
bot=bot,
main_cog=main_cog,
discord_token=config.DISCORD_TOKEN
)