@@ -135,7 +135,7 @@ def __getitem__(self, item: str) -> "Any": # type: ignore[explicit-any] # noqa
135135
136136 @staticmethod
137137 def _setup_logging () -> None :
138- raw_console_log_level : str = ( os .getenv ("CONSOLE_LOG_LEVEL" , "INFO" ) ).upper ().strip ()
138+ raw_console_log_level : str = os .getenv ("CONSOLE_LOG_LEVEL" , "INFO" ).upper ().strip ()
139139
140140 if raw_console_log_level not in LOG_LEVEL_CHOICES :
141141 INVALID_LOG_LEVEL_MESSAGE : Final [str ] = f"""LOG_LEVEL must be one of {
@@ -173,16 +173,18 @@ def _setup_discord_bot_token(cls) -> None:
173173
174174 @classmethod
175175 def _setup_discord_log_channel_webhook (cls ) -> "Logger" :
176- raw_discord_log_channel_webhook_url : str = (
177- ( os . getenv ( "DISCORD_LOG_CHANNEL_WEBHOOK_URL" , "" )). strip (). lower ()
178- )
176+ raw_discord_log_channel_webhook_url : str = os . getenv (
177+ "DISCORD_LOG_CHANNEL_WEBHOOK_URL" , ""
178+ ). strip ()
179179
180- if (
181- not raw_discord_log_channel_webhook_url
182- or not validators .url (raw_discord_log_channel_webhook_url )
183- or not raw_discord_log_channel_webhook_url .startswith (
184- "https://discord.com/api/webhooks/"
185- )
180+ if not raw_discord_log_channel_webhook_url :
181+ cls ._settings ["DISCORD_LOG_CHANNEL_WEBHOOK_URL" ] = None
182+ return logging .getLogger ("_temp_webhook_config" )
183+
184+ if not validators .url (
185+ raw_discord_log_channel_webhook_url
186+ ) or not raw_discord_log_channel_webhook_url .startswith (
187+ "https://discord.com/api/webhooks/"
186188 ):
187189 INVALID_DISCORD_LOG_CHANNEL_WEBHOOK_URL_MESSAGE : Final [str ] = (
188190 "DISCORD_LOG_CHANNEL_WEBHOOK_URL must be a valid webhook URL "
@@ -268,8 +270,8 @@ def _setup_purchase_membership_url(cls) -> None:
268270 if not raw_purchase_membership_url .startswith ("https://" ):
269271 raw_purchase_membership_url = "https://" + raw_purchase_membership_url
270272 logger .warning (
271- "PURCHASE_MEMBERSHIP_URL does not start with 'https://'. "
272- "Please ensure all URLs are valid https URLs." ,
273+ "PURCHASE_MEMBERSHIP_URL was missing a URL protocol. "
274+ "Please ensure all URLs are valid HTTPS URLs." ,
273275 )
274276
275277 if not validators .url (raw_purchase_membership_url ):
@@ -282,9 +284,7 @@ def _setup_purchase_membership_url(cls) -> None:
282284
283285 @classmethod
284286 def _setup_membership_perks_url (cls ) -> None :
285- raw_membership_perks_url : str = (
286- os .getenv ("MEMBERSHIP_PERKS_URL" , default = "" ).strip ().lower ()
287- )
287+ raw_membership_perks_url : str = os .getenv ("MEMBERSHIP_PERKS_URL" , default = "" ).strip ()
288288
289289 if not raw_membership_perks_url :
290290 cls ._settings ["MEMBERSHIP_PERKS_URL" ] = None
@@ -293,8 +293,8 @@ def _setup_membership_perks_url(cls) -> None:
293293 if not raw_membership_perks_url .startswith ("https://" ):
294294 raw_membership_perks_url = "https://" + raw_membership_perks_url
295295 logger .warning (
296- "MEMBERSHIP_PERKS_URL does not start with 'https://'. "
297- "Please ensure all URLs are valid https URLs." ,
296+ "MEMBERSHIP_PERKS_URL was missing a URL protocol. "
297+ "Please ensure all URLs are valid HTTPS URLs." ,
298298 )
299299
300300 if not validators .url (raw_membership_perks_url ):
@@ -307,9 +307,9 @@ def _setup_membership_perks_url(cls) -> None:
307307
308308 @classmethod
309309 def _setup_custom_discord_invite_url (cls ) -> None :
310- raw_custom_discord_invite_url : str = (
311- os . getenv ( "CUSTOM_DISCORD_INVITE_URL" , default = "" ). strip (). lower ()
312- )
310+ raw_custom_discord_invite_url : str = os . getenv (
311+ "CUSTOM_DISCORD_INVITE_URL" , default = ""
312+ ). strip ()
313313
314314 if not raw_custom_discord_invite_url :
315315 cls ._settings ["CUSTOM_DISCORD_INVITE_URL" ] = None
@@ -318,8 +318,8 @@ def _setup_custom_discord_invite_url(cls) -> None:
318318 if not raw_custom_discord_invite_url .startswith ("https://" ):
319319 raw_custom_discord_invite_url = "https://" + raw_custom_discord_invite_url
320320 logger .warning (
321- "CUSTOM_DISCORD_INVITE_URL does not start with 'https://'. "
322- "Please ensure all URLs are valid https URLs." ,
321+ "CUSTOM_DISCORD_INVITE_URL was missing a URL protocol. "
322+ "Please ensure all URLs are valid HTTPS URLs." ,
323323 )
324324
325325 if not validators .url (raw_custom_discord_invite_url ):
@@ -500,7 +500,10 @@ def _setup_send_introduction_reminders_delay(cls) -> None:
500500
501501 raw_send_introduction_reminders_delay : re .Match [str ] | None = re .fullmatch (
502502 r"\A(?:(?P<seconds>(?:\d*\.)?\d+)s)?(?:(?P<minutes>(?:\d*\.)?\d+)m)?(?:(?P<hours>(?:\d*\.)?\d+)h)?(?:(?P<days>(?:\d*\.)?\d+)d)?(?:(?P<weeks>(?:\d*\.)?\d+)w)?\Z" ,
503- os .getenv ("SEND_INTRODUCTION_REMINDERS_DELAY" , "40h" ).strip ().replace (" " , "" ),
503+ os .getenv ("SEND_INTRODUCTION_REMINDERS_DELAY" , "40h" )
504+ .strip ()
505+ .lower ()
506+ .replace (" " , "" ),
504507 )
505508
506509 raw_timedelta_send_introduction_reminders_delay : timedelta = timedelta ()
@@ -546,7 +549,10 @@ def _setup_send_introduction_reminders_interval(cls) -> None:
546549
547550 raw_send_introduction_reminders_interval : re .Match [str ] | None = re .fullmatch (
548551 r"\A(?:(?P<seconds>(?:\d*\.)?\d+)s)?(?:(?P<minutes>(?:\d*\.)?\d+)m)?(?:(?P<hours>(?:\d*\.)?\d+)h)?\Z" ,
549- os .getenv ("SEND_INTRODUCTION_REMINDERS_INTERVAL" , "6h" ).strip ().replace (" " , "" ),
552+ os .getenv ("SEND_INTRODUCTION_REMINDERS_INTERVAL" , "6h" )
553+ .strip ()
554+ .lower ()
555+ .replace (" " , "" ),
550556 )
551557
552558 raw_timedelta_details_send_introduction_reminders_interval : Mapping [str , float ] = {
@@ -611,7 +617,10 @@ def _setup_send_get_roles_reminders_delay(cls) -> None:
611617
612618 raw_send_get_roles_reminders_delay : re .Match [str ] | None = re .fullmatch (
613619 r"\A(?:(?P<seconds>(?:\d*\.)?\d+)s)?(?:(?P<minutes>(?:\d*\.)?\d+)m)?(?:(?P<hours>(?:\d*\.)?\d+)h)?(?:(?P<days>(?:\d*\.)?\d+)d)?(?:(?P<weeks>(?:\d*\.)?\d+)w)?\Z" ,
614- os .getenv ("SEND_GET_ROLES_REMINDERS_DELAY" , "40h" ).strip ().replace (" " , "" ),
620+ os .getenv ("SEND_GET_ROLES_REMINDERS_DELAY" , "40h" )
621+ .strip ()
622+ .lower ()
623+ .replace (" " , "" ),
615624 )
616625
617626 raw_timedelta_send_get_roles_reminders_delay : timedelta = timedelta ()
@@ -659,6 +668,7 @@ def _setup_advanced_send_get_roles_reminders_interval(cls) -> None:
659668 r"\A(?:(?P<seconds>(?:\d*\.)?\d+)s)?(?:(?P<minutes>(?:\d*\.)?\d+)m)?(?:(?P<hours>(?:\d*\.)?\d+)h)?\Z" ,
660669 os .getenv ("ADVANCED_SEND_GET_ROLES_REMINDERS_INTERVAL" , "24h" )
661670 .strip ()
671+ .lower ()
662672 .replace (" " , "" ),
663673 )
664674
@@ -711,7 +721,7 @@ def _setup_statistics_days(cls) -> None:
711721 def _setup_statistics_roles (cls ) -> None :
712722 raw_statistics_roles : str = os .getenv ("STATISTICS_ROLES" , default = "" ).strip ()
713723
714- cls . _settings [ "STATISTICS_ROLES" ] = (
724+ statistics_roles : AbstractSet [ str ] = (
715725 {
716726 raw_statistics_role .strip ()
717727 for raw_statistics_role in raw_statistics_roles .split ("," )
@@ -721,6 +731,10 @@ def _setup_statistics_roles(cls) -> None:
721731 else DEFAULT_STATISTICS_ROLES
722732 )
723733
734+ cls ._settings ["STATISTICS_ROLES" ] = (
735+ statistics_roles if statistics_roles else DEFAULT_STATISTICS_ROLES
736+ )
737+
724738 @classmethod
725739 def _setup_moderation_document_url (cls ) -> None :
726740 MODERATION_DOCUMENT_URL_MESSAGE : Final [str ] = (
0 commit comments