halbot 1989.6.22 → 1989.6.24
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 +3 -3
- package/package.json +1 -1
- package/skills/ai.mjs +1 -1
- package/skills/cmd.mjs +10 -5
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ alt="Halbot live demo" width="240" height="180" border="10" /></a>
|
|
|
33
33
|
- Code block rendering, developers friendly.
|
|
34
34
|
- ESM from the ground up
|
|
35
35
|
|
|
36
|
-
##
|
|
36
|
+
## Basic usage
|
|
37
37
|
|
|
38
38
|
### Configuration
|
|
39
39
|
|
|
@@ -94,7 +94,7 @@ All supported configuration fields:
|
|
|
94
94
|
|
|
95
95
|
### Run it
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
In peace-of-mind:
|
|
98
98
|
|
|
99
99
|
```bash
|
|
100
100
|
$ npx halbot
|
|
@@ -110,7 +110,7 @@ Install:
|
|
|
110
110
|
$ npm i halbot
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
Code:
|
|
114
114
|
|
|
115
115
|
```js
|
|
116
116
|
import halbot from 'halbot';
|
package/package.json
CHANGED
package/skills/ai.mjs
CHANGED
|
@@ -46,7 +46,7 @@ const action = async (bot) => {
|
|
|
46
46
|
ok(onProgress);
|
|
47
47
|
}
|
|
48
48
|
);
|
|
49
|
-
msgs[name] = resp.responseRendered;
|
|
49
|
+
msgs[name] = ctx.session.raw ? resp.response : resp.responseRendered;
|
|
50
50
|
tts[name] = resp.spokenText;
|
|
51
51
|
} catch (err) {
|
|
52
52
|
msgs[name] = `[ERROR] ${err?.message || err}`;
|
package/skills/cmd.mjs
CHANGED
|
@@ -8,15 +8,20 @@ const action = async (bot) => {
|
|
|
8
8
|
ctx.session.ai || (ctx.session.ai = new Set());
|
|
9
9
|
const curAi = new Set();
|
|
10
10
|
ctx.cmd = ctx.text.split('\n')?.[0]?.replace(matchReg, '$1');
|
|
11
|
+
let catched;
|
|
12
|
+
switch (ctx.cmd) {
|
|
13
|
+
case 'raw': ctx.session.raw = true; catched = true; break;
|
|
14
|
+
case 'render': ctx.session.raw = false; catched = true; break;
|
|
15
|
+
}
|
|
11
16
|
for (let name in bot.ai) {
|
|
12
17
|
ctx.firstAi || (ctx.firstAi = name);
|
|
13
|
-
(utilitas.insensitiveCompare(ctx.cmd, name) || ctx.cmd === '*')
|
|
14
|
-
|
|
18
|
+
if (utilitas.insensitiveCompare(ctx.cmd, name) || ctx.cmd === '*') {
|
|
19
|
+
curAi.add(name);
|
|
20
|
+
catched = true;
|
|
21
|
+
}
|
|
15
22
|
}
|
|
16
23
|
curAi.size && (ctx.session.ai = curAi);
|
|
17
|
-
ctx.
|
|
18
|
-
ctx.text = ctx.text.replace(matchReg, '$2').trim() || bot.hello
|
|
19
|
-
);
|
|
24
|
+
catched && (ctx.text = ctx.text.replace(matchReg, '$2').trim() || bot.hello);
|
|
20
25
|
await next();
|
|
21
26
|
});
|
|
22
27
|
};
|