-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
39 lines (28 loc) · 1020 Bytes
/
config.py
File metadata and controls
39 lines (28 loc) · 1020 Bytes
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
from aiogram import Bot
from aiogram import Dispatcher
from aiogram.client.default import DefaultBotProperties
from aiogram.fsm.storage.redis import RedisStorage
from pydantic_settings import BaseSettings
from supabase import Client, create_client
class EnvSettings(BaseSettings):
"""
Environment settings.
"""
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
extra = "ignore"
class BotSettings(EnvSettings):
token: str
class SupabaseSettings(EnvSettings):
supabase_url: str
supabase_key: str
bot_settings = BotSettings()
supabase_settings = SupabaseSettings()
url: str = supabase_settings.supabase_url
key: str = supabase_settings.supabase_key
supabase: Client = create_client(url, key)
storage = RedisStorage.from_url(os.getenv('REDIS_URL'))
default = DefaultBotProperties(parse_mode='Markdown', protect_content=False)
bot = Bot(token=bot_settings.token, default=default)
dp = Dispatcher(storage=storage)