divyenduz / languagelearners

LingoParrot - LanguageLearners.club
1 stars 0 forks source link

Adjust translations in reaction to message edits #15

Closed marktani closed 4 years ago

marktani commented 5 years ago

When an original message gets edited, the translated message is currently unchanged.

With this feature in place, editing the original message would trigger a "re translation" to happen.

divyenduz commented 5 years ago

POC worked like this for normal text. Assuming that bot message was the next message to the original text. We can capture edits and perform bot edit like this.

Due to the async nature of the communication though, IRL we have to store bot reply message IDs against the original message to be able to edit them unless we can attach this information to a message itself somehow and retrieve it easily.

In my current understanding, this is a high investment task, not sure about the return yet.

bot.on("edited_message", async ctx => {
  ctx.telegram.editMessageText(
    ctx.editedMessage.chat.id,
    ctx.editedMessage.message_id + 1,
    ``, // Inline message ID. Fill it later.
    `${ctx.editedMessage.text} Zebra!`
  );
});
marktani commented 5 years ago

Let's keep this out for now, current solutions seem to be a hack and if two user messages appear close to each other we might be editing the wrong one... which is worse then accepting the current situation!

divyenduz commented 4 years ago

Implemented a good enough solution, bot sends a new quoted reply for an edit i.e. treating it like a new message. Does not edit its original message as that might be complicated to implement. Will investigate it in future again based on real users (if any) requests.

Done via https://github.com/divyenduz/LingoParrot/commit/07b7d18c04df3fddd5392331d0768201f095fb87

CleanShot 2019-12-23 at 03 51 47@2x