Files
2025-11-23 23:17:00 +03:00

38 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from logging import getLogger
from aiogram import Dispatcher, Bot
from aiogram.types import Message
from aiogram.filters import Command
from models.state import BotState
API_URL = "http://127.0.0.1:7700/speak"
logger = getLogger(__name__)
def register_handlers(dp: Dispatcher, state: BotState, bot: Bot):
@dp.message(Command("id"))
async def id_handler(message: Message):
# Разбираем аргументы команды
args = message.text.split()
if len(args) > 1:
try:
user_id = int(args[1]) # берём ID из аргумента
except ValueError:
await message.reply("ID должен быть числом")
return
else:
# если аргумента нет — берём ID самого пользователя
user_id = message.from_user.id
# Получаем фото профиля
photos = await bot.get_user_profile_photos(user_id=user_id)
if photos.total_count > 0:
for i, photo_sizes in enumerate(photos.photos):
file_id = photo_sizes[-1].file_id # самое большое разрешение
await message.answer_photo(file_id, caption=f"Аватар #{i + 1}")
await message.reply(f"ID пользователя: {user_id}")
else:
await message.reply(f"У пользователя {user_id} нет аватара")