2
2
from os import environ
3
3
from types import MappingProxyType
4
4
5
- from pydantic import BaseSettings , SecretStr
5
+ from pydantic import SecretStr
6
+ from pydantic_settings import BaseSettings
6
7
from pydis_core .utils .logging import get_logger
7
8
8
9
__all__ = (
34
35
PYTHON_PREFIX = "!"
35
36
36
37
37
- class EnvConfig (BaseSettings ):
38
+ class EnvConfig (
39
+ BaseSettings ,
40
+ env_file = (".env.server" , ".env" ),
41
+ env_file_encoding = "utf-8" ,
42
+ env_nested_delimiter = "__" ,
43
+ extra = "ignore" ,
44
+ ):
38
45
"""Our default configuration for models that should load from .env files."""
39
46
40
- class Config :
41
- """Specify what .env files to load, and how to load them."""
42
47
43
- env_file = ".env" ,
44
- env_file_encoding = "utf-8"
45
-
46
-
47
- class _Channels (EnvConfig ):
48
- EnvConfig .Config .env_prefix = "channels_"
49
-
50
- algos_and_data_structs = 650401909852864553
51
- bot_commands = 267659945086812160
52
- community_meta = 267659945086812160
53
- organisation = 551789653284356126
54
- data_science_and_ai = 366673247892275221
55
- devlog = 622895325144940554
56
- dev_contrib = 635950537262759947
57
- mod_meta = 775412552795947058
58
- mod_tools = 775413915391098921
59
- off_topic_0 = 291284109232308226
60
- off_topic_1 = 463035241142026251
61
- off_topic_2 = 463035268514185226
62
- python_help = 1035199133436354600
63
- sir_lancebot_playground = 607247579608121354
64
- voice_chat_0 = 412357430186344448
65
- voice_chat_1 = 799647045886541885
66
- staff_voice = 541638762007101470
67
- reddit = 458224812528238616
48
+ class _Channels (EnvConfig , env_prefix = "channels_" ):
49
+ algos_and_data_structs : int = 650401909852864553
50
+ bot_commands : int = 267659945086812160
51
+ community_meta : int = 267659945086812160
52
+ organisation : int = 551789653284356126
53
+ data_science_and_ai : int = 366673247892275221
54
+ devlog : int = 622895325144940554
55
+ dev_contrib : int = 635950537262759947
56
+ mod_meta : int = 775412552795947058
57
+ mod_tools : int = 775413915391098921
58
+ off_topic_0 : int = 291284109232308226
59
+ off_topic_1 : int = 463035241142026251
60
+ off_topic_2 : int = 463035268514185226
61
+ python_help : int = 1035199133436354600
62
+ sir_lancebot_playground : int = 607247579608121354
63
+ voice_chat_0 : int = 412357430186344448
64
+ voice_chat_1 : int = 799647045886541885
65
+ staff_voice : int = 541638762007101470
66
+ reddit : int = 458224812528238616
68
67
69
68
70
69
Channels = _Channels ()
71
70
72
71
73
- class _Categories (EnvConfig ):
74
- EnvConfig .Config .env_prefix = "categories_"
75
-
76
- python_help_system = 691405807388196926
77
- development = 411199786025484308
78
- devprojects = 787641585624940544
79
- media = 799054581991997460
80
- staff = 364918151625965579
72
+ class _Categories (EnvConfig , env_prefix = "categories_" ):
73
+ python_help_system : int = 691405807388196926
74
+ development : int = 411199786025484308
75
+ devprojects : int = 787641585624940544
76
+ media : int = 799054581991997460
77
+ staff : int = 364918151625965579
81
78
82
79
83
80
Categories = _Categories ()
84
81
85
82
86
- class _Client (EnvConfig ):
87
- EnvConfig .Config .env_prefix = "client_"
88
-
89
- name = "Sir Lancebot"
90
- guild = 267624335836053506
91
- prefix = "."
83
+ class _Client (EnvConfig , env_prefix = "client_" ):
84
+ name : str = "Sir Lancebot"
85
+ guild : int = 267624335836053506
86
+ prefix : str = "."
92
87
token : SecretStr
93
- debug = True
94
- in_ci = False
95
- github_repo = "https://github.com/python-discord/sir-lancebot"
88
+ debug : bool = True
89
+ in_ci : bool = False
90
+ github_repo : str = "https://github.com/python-discord/sir-lancebot"
96
91
# Override seasonal locks: 1 (January) to 12 (December)
97
92
month_override : int | None = None
98
93
99
94
100
95
Client = _Client ()
101
96
102
97
103
- class _Logging (EnvConfig ):
104
- EnvConfig .Config .env_prefix = "logging_"
105
-
106
- debug = Client .debug
107
- file_logs = False
108
- trace_loggers = ""
98
+ class _Logging (EnvConfig , env_prefix = "logging_" ):
99
+ debug : bool = Client .debug
100
+ file_logs : bool = False
101
+ trace_loggers : str = ""
109
102
110
103
111
104
Logging = _Logging ()
@@ -259,26 +252,21 @@ def __str__(self) -> str:
259
252
Month (Client .month_override )
260
253
261
254
262
- class _Roles (EnvConfig ):
255
+ class _Roles (EnvConfig , env_prefix = "roles_" ):
256
+ owners : int = 267627879762755584
257
+ admins : int = 267628507062992896
258
+ moderation_team : int = 267629731250176001
259
+ helpers : int = 267630620367257601
260
+ core_developers : int = 587606783669829632
261
+ everyone : int = Client .guild
263
262
264
- EnvConfig .Config .env_prefix = "roles_"
265
-
266
- owners = 267627879762755584
267
- admins = 267628507062992896
268
- moderation_team = 267629731250176001
269
- helpers = 267630620367257601
270
- core_developers = 587606783669829632
271
- everyone = Client .guild
272
-
273
- lovefest = 542431903886606399
263
+ lovefest : int = 542431903886606399
274
264
275
265
276
266
Roles = _Roles ()
277
267
278
268
279
- class _Tokens (EnvConfig ):
280
- EnvConfig .Config .env_prefix = "tokens_"
281
-
269
+ class _Tokens (EnvConfig , env_prefix = "tokens_" ):
282
270
giphy : SecretStr = ""
283
271
youtube : SecretStr = ""
284
272
tmdb : SecretStr = ""
@@ -292,31 +280,26 @@ class _Tokens(EnvConfig):
292
280
Tokens = _Tokens ()
293
281
294
282
295
- class _Wolfram (EnvConfig ):
296
- EnvConfig .Config .env_prefix = "wolfram_"
297
- user_limit_day = 10
298
- guild_limit_day = 67
283
+ class _Wolfram (EnvConfig , env_prefix = "wolfram_" ):
284
+ user_limit_day : int = 10
285
+ guild_limit_day : int = 67
299
286
key : SecretStr = ""
300
287
301
288
302
289
Wolfram = _Wolfram ()
303
290
304
291
305
- class _Redis (EnvConfig ):
306
- EnvConfig .Config .env_prefix = "redis_"
307
-
308
- host = "redis.default.svc.cluster.local"
309
- port = 6379
292
+ class _Redis (EnvConfig , env_prefix = "redis_" ):
293
+ host : str = "redis.default.svc.cluster.local"
294
+ port : int = 6379
310
295
password : SecretStr = ""
311
- use_fakeredis = False
296
+ use_fakeredis : bool = False
312
297
313
298
314
299
Redis = _Redis ()
315
300
316
301
317
- class _Reddit (EnvConfig ):
318
- EnvConfig .Config .env_prefix = "reddit_"
319
-
302
+ class _Reddit (EnvConfig , env_prefix = "reddit_" ):
320
303
subreddits : tuple [str , ...] = ("r/Python" ,)
321
304
322
305
client_id : SecretStr = ""
0 commit comments