diff --git a/telegram-application/poetry.lock b/telegram-application/poetry.lock index 1df021a..23ef93f 100644 --- a/telegram-application/poetry.lock +++ b/telegram-application/poetry.lock @@ -1706,4 +1706,4 @@ propcache = ">=0.2.0" [metadata] lock-version = "2.1" python-versions = ">=3.11, <4.0" -content-hash = "4c5bdf8bea56a29cbf6eb743a2c3e1214b327580f86788e9bdbf609a379732af" +content-hash = "65b93102052fc6bdc2add0c17d35a9b9d32f43265ea51509de7ef1dc24bd1123" diff --git a/telegram-application/pyproject.toml b/telegram-application/pyproject.toml index 69ce500..eccdbf6 100644 --- a/telegram-application/pyproject.toml +++ b/telegram-application/pyproject.toml @@ -8,7 +8,6 @@ authors = [ readme = "README.md" requires-python = ">=3.11, <4.0" dependencies = [ - "pyrogram (>=2.0.106,<3.0.0)", "tgcrypto (>=1.2.5,<2.0.0)", "kurigram (>=2.1.37,<3.0.0)", "httpx (>=0.28.1,<0.29.0)", @@ -19,7 +18,8 @@ dependencies = [ "google-generativeai (>=0.8.4,<0.9.0)", "faststream[rabbitmq] (>=0.5.34,<0.6.0)", "asyncpg (>=0.30.0,<0.31.0)", - "aio-pika (>=9.5.4,<10.0.0)" + "aio-pika (>=9.5.4,<10.0.0)", + "pyrogram (>=2.0.106,<3.0.0)" ] diff --git a/telegram-application/src/core/settings/account.py b/telegram-application/src/core/settings/account.py new file mode 100644 index 0000000..22a5c1f --- /dev/null +++ b/telegram-application/src/core/settings/account.py @@ -0,0 +1,7 @@ +from pydantic import BaseModel + + +class AccountSettings(BaseModel): + API_ID: int + API_HASH: str + NAME: str = "tg_account" \ No newline at end of file diff --git a/telegram-application/src/core/settings/base.py b/telegram-application/src/core/settings/base.py index 8b27df9..3431a04 100644 --- a/telegram-application/src/core/settings/base.py +++ b/telegram-application/src/core/settings/base.py @@ -1,6 +1,7 @@ from pydantic_settings import BaseSettings, SettingsConfigDict from src.core.common.constants import PydanticEnvPrefixEnum, EnvFileLocation, EnvironmentEnum +from src.core.settings.account import AccountSettings from src.core.settings.bot import BotSettings from src.core.settings.database import DatabaseSettings @@ -27,6 +28,7 @@ class Settings(BaseSettings): NOTIFY: NotifySettings = NotifySettings() BOT: BotSettings + ACCOUNT: AccountSettings GROQ: GroqSettings GEMINI: GeminiSettings diff --git a/telegram-application/src/core/tg_service/constants.py b/telegram-application/src/core/tg_service/constants.py index c69c213..1614011 100644 --- a/telegram-application/src/core/tg_service/constants.py +++ b/telegram-application/src/core/tg_service/constants.py @@ -1 +1 @@ -MESSAGE_CHANG_SIZE: int = 2 \ No newline at end of file +MESSAGE_CHANG_SIZE: int = 20 \ No newline at end of file diff --git a/telegram-application/src/core/tg_service/messages_handler.py b/telegram-application/src/core/tg_service/messages_handler.py index 8ae1402..b4bf22f 100644 --- a/telegram-application/src/core/tg_service/messages_handler.py +++ b/telegram-application/src/core/tg_service/messages_handler.py @@ -10,6 +10,7 @@ DATA: dict[int, list[MessageFromChatSchema]] = dict() async def message_listener(client: Client, message: Message): + print("received message") if api_tg_utils.check_message_condition(message): await check_user_exists( user_pyrogram=message.from_user, diff --git a/telegram-application/src/core/tg_service/notify_success.py b/telegram-application/src/core/tg_service/notify_success.py index 89036f1..7504735 100644 --- a/telegram-application/src/core/tg_service/notify_success.py +++ b/telegram-application/src/core/tg_service/notify_success.py @@ -17,6 +17,6 @@ async def notify_for_success( chat=chat, ) - await send_to_tg_from_bot( - text=message - ) \ No newline at end of file + # await send_to_tg_from_bot( + # text=message + # ) \ No newline at end of file diff --git a/telegram-application/src/core/tg_service/utils.py b/telegram-application/src/core/tg_service/utils.py index d05fa01..5e26560 100644 --- a/telegram-application/src/core/tg_service/utils.py +++ b/telegram-application/src/core/tg_service/utils.py @@ -22,20 +22,21 @@ def create_and_format_message( user_model: User, ) -> str: if user_model.username: - user_link = f"{user_model.username}](tg://user?id={user_model.id})" + user_link = f"[{user_model.username}](tg://user?id={user_model.id})" else: user_link = f"ID: {user_model.id}" messages_text = "\n".join( f"{msg.message_time.isoformat()}: {msg.text}\n" for msg in messages ) + messages_text = '```dialog\n' + messages_text + '```' + chat_link = f"https://t.me/c/{str(chat.id)[4:]}" if str(chat.id).startswith( "-100") else f"https://t.me/{chat.id}" - return f"""🔥 *Найдена успешка!* - 👤 *Пользователь:* {user_link} + return f""" 🔥 *Найдена успешка!* + 👤 *Пользователь:* {user_link}\n 🐩 *Чат*: [{chat.title}]({chat_link}) 📌 *Причина:* {reason} - 📝 *Диалог:* {messages_text} """ \ No newline at end of file diff --git a/telegram-application/src/main.py b/telegram-application/src/main.py index 79e1bd0..5b0edba 100644 --- a/telegram-application/src/main.py +++ b/telegram-application/src/main.py @@ -5,13 +5,11 @@ from src.core.settings.base import settings from src.core.tg_service.messages_handler import message_listener from src.core.rabbitmq.connect import broker, init_queue_and_publisher -api_id = 17718565 -api_hash = "72f93973f4227415572f039d4f847082" app = Client( - name="advatroniks", - api_id=api_id, - api_hash=api_hash, + name=settings.ACCOUNT.NAME, + api_id=settings.ACCOUNT.API_ID, + api_hash=settings.ACCOUNT.API_HASH, ) app.add_handler(MessageHandler(