Answer the question
In order to leave comments, you need to log in
Is it possible to get message id from bot (telegram)?
I am writing a bot based on the aiogram library.
You need to get the id of a specific message from the bot.
The situation is this: the bot issues orders from the database (in a cycle) and each order can be assigned a status (accepted or not), but in order to assign it, I need to get the order id, and so it is stored in a specific message of the bot, you need to find exactly this message and more read it once to find the order id.
I know how to find the order id in the message, but I can’t get the bot’s message id.
Can you suggest something or is there any alternative solutions to this issue?
@dp.callback_query_handler(text='check_new_ords')
async def process_order_callback_2(query: types.CallbackQuery):
if answer_ord_date == 'check_new_ords':
if len(records):
await bot.send_message(query.from_user.id, text='Хорошо! Вывожу новые заказы:')
for r in records:
if r[6] == 1:
client_id_1= int(re.search('\d+',r[1]).group(0))
cl_name = db.get_client_name(client_id_1)
await bot.send_message(query.from_user.id,
text=f"Заказ № {r[0]}\nСтатус: НА РАССМОТРЕНИИ.\nНазвание работы: {r[2]}\nОписание: {r[3]}\nКлиент: {cl_name}\nДата создания заказа:\n{r[5]}\n\n",
reply_markup=nav.order_list_admin_1)
await bot.send_message(query.from_user.id, text='Выберите пункт меню:',reply_markup=nav.back_admin_menu_order)
@dp.callback_query_handler(text="accept_ord")
@dp.callback_query_handler(text="refusal_ord")
async def process_order_callback_3(query: types.CallbackQuery):
answ_date_2=query.data
if answ_date_2 == "accept_ord":
status = 2
## Вот здесь я застрял
message_id=
##
db.set_new_status(id, status)
await bot.send_message(query.from_user.id, text=f'ЗАКАЗ №{id} ПРИНЯТ', reply_markup=nav.back_admin_menu_order)
Answer the question
In order to leave comments, you need to log in
Can't find message by ID. If you mean receiving a message as in your code, then
message_id=query.message.message_id
If you have a message id, then you can easily find the sent message completely!
The bottom line is that you are using forwardMessage
await bot.forward_message(chat_id=<чат id КУДА ПЕРЕСЛАТЬ СООБЩЕНИЕ>, from_chat_id=<чат id ГДЕ БЫЛО ОТПРАВЛЕНО СООБЩЕНИЕ>, message_id<id сообщения>)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question