oira666_tg 1.0.21 → 1.0.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oira666_tg",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "tg framework for oira666",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,14 +1,24 @@
1
1
  module.exports = async (ctx) => {
2
- const commands = _parse_commands(ctx.message.text);
3
- if (!commands.length) {
2
+ if (ctx.handler.type !== 'expected_input') {
4
3
  await ctx.telegram.sendMessage(
5
4
  ctx.chat.id,
6
- ctx.t`Чтобы установить команды, напишите их с новой строки после /set_my_commands в формате:
5
+ ctx.t`Пришли мне команды в формате:
7
6
 
8
7
  Команда - Описание
9
8
  Команда - Описание
10
9
  `
11
10
  );
11
+ ctx.expected_input = 'set_my_commands';
12
+ return;
13
+ }
14
+
15
+ const commands = _parse_commands(ctx.message.text);
16
+ if (!commands.length) {
17
+ await ctx.telegram.sendMessage(
18
+ ctx.chat.id,
19
+ ctx.t`Не получилось разобрать команды, пришли ещё раз`
20
+ );
21
+ ctx.expected_input = 'set_my_commands';
12
22
  return;
13
23
  }
14
24
 
@@ -37,8 +47,7 @@ function _parse_commands(text) {
37
47
  const description = _c[1]?.trim();
38
48
 
39
49
  if (!command) return null;
40
- if (!command.test(/^[a-zA-Z0-9_]+$/)) return null;
41
- if (command === 'set_my_commands' || command === '/set_my_commands') return null;
50
+ if (!/^[a-zA-Z0-9_]+$/.test(command)) return null;
42
51
 
43
52
  return { command, description: description || command };
44
53
  })