alemonjs 2.1.70 → 2.1.71
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/bin/alemonc.js +8 -8
- package/lib/app/router/dsl.js +27 -0
- package/package.json +1 -1
package/bin/alemonc.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {updateConfig} from './updateConfig.js';
|
|
3
|
-
import {run} from './run.js';
|
|
4
|
-
import {start} from './start.js';
|
|
5
|
-
import {versionUpdate} from './versionUpdate.js';
|
|
6
|
-
import {info} from './info.js';
|
|
7
|
-
import {platformAdd, platformRemove, platformList} from './platform.js';
|
|
8
|
-
import {login} from './login.js';
|
|
9
|
-
import {Command} from 'commander';
|
|
2
|
+
import { updateConfig } from './updateConfig.js';
|
|
3
|
+
import { run } from './run.js';
|
|
4
|
+
import { start } from './start.js';
|
|
5
|
+
import { versionUpdate } from './versionUpdate.js';
|
|
6
|
+
import { info } from './info.js';
|
|
7
|
+
import { platformAdd, platformRemove, platformList } from './platform.js';
|
|
8
|
+
import { login } from './login.js';
|
|
9
|
+
import { Command } from 'commander';
|
|
10
10
|
const program = new Command();
|
|
11
11
|
|
|
12
12
|
program.name('alemonc').description('CLI to some alemonc actions and scripts').version('1.0.0');
|
package/lib/app/router/dsl.js
CHANGED
|
@@ -122,10 +122,37 @@ function getRouteMessageText(event) {
|
|
|
122
122
|
}
|
|
123
123
|
return event.MessageText;
|
|
124
124
|
}
|
|
125
|
+
function shouldParseInteractionAsText(messageText) {
|
|
126
|
+
const text = String(messageText ?? '').trim();
|
|
127
|
+
if (!text) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return /\s/.test(text);
|
|
131
|
+
}
|
|
125
132
|
function getLookupCandidates(event, keyPolicy) {
|
|
126
133
|
const eventName = String(event.name ?? '');
|
|
127
134
|
const routeMessageText = getRouteMessageText(event);
|
|
128
135
|
if (eventName.includes('interaction')) {
|
|
136
|
+
if (shouldParseInteractionAsText(routeMessageText)) {
|
|
137
|
+
const parsed = parseMessageText(routeMessageText);
|
|
138
|
+
if (!parsed) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
const oneKey = parsed.tokens[0] ?? '';
|
|
142
|
+
const twoKey = parsed.tokens.length >= 2 ? `${parsed.tokens[0]} ${parsed.tokens[1]}` : '';
|
|
143
|
+
const maxWords = keyPolicy?.maxWords ?? 2;
|
|
144
|
+
const candidates = maxWords === 1
|
|
145
|
+
? [{ key: oneKey, keyLength: 1 }]
|
|
146
|
+
: [
|
|
147
|
+
...(twoKey ? [{ key: twoKey, keyLength: 2 }] : []),
|
|
148
|
+
{ key: oneKey, keyLength: 1 }
|
|
149
|
+
];
|
|
150
|
+
return {
|
|
151
|
+
normalizedCommand: parsed?.normalized,
|
|
152
|
+
rawArgs: parsed.tokens,
|
|
153
|
+
candidates
|
|
154
|
+
};
|
|
155
|
+
}
|
|
129
156
|
const interactionKey = normalizeInteractionKey(routeMessageText);
|
|
130
157
|
if (!interactionKey) {
|
|
131
158
|
return null;
|