парсер

This commit is contained in:
Artem Tsyrulnikov
2026-01-06 21:04:42 +03:00
parent b77e4fd0b6
commit 2c0ae2dfc3
45 changed files with 2202 additions and 51 deletions

View File

@@ -9,10 +9,6 @@ from shared.telegram_base import TelegramConfig
from src.adapter.s3 import S3Config
class AppConfig(BaseModel):
URL: str
class ParserConfig(BaseModel):
URL: str
@@ -20,7 +16,6 @@ class ParserConfig(BaseModel):
class Settings(BaseSettings):
model_config = SettingsConfigDict(env_file='.env', case_sensitive=False, env_nested_delimiter='__')
app: AppConfig
db: DatabaseConfig
logger: LoggerConfig
telegram: TelegramConfig

View File

@@ -1,5 +1,4 @@
import logging
import random
import uuid
from typing import TYPE_CHECKING
@@ -131,13 +130,17 @@ async def create_purchase(
channel = await self.database.get_channel(username=channel_input.username)
if not channel:
parser_response = await self.parser.fetch_telegram_channel(channel_input.username)
if not parser_response:
raise domain.TelegramChannelNotFound(channel_input.username)
channel = domain.Channel(
username=channel_input.username,
telegram_id=random.randint(1, 10000),
title='parser_response.title',
username=parser_response.username,
telegram_id=parser_response.telegram_id,
title=parser_response.title,
)
await self.database.create_channel(channel)
log.info('Created channel @%s with telegram_id=%s', channel_input.username, channel.telegram_id)
log.info('Created channel @%s with telegram_id=%s', channel.username, channel.telegram_id)
invite_link = await self.telegram_bot.create_chat_invite_link(project.channel.telegram_id, requires_approval)