feat(spamblock): add SpamBot spamblock check and language support

This commit is contained in:
2026-08-02 02:14:19 +05:00
parent c96a335352
commit 7e3b31f32a
4 changed files with 69 additions and 15 deletions
+23 -6
View File
@@ -16,17 +16,23 @@ class Worker:
input_path: str = "tdata",
output_path: str = "data",
temp_path: str = "temp",
lang_code: str = "en",
):
logger.debug(f"Инициализация Worker с путями: input={input_path}, output={output_path}, temp={temp_path}")
logger.debug(
f"Инициализация Worker с путями: input={input_path}, output={output_path}, temp={temp_path}, lang={lang_code}"
)
self.input_path = Path(input_path).absolute()
self.output_path = Path(output_path).absolute()
self.temp_path = Path(temp_path).absolute()
self.lang_code = lang_code
self.valid_path = self.output_path.joinpath("valid")
self.invalid_path = self.output_path.joinpath("invalid")
self.all_path = self.valid_path.joinpath("all.txt")
logger.debug(f"Пути настроены: valid={self.valid_path}, invalid={self.invalid_path}")
logger.debug(
f"Пути настроены: valid={self.valid_path}, invalid={self.invalid_path}"
)
async def __aenter__(self):
logger.debug("Вход в контекстный менеджер Worker")
@@ -105,10 +111,15 @@ class Worker:
logger.debug(f"Не удалось получить флаг для страны '{result.country}': {e}")
flag = "🌐"
spamblock_status = "unknown"
if result.spamblock is not None:
spamblock_status = "true" if result.spamblock else "false"
return (
f"👤 [{flag} {result.country}] {result.me.phone}{result.me.id}\n"
f"👤 [{flag} {result.country}] +{result.me.phone}{result.me.id}\n"
f"⭐️ {result.stars}\n"
f"💎 Premium: {'true' if result.me.premium else 'false'}\n"
f"🚫 Spamblock: {spamblock_status}\n"
f"👥 {len(result.chats)}/{len(result.contacts)}\n"
f"🍀 {len(result.admin_channels)}"
)
@@ -162,11 +173,17 @@ class Worker:
logger.info(f"Проверка TDATA: {tdata.name}")
try:
async with Checker(path=tdata_absolute, temp_path=self.temp_path) as checker:
async with Checker(
path=tdata_absolute, temp_path=self.temp_path, lang_code=self.lang_code
) as checker:
result = await checker.check_all()
logger.info(f"Проверка завершена: {result.me.first_name} (+{result.me.phone})")
self.__save_valid(user_id=result.me.id, result=result, tdata=tdata_absolute)
logger.info(
f"Проверка завершена: {result.me.first_name} (+{result.me.phone})"
)
self.__save_valid(
user_id=result.me.id, result=result, tdata=tdata_absolute
)
except SessionInvalid:
logger.warning(f"TDATA невалидна: {tdata.name}")