@delt/claude-alarm 0.6.13 → 0.6.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -329,8 +329,8 @@ var init_telegram = __esm({
329
329
  }
330
330
  /** Send a notification message to Telegram */
331
331
  async sendNotification(sessionId2, _sessionLabel, title, message) {
332
- const text = `${title}
333
- ${message}`;
332
+ const text = `<b>${this.escHtml(title)}</b>
333
+ ${this.mdToHtml(message)}`;
334
334
  const result = await this.sendMessage(text);
335
335
  if (result?.message_id) {
336
336
  this.messageSessionMap.set(result.message_id, sessionId2);
@@ -625,6 +625,15 @@ ${label}`);
625
625
  escHtml(s) {
626
626
  return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
627
627
  }
628
+ /** Convert markdown to Telegram HTML (escape first, then apply formatting) */
629
+ mdToHtml(s) {
630
+ let html = this.escHtml(s);
631
+ html = html.replace(/```(?:\w*)\n?([\s\S]*?)```/g, "<pre>$1</pre>");
632
+ html = html.replace(/`([^`]+)`/g, "<code>$1</code>");
633
+ html = html.replace(/\*\*(.+?)\*\*/g, "<b>$1</b>");
634
+ html = html.replace(/\*(.+?)\*/g, "<i>$1</i>");
635
+ return html;
636
+ }
628
637
  /** Update config (e.g., from dashboard settings) */
629
638
  updateConfig(config2) {
630
639
  const wasPolling = this.polling;