add fix for checker condidtinos

This commit is contained in:
harold 2025-06-14 00:14:26 +05:00
parent 231d449203
commit 7e1889ef6d
4 changed files with 10 additions and 3 deletions

View File

@ -5,3 +5,4 @@ class AccountSettings(BaseModel):
API_ID: int
API_HASH: str
NAME: str = "tg_account"
SESSION: str

View File

@ -12,11 +12,13 @@ from telethon.types import Message, User, Chat, Channel
DATA: dict[int, list[MessageFromChatSchema]] = dict()
lock = asyncio.Lock()
@telethon_client.on(event=NewMessage)
async def message_listener(event: NewMessage.Event) -> None:
print("received new message")
message: Message = event.message
sender: User = await event.get_sender()
chat: TELETHON_CHAT_TYPES = await event.get_chat()

View File

@ -15,6 +15,9 @@ def check_message_condition(
sender: User,
chat_type: CustomChatTypes,
) -> bool:
if isinstance(sender, Channel):
return False
if chat_type == CustomChatTypes.PRIVATE_GROUP:
return False
@ -36,7 +39,7 @@ def check_message_condition(
def create_and_format_message(
reason: str,
chat: TgChat,
user_model: User,
user_model: User | Channel,
) -> str:
def escape_markdown_v2(text: str) -> str:
if not text:

View File

@ -1,13 +1,14 @@
import asyncio
from telethon import TelegramClient
from telethon.sessions import StringSession
from src.core.settings.base import settings
loop = asyncio.get_event_loop()
telethon_client = TelegramClient(
settings.ACCOUNT.NAME,
session=StringSession(settings.ACCOUNT.SESSION),
api_id=settings.ACCOUNT.API_ID,
api_hash=settings.ACCOUNT.API_HASH,
loop=loop,