I want to transfer the user id when clicking on a telegram web app button
async def send_message_to_channel(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
chat_id = '@2222222' # Используйте ID вашего канала
image_url = "https://i.ibb.co/RjCnn2d/photo-5472102692806581894-x.jpg"
user_id = update.callback_query.from_user.id
web_app_url = f"https://t.me/Ddddd/ddfdf?user_id={user_id}"
button = InlineKeyboardButton(text="PLAY", url=web_app_url)
keyboard = InlineKeyboardMarkup([[button]])
caption = (" Welcome!")
try:
await context.bot.send_photo(chat_id=chat_id, photo=image_url, caption=caption, reply_markup=keyboard)
await update.message.reply_text("Сообщение с картинкой и текстом отправлено в канал!")
except Exception as e:
logger.error(f"Ошибка при отправке сообщения: {e}")
await update.message.reply_text(f"Ошибка при отправке сообщения: {e}")
New contributor
Eduard Ivanov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.