tdlib / telegram-bot-api

Telegram Bot API server
https://core.telegram.org/bots
Boost Software License 1.0
2.94k stars 569 forks source link

Message entities are not preserved by `editMessageText` and `editMessageMedia` #587

Closed taminomara closed 1 month ago

taminomara commented 1 month ago

Hi! I'm trying to update a message with editMessageText. It works fine, but message entities are ignored, and if I only update entities but not text, I get 400: message is not modified.

Here's the request that's sent to the API, and the error. ``` err: { "type": "GrammyError", "message": "Call to 'editMessageText' failed! (400: Bad Request: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message)", "stack": GrammyError: Call to 'editMessageText' failed! (400: Bad Request: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message) at toGrammyError (/home/taminomara/regbot/node_modules/grammy/out/core/error.js:45:12) at ApiClient.callApi (/home/taminomara/regbot/node_modules/grammy/out/core/client.js:90:48) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at handleMessageEdit (/home/taminomara/regbot/src/bot/features/edit-cache.ts:44:7) at async /home/taminomara/regbot/node_modules/grammy/out/composer.js:61:13 at async /home/taminomara/regbot/node_modules/grammy/out/composer.js:56:9 at async /home/taminomara/regbot/node_modules/grammy/out/composer.js:532:13 at async /home/taminomara/regbot/node_modules/grammy/out/composer.js:61:13 at async /home/taminomara/regbot/node_modules/grammy/out/composer.js:532:13 at async /home/taminomara/regbot/node_modules/grammy/out/composer.js:61:13 "method": "editMessageText", "payload": { "chat_id": ..., "message_id": 163, "text": "123 4 5 6 6 7 8 9 @foobar", "entities": [ { "offset": 0, "length": 3, "type": "strikethrough" }, { "offset": 6, "length": 1, "type": "bold" }, { "offset": 10, "length": 7, "type": "code" }, { "offset": 18, "length": 7, "type": "mention" } ] }, "ok": false, "name": "GrammyError", "error_code": 400, "description": "Bad Request: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message", "parameters": {} } ```
taminomara commented 1 month ago

Workaround is converting entities to HTML and using parse mode HTML.

taminomara commented 1 month ago

Ok, it seems like my code was adding parse_mode: "HTML" and it didn't show up in the logs due to config error. My mistake, closing now :)