alemonjs 2.1.69 → 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 CHANGED
@@ -67,6 +67,13 @@ program
67
67
  versionUpdate();
68
68
  });
69
69
 
70
+ program
71
+ .command('upgrade')
72
+ .description('检查并更新 alemonjs 和 @alemonjs/* 包到最新版本')
73
+ .action(() => {
74
+ versionUpdate();
75
+ });
76
+
70
77
  program
71
78
  .command('info')
72
79
  .description('输出项目诊断信息')
@@ -93,7 +93,8 @@ const onProcessor = (name, event, data) => {
93
93
  }
94
94
  }
95
95
  const mappingText = value?.mapping_text ?? [];
96
- if (event['MessageText']) {
96
+ if (event['MessageText'] && typeof event['MessageText'] === 'string') {
97
+ event['MessageText'] = event['MessageText'].trim();
97
98
  for (const mapping of mappingText) {
98
99
  const { regular, target } = mapping ?? {};
99
100
  if (!regular) {
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alemonjs",
3
- "version": "2.1.69",
3
+ "version": "2.1.71",
4
4
  "description": "bot script",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",