Initial commit

This commit is contained in:
2025-12-30 23:55:43 +03:00
commit bd1def421f
29 changed files with 1071 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
__version__ = "0.1.0"
+18
View File
@@ -0,0 +1,18 @@
import asyncio
import logging
from aiogram import Bot, Dispatcher
from trudex.infrastructure.utils.config import AppConfig
async def main():
logging.basicConfig(level=logging.INFO)
config = AppConfig.from_toml()
logging.info("Бот запущен")
if __name__ == "__main__":
asyncio.run(main())
+1
View File
@@ -0,0 +1 @@
+1
View File
@@ -0,0 +1 @@
@@ -0,0 +1 @@
+4
View File
@@ -0,0 +1,4 @@
from aiogram import Router
router = Router()
@@ -0,0 +1 @@
@@ -0,0 +1 @@
+1
View File
@@ -0,0 +1 @@
+2
View File
@@ -0,0 +1,2 @@
from dataclasses import dataclass
from datetime import datetime
+1
View File
@@ -0,0 +1 @@
@@ -0,0 +1 @@
@@ -0,0 +1 @@
@@ -0,0 +1,9 @@
from sqlalchemy.ext.asyncio import AsyncEngine, async_sessionmaker, create_async_engine
def create_engine(database_url: str) -> AsyncEngine:
return create_async_engine(database_url, echo=False)
def create_session_maker(engine: AsyncEngine) -> async_sessionmaker:
return async_sessionmaker(engine, expire_on_commit=False)
@@ -0,0 +1 @@
@@ -0,0 +1,5 @@
from sqlalchemy.orm import DeclarativeBase
class Base(DeclarativeBase):
pass
+9
View File
@@ -0,0 +1,9 @@
from dishka import Provider, Scope
class DatabaseProvider(Provider):
scope = Scope.APP
class InfrastructureProvider(Provider):
scope = Scope.APP
@@ -0,0 +1 @@
@@ -0,0 +1 @@
+37
View File
@@ -0,0 +1,37 @@
import tomllib
from dataclasses import dataclass
from pathlib import Path
@dataclass
class BotConfig:
token: str
@dataclass
class DatabaseConfig:
host: str
port: int
user: str
password: str
database: str
@property
def url(self) -> str:
return f"postgresql+asyncpg://{self.user}:{self.password}@{self.host}:{self.port}/{self.database}"
@dataclass
class AppConfig:
bot: BotConfig
database: DatabaseConfig
@classmethod
def from_toml(cls, path: str | Path = "config.toml") -> "AppConfig":
with open(path, "rb") as f:
data = tomllib.load(f)
return cls(
bot=BotConfig(**data["bot"]),
database=DatabaseConfig(**data["database"])
)