@thesashadev/girl-agent 0.1.6 → 0.1.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.7 — MarkdownV2 escaping fix
4
+
5
+ Дата: 2026-05-06
6
+
7
+ - Исправлена ошибка `400: Bad Request: can't parse entities` при отправке сообщений с точками, скобками и другими зарезервированными символами MarkdownV2. (#15)
8
+ - Добавлен `escapeMarkdownV2()` хелпер для экранирования всех 18 зарезервированных символов.
9
+ - Fallback на plain text если экранирование не помогает.
10
+
3
11
  ## 0.1.6 — --new flag
4
12
 
5
13
  Дата: 2026-05-06
package/dist/cli.js CHANGED
@@ -18,6 +18,19 @@ var init_esm_shims = __esm({
18
18
  }
19
19
  });
20
20
 
21
+ // src/telegram/markdown.ts
22
+ function escapeMarkdownV2(text) {
23
+ return text.replace(MD2_RESERVED, "\\$1");
24
+ }
25
+ var MD2_RESERVED;
26
+ var init_markdown = __esm({
27
+ "src/telegram/markdown.ts"() {
28
+ "use strict";
29
+ init_esm_shims();
30
+ MD2_RESERVED = /([_*\[\]()~`>#+\-=|{}.!\\])/g;
31
+ }
32
+ });
33
+
21
34
  // src/telegram/userbot.ts
22
35
  var userbot_exports = {};
23
36
  __export(userbot_exports, {
@@ -177,7 +190,11 @@ function makeUserbotAdapter(cfg) {
177
190
  },
178
191
  async editLastMessage(chatId, messageId, text) {
179
192
  const peer = await resolvePeer(chatId);
180
- await client.editMessage(peer, { message: messageId, text, parseMode: "MarkdownV2" });
193
+ try {
194
+ await client.editMessage(peer, { message: messageId, text: escapeMarkdownV2(text), parseMode: "MarkdownV2" });
195
+ } catch {
196
+ await client.editMessage(peer, { message: messageId, text });
197
+ }
181
198
  },
182
199
  async deleteMessages(chatId, messageIds, revoke = false) {
183
200
  const peer = await resolvePeer(chatId);
@@ -241,6 +258,7 @@ var init_userbot = __esm({
241
258
  "src/telegram/userbot.ts"() {
242
259
  "use strict";
243
260
  init_esm_shims();
261
+ init_markdown();
244
262
  }
245
263
  });
246
264
 
@@ -275,8 +293,13 @@ function makeBotAdapter(cfg) {
275
293
  });
276
294
  },
277
295
  async sendText(chatId, text) {
278
- const msg = await bot.api.sendMessage(chatId, text, { parse_mode: "MarkdownV2" });
279
- return msg.message_id;
296
+ try {
297
+ const msg = await bot.api.sendMessage(chatId, escapeMarkdownV2(text), { parse_mode: "MarkdownV2" });
298
+ return msg.message_id;
299
+ } catch {
300
+ const msg = await bot.api.sendMessage(chatId, text);
301
+ return msg.message_id;
302
+ }
280
303
  },
281
304
  async setTyping(chatId, on) {
282
305
  if (on) {
@@ -318,6 +341,7 @@ var init_bot = __esm({
318
341
  "src/telegram/bot.ts"() {
319
342
  "use strict";
320
343
  init_esm_shims();
344
+ init_markdown();
321
345
  }
322
346
  });
323
347
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thesashadev/girl-agent",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Telegram AI persona engine with memory, schedule, relationship state and MTProto userbot mode.",
5
5
  "type": "module",
6
6
  "bin": {