@shliamb/dsh-telegram-bot 0.2.2 → 0.2.3

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/README.md CHANGED
@@ -59,13 +59,13 @@ Adding a new bundle requires a Host restart. Chat sessions and bindings survive
59
59
  The repository also contains a ready-to-install archive:
60
60
 
61
61
  ```text
62
- dist/shliamb-dsh-telegram-bot-0.2.2.tgz
62
+ dist/shliamb-dsh-telegram-bot-0.2.3.tgz
63
63
  ```
64
64
 
65
65
  If the `dsh` CLI is on your `PATH`, run this from the repository root:
66
66
 
67
67
  ```bash
68
- dsh plugin --profile web add ./dist/shliamb-dsh-telegram-bot-0.2.2.tgz
68
+ dsh plugin --profile web add ./dist/shliamb-dsh-telegram-bot-0.2.3.tgz
69
69
  dsh web
70
70
  ```
71
71
 
@@ -73,7 +73,7 @@ If you run Harness from a source checkout, use `pnpm dsh` from that checkout and
73
73
 
74
74
  ```bash
75
75
  cd /path/to/deepseek-harness
76
- pnpm dsh plugin --profile web add /path/to/HarnessBot/dist/shliamb-dsh-telegram-bot-0.2.2.tgz
76
+ pnpm dsh plugin --profile web add /path/to/HarnessBot/dist/shliamb-dsh-telegram-bot-0.2.3.tgz
77
77
  pnpm dsh web
78
78
  ```
79
79
 
package/README.ru.md CHANGED
@@ -59,13 +59,13 @@ pnpm dsh web
59
59
  В репозитории также лежит готовый к установке архив:
60
60
 
61
61
  ```text
62
- dist/shliamb-dsh-telegram-bot-0.2.2.tgz
62
+ dist/shliamb-dsh-telegram-bot-0.2.3.tgz
63
63
  ```
64
64
 
65
65
  Если команда `dsh` доступна в `PATH`, выполните из корня репозитория:
66
66
 
67
67
  ```bash
68
- dsh plugin --profile web add ./dist/shliamb-dsh-telegram-bot-0.2.2.tgz
68
+ dsh plugin --profile web add ./dist/shliamb-dsh-telegram-bot-0.2.3.tgz
69
69
  dsh web
70
70
  ```
71
71
 
@@ -73,7 +73,7 @@ dsh web
73
73
 
74
74
  ```bash
75
75
  cd /path/to/deepseek-harness
76
- pnpm dsh plugin --profile web add /path/to/HarnessBot/dist/shliamb-dsh-telegram-bot-0.2.2.tgz
76
+ pnpm dsh plugin --profile web add /path/to/HarnessBot/dist/shliamb-dsh-telegram-bot-0.2.3.tgz
77
77
  pnpm dsh web
78
78
  ```
79
79
 
package/lib/index.js CHANGED
@@ -244,6 +244,8 @@ const STRINGS = {
244
244
  openMenu: 'Menu',
245
245
  },
246
246
  };
247
+ /** Commands handled by dedicated grammY handlers; text starting with one is not a question answer. */
248
+ const BOT_TEXT_COMMANDS = new Set(['start', 'menu', 'admin', 'new', 'compact', 'stop', 'status', 'logs']);
247
249
  function t(locale, key) {
248
250
  return STRINGS[locale][key];
249
251
  }
@@ -471,7 +473,7 @@ async function getBalance(runtime, locale, force = false) {
471
473
  }
472
474
  try {
473
475
  const result = await runtime.account.getBalance({
474
- version: '@shliamb/dsh-telegram-bot/0.2.2',
476
+ version: '@shliamb/dsh-telegram-bot/0.2.3',
475
477
  locale,
476
478
  timezoneOffsetSeconds: -new Date().getTimezoneOffset() * 60,
477
479
  });
@@ -2088,22 +2090,28 @@ async function runBot(ctx, config, workspaces, sessions, credentials, logger, si
2088
2090
  });
2089
2091
  bot.on('message:text', async (grammyCtx) => {
2090
2092
  const text = grammyCtx.message.text;
2091
- if (text.startsWith('/'))
2092
- return;
2093
2093
  const chatId = grammyCtx.chat.id;
2094
2094
  const userId = grammyCtx.from.id;
2095
2095
  const locale = localeOf(grammyCtx.from.language_code);
2096
2096
  const messageId = grammyCtx.message.message_id;
2097
2097
  const questionToken = runtime.pendingQuestionChats.get(chatId);
2098
- if (questionToken !== undefined) {
2099
- const pending = runtime.pendingQuestions.get(questionToken);
2100
- if (pending !== undefined) {
2101
- answerQuestionWithText(runtime, pending, text);
2102
- return;
2103
- }
2098
+ const pendingQuestion = questionToken === undefined ? undefined : runtime.pendingQuestions.get(questionToken);
2099
+ if (questionToken !== undefined && pendingQuestion === undefined)
2104
2100
  runtime.pendingQuestionChats.delete(chatId);
2105
- }
2106
2101
  const approvalToken = runtime.pendingApprovalChats.get(chatId);
2102
+ if (text.startsWith('/')) {
2103
+ const command = text.slice(1).split(/[ @]/, 1)[0]?.toLowerCase();
2104
+ if (command !== undefined && BOT_TEXT_COMMANDS.has(command))
2105
+ return;
2106
+ // A slash-prefixed custom answer is valid while a question is open (for
2107
+ // example a path); only commands are reserved.
2108
+ if (pendingQuestion === undefined && approvalToken === undefined)
2109
+ return;
2110
+ }
2111
+ if (pendingQuestion !== undefined) {
2112
+ answerQuestionWithText(runtime, pendingQuestion, text);
2113
+ return;
2114
+ }
2107
2115
  if (approvalToken !== undefined) {
2108
2116
  logger.info('approval-text-blocked', 'text ignored while an approval is pending', { chatId });
2109
2117
  await grammyCtx.reply(t(locale, 'approvalTextOnly')).catch(() => undefined);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shliamb/dsh-telegram-bot",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Telegram bridge for DeepSeek Harness",
5
5
  "keywords": [
6
6
  "deepseek-harness",