lnp2pBot / lnp2pBot/bot

Bug: Persian taker message not delivered due to Telegram MarkdownV2 parse error — proposed fallback fix

Open
#882 4 comments 0 reactions 1 assignee View on GitHub

@ToRyVand is already working on this.

Since Aug 10, 2026.

bug good first issue help wanted priority: high UX
Dominant language
TypeScript
Stars
292
Forks
136
Avg merge
19m
Merged PRs (30d)
1

Description

Summary

When a user with language set to Persian (fa) takes an order, the bot sometimes does not send the taker message. Root cause: the Persian translation for the key you_took_someone_order can contain characters that break Telegram's MarkdownV2 parsing, causing bot.telegram.sendMessage(...) to throw and the message not to reach the taker.

Reproduction

  1. Set a Telegram user language to Persian (fa) in the bot.
  2. Publish an order (sell/buy) and have another user take it.
  3. Observe that the taker (buyer/seller) does not receive the "you took order" message and logs show a MarkdownV2 parse-related error.

Proposed fix

Wrap the sendMessage call in beginTakeSellMessage with a try/catch that:

  • first attempts to send with parse_mode: 'MarkdownV2' (preserve intended formatting for safe locales),
  • on failure retries once without parse_mode as a safe fallback.

Minimal patch (applies to bot/messages.ts, function beginTakeSellMessage):

const message = ctx.i18n.t('you_took_someone_order', { expirationTime });
try {
await bot.telegram.sendMessage(buyer.tg_id, message, { parse_mode: 'MarkdownV2' });
} catch (err) {
logger.error('Failed to send MarkdownV2 message, retrying without parse_mode', err);
try { await bot.telegram.sendMessage(buyer.tg_id, message); } catch (err2) { logger.error('Retry without parse_mode also failed', err2); }
}

Why this is safe

  • Keeps MarkdownV2 for locales/translations that are already Markdown-safe.
  • Ensures users still receive the message when translations contain unescaped characters.
  • Minimal and local change; no behaviour change for other flows.

Files changed (local patch created)

  • bot/messages.ts (beginTakeSellMessage) — patch saved locally as:
    C:\Users\gatmiri.majid.copilot\session-state\22f19408-ad09-4767-974a8a675dc4a3a9\files\0001-Fix-fallback-for-MarkdownV2-send-in-beginTakeSellMes.patch

Testing

  • Run the bot (npm run dev or npm start). Set a user language to fa and take an order. Taker should receive the message.
  • If errors still occur, inspect logs for Telegram parse errors and escape MarkdownV2 special chars in locales/fa.yaml (key: you_took_someone_order).

Next steps

  • Apply the change and merge into main/release branch.
  • Optional: sanitize/escape MarkdownV2 in locales/fa.yaml to keep full MarkdownV2 formatting.

If useful, I can open a PR directly if given push rights; otherwise please apply the patch above or run the included patch with git am.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.