S
S
Smoody2021-05-06 16:13:07
Python
Smoody, 2021-05-06 16:13:07

When you press a button in a group, does the telegram bot respond by tagging something in PM, and not in the group?

@dp.message_handler(commands=["start"])
async def start_command(message: types.Message):
await message.reply('Hello! If you want to know some information, click on one of the buttons below',
reply_markup =InlineKeyboardMarkup().row(
InlineKeyboardButton(text="Dates", callback_data="button1"),
InlineKeyboardButton(text="Information", callback_data='button2')

@dp.callback_query_handler(lambda c: c.data == " button1")
async def process_callback_button1(callback_query: types.CallbackQuery):
await bot.answer_callback_query(callback_query.id)
await bot.send_message(callback_query.from_user.id ,"I don't know what else will happen here, but I'll figure it out later!")

For the second day I've been trying to build a bot in different ways so that when I click on the buttons, it would answer me in a group, and not in PM .

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Confy, 2021-05-06
@Smoody

The last line says in black and white - send a message to the user id: The
bot.send_message(callback_query.from_user.id)
chat id is located nearby, in callback_query.message.chat.id, judging by the documentation .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question