add photo triget fix2

This commit is contained in:
q 2026-04-11 17:43:00 +03:00
parent d3ee72bca9
commit a2b72b6dfd

26
main.py
View file

@ -19,7 +19,7 @@ from aiogram.types import (
from aiogram.client.default import DefaultBotProperties from aiogram.client.default import DefaultBotProperties
# Локальные импорты # Локальные импорты
from AI.talk_handler import handle_chat_message, handle_talk, push_message from AI.talk_handler import handle_chat_message, handle_photo_message, handle_talk, push_message
from games.casino import play_casino from games.casino import play_casino
from games.fortune import generate_fortune from games.fortune import generate_fortune
from games.uwu import handle_uwu_cmd from games.uwu import handle_uwu_cmd
@ -47,6 +47,28 @@ _polychaetsi_lock = threading.Lock()
_polychaetsi_word_re = re.compile(r"[а-яё]+", re.IGNORECASE) _polychaetsi_word_re = re.compile(r"[а-яё]+", re.IGNORECASE)
_no_lesson_re = re.compile(r"(нету\s+пары|нет\s+пары|пары\s+нету|пары\s+нет)", re.IGNORECASE) _no_lesson_re = re.compile(r"(нету\s+пары|нет\s+пары|пары\s+нету|пары\s+нет)", re.IGNORECASE)
def _is_supported_image_message(message: Message) -> bool:
return bool(
message.photo
or (
message.document
and (message.document.mime_type or "").startswith("image/")
)
)
async def handle_unmatched_message_debug(message: Message):
logger.warning(
"Unhandled message reached fallback. content_type=%s chat_id=%s has_text=%s has_photo=%s has_document=%s caption=%s",
getattr(message, "content_type", None),
message.chat.id if message.chat else None,
bool(message.text),
bool(message.photo),
bool(message.document),
bool(message.caption),
)
_weekday_names = { _weekday_names = {
0: "Понедельник", 0: "Понедельник",
1: "Вторник", 1: "Вторник",
@ -1399,7 +1421,9 @@ def main():
dp.message.register(handle_gen_mem, Command("gen_mem")) dp.message.register(handle_gen_mem, Command("gen_mem"))
dp.message.register(handle_uwu_cmd, Command("uwu")) dp.message.register(handle_uwu_cmd, Command("uwu"))
dp.message.register(handle_nude_cmd, Command("nude")) dp.message.register(handle_nude_cmd, Command("nude"))
dp.message.register(handle_photo_message, _is_supported_image_message)
dp.message.register(handle_keywords, F.text) dp.message.register(handle_keywords, F.text)
dp.message.register(handle_unmatched_message_debug)
async def on_startup(bot: Bot): async def on_startup(bot: Bot):
try: try: