question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support/Request: editMessageText documentation needed

See original GitHub issue

Hello, I’ve been playing with Telegraf for a while and can’t find enough details or examples of how to use editMessageText. I read through the Telegraf and Telegram docs but have not been able to get my issue sorted out.

I am working on a standard messaging bot (bot <==> user) and am sending messages via ctx.reply. I would like to edit those messages later on, but am unable to find the proper context/format. I am already passing the chat and message IDs back from the reply I’m sending.

Can I make a request for a simple example of a bot editing its own message sent via reply?

I am looking for something along these lines:

bot.on('message', (ctx) => { ctx.reply("hello world").then((msgInfo) => { bot.editMessageText(msgInfo.chat.id, msgInfo.message_id, "goodbye"); }); (Format for that is probably wrong, I have tried several variations/contexts, consider it pseudocode) In reality I would be passing the message ID and chat ID to a function which processes info, then use it to update the staus of a job for the user

Application/context: I allow users to send links to my bot (ytdl-core stuff) which then downloads the media and does some processing. Currently my bot notifies when it starts downloading, then sends a second message upon completion. This is both noisy, and as the processes are async, a bit confusing matching multiple starts/completions up. My goal is to have a message that reads something like: Video: Title here\n Status: Downloading Upon completion/processing, edit the message to read: Video: Title here\n Status: Complete

Thanks in advance for input!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
yanislav-igonincommented, Mar 20, 2019

I’ve figured it out

ctx.telegram.editMessageText(
  msgInfo.chat.id,
  msgInfo.message_id,
  msgInfo.message_id,
  `PLEASE`,
);
6reactions
ejnshteincommented, Mar 21, 2019

Instead of second msgInfo.message_id you can just use undefined. The third argument is for inline messages

Read more comments on GitHub >

github_iconTop Results From Across the Web

editMessageText: Edit a text message in telegram.bot - Rdrr.io
editMessageText : Edit a text message ... editMessageText, R Documentation ... Required if inline_message_id is not specified.
Read more >
How do I edit a sent message using Telegram's python bot API?
The documentation (https://core.telegram.org/bots/api#editmessagetext) says that I need to specify a message ID to edit, but I have no idea ...
Read more >
teloxide::requests::EditMessageText - Rust - Docs.rs
Use this method to edit text and game messages. On success, if edited message is sent by the bot, the edited Message is...
Read more >
Telegram Bot API
You can learn about obtaining tokens and generating new ones in this document. Making requests. All queries to the Telegram Bot API must...
Read more >
editMessageText: Edit a text message - RDocumentation
Arguments. chat_id. (Optional). Unique identifier for the target chat or username of the target channel. message_id. (Optional). Required if ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found