Support/Request: editMessageText documentation needed
See original GitHub issueHello, 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:
- Created 5 years ago
- Comments:12 (2 by maintainers)
I’ve figured it out
Instead of second
msgInfo.message_id
you can just useundefined
. The third argument is for inline messages