from telegram import Bot
from telegram.error import TelegramError
# Замените 'YOUR_BOT_TOKEN' на токен вашего бота
bot_token = 'YOUR_BOT_TOKEN'
username = 'USERNAME_TO_FIND'
bot = Bot(token=bot_token)
try:
user = bot.get_chat(username)
user_id = user.id
print(f"User ID for {username} is {user_id}")
except TelegramError as e:
print(f"An error occurred: {e}")