koishi-plugin-ciyi 1.2.9 → 1.2.10
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 +26 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.js +10 -14
- package/package.json +1 -1
- package/readme.md +0 -41
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# koishi-plugin-ciyi
|
|
2
|
+
|
|
3
|
+
词意猜词:每天一个两字词,在群里开猜
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
yarn add koishi-plugin-ciyi
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
在 Koishi 配置中启用,并提供 database 服务;需要图片输出时再提供 canvas 服务。
|
|
12
|
+
|
|
13
|
+
## 指令
|
|
14
|
+
|
|
15
|
+
| 指令 | 说明 |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `ciyi` | 玩法 |
|
|
18
|
+
| `ciyi.猜 <词>` | 开始今日游戏并提交猜测 |
|
|
19
|
+
| `ciyi.裸词 [开/关]` | 切换本群无前缀续猜 |
|
|
20
|
+
| `ciyi.排行榜` | 猜中次数排行 |
|
|
21
|
+
|
|
22
|
+
首次用 `ciyi.猜 <词>` 开题,之后可直接发送两字词继续猜。裸词设置只对当前群生效,重启后恢复默认。
|
|
23
|
+
|
|
24
|
+
## 许可证
|
|
25
|
+
|
|
26
|
+
可按 [Apache-2.0](LICENSE-APACHE) 或 [MIT](LICENSE-MIT) 使用。
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context, Schema, Session } from "koishi";
|
|
2
2
|
import { History } from "./view";
|
|
3
3
|
export declare const name = "ciyi";
|
|
4
|
-
export declare const usage = "## \u4F7F\u7528\n\n\u8BBE\u7F6E\u6307\u4EE4\u522B\u540D\u540E\uFF0C\u53D1\u9001 `ciyi` \u67E5\u770B\u73A9\u6CD5\u3002\u6BCF\u65E5\u85CF\u4E00\u4E2A\u4E24\u5B57\u8BCD\uFF0C\
|
|
4
|
+
export declare const usage = "## \u4F7F\u7528\n\n\u8BBE\u7F6E\u6307\u4EE4\u522B\u540D\u540E\uFF0C\u53D1\u9001 `ciyi` \u67E5\u770B\u73A9\u6CD5\u3002\u6BCF\u65E5\u85CF\u4E00\u4E2A\u4E24\u5B57\u8BCD\uFF0C\u9996\u6B21\u7528 `ciyi.\u731C <\u8BCD>` \u5F00\u9898\uFF0C\u4E4B\u540E\u53EF\u4EE5\u76F4\u63A5\u53D1\u9001\u4E24\u5B57\u8BCD\u7EE7\u7EED\u731C\u3002\u88F8\u8BCD\u8BBE\u7F6E\u53EA\u5BF9\u5F53\u524D\u7FA4\u751F\u6548\uFF0C\u91CD\u542F\u540E\u6062\u590D\u9ED8\u8BA4\u3002\n\n## \u6307\u4EE4\n\n| \u6307\u4EE4 | \u8BF4\u660E |\n| --- | --- |\n| `ciyi` | \u73A9\u6CD5 |\n| `ciyi.\u731C <\u8BCD>` | \u5F00\u59CB\u4ECA\u65E5\u6E38\u620F\u5E76\u63D0\u4EA4\u731C\u6D4B |\n| `ciyi.\u88F8\u8BCD [\u5F00/\u5173]` | \u5207\u6362\u672C\u7FA4\u65E0\u524D\u7F00\u7EED\u731C |\n| `ciyi.\u6392\u884C\u699C` | \u731C\u4E2D\u6B21\u6570\u6392\u884C |";
|
|
5
5
|
export declare const inject: {
|
|
6
6
|
required: string[];
|
|
7
7
|
optional: string[];
|
|
@@ -40,8 +40,9 @@ export interface CiyiRank {
|
|
|
40
40
|
}
|
|
41
41
|
export type { History };
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
43
|
+
* 裸词中间件只看消息里的文本,引用、@、图片等非文本元素一律过滤掉:
|
|
44
|
+
* 回复时带上引用或 @ 是常见操作,不应因此把一条两字词挡在门外。
|
|
45
|
+
* 剩下的正文仍必须是一条完整、无多余空白的两字中文词。
|
|
45
46
|
*/
|
|
46
47
|
export declare function getMiddlewareGuess(session: Session): string | null;
|
|
47
48
|
/** 裸词只能加入已开始且未封题的游戏,不能开题,也不重复提交旧猜测。 */
|
package/lib/index.js
CHANGED
|
@@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
23
|
Config: () => Config,
|
|
24
24
|
apply: () => apply,
|
|
25
25
|
canHandleMiddlewareGuess: () => canHandleMiddlewareGuess,
|
|
@@ -29,7 +29,7 @@ __export(index_exports, {
|
|
|
29
29
|
resolveMiddlewareSwitch: () => resolveMiddlewareSwitch,
|
|
30
30
|
usage: () => usage
|
|
31
31
|
});
|
|
32
|
-
module.exports = __toCommonJS(
|
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
|
33
33
|
var import_koishi = require("koishi");
|
|
34
34
|
|
|
35
35
|
// src/data/allWords.json
|
|
@@ -883,16 +883,16 @@ __name(renderRankCard, "renderRankCard");
|
|
|
883
883
|
var name = "ciyi";
|
|
884
884
|
var usage = `## 使用
|
|
885
885
|
|
|
886
|
-
设置指令别名后,发送 \`ciyi\`
|
|
886
|
+
设置指令别名后,发送 \`ciyi\` 查看玩法。每日藏一个两字词,首次用 \`ciyi.猜 <词>\` 开题,之后可以直接发送两字词继续猜。裸词设置只对当前群生效,重启后恢复默认。
|
|
887
887
|
|
|
888
888
|
## 指令
|
|
889
889
|
|
|
890
890
|
| 指令 | 说明 |
|
|
891
891
|
| --- | --- |
|
|
892
|
-
| \`ciyi\` |
|
|
892
|
+
| \`ciyi\` | 玩法 |
|
|
893
893
|
| \`ciyi.猜 <词>\` | 开始今日游戏并提交猜测 |
|
|
894
|
-
| \`ciyi.裸词 [开/关]\` |
|
|
895
|
-
| \`ciyi.排行榜\` |
|
|
894
|
+
| \`ciyi.裸词 [开/关]\` | 切换本群无前缀续猜 |
|
|
895
|
+
| \`ciyi.排行榜\` | 猜中次数排行 |`;
|
|
896
896
|
var inject = { required: ["database"], optional: ["canvas"] };
|
|
897
897
|
var Config = import_koishi.Schema.object({
|
|
898
898
|
atReply: import_koishi.Schema.boolean().default(false).description("响应时 @"),
|
|
@@ -906,15 +906,11 @@ var Config = import_koishi.Schema.object({
|
|
|
906
906
|
});
|
|
907
907
|
function getMiddlewareGuess(session) {
|
|
908
908
|
const message = session.event.message;
|
|
909
|
-
if (!message ||
|
|
909
|
+
if (!message || session.event.user?.isBot || message.user?.isBot) {
|
|
910
910
|
return null;
|
|
911
911
|
}
|
|
912
|
-
const
|
|
913
|
-
if (
|
|
914
|
-
return null;
|
|
915
|
-
}
|
|
916
|
-
const text = elements[0].attrs.content;
|
|
917
|
-
if (typeof text !== "string" || text !== text.trim() || Array.from(text).length !== 2 || !/^\p{Script=Han}{2}$/u.test(text) || !allWords_default.includes(text)) {
|
|
912
|
+
const text = (message.elements ?? []).filter((element) => element.type === "text").map((element) => element.attrs.content).filter((content) => typeof content === "string").join("");
|
|
913
|
+
if (text !== text.trim() || Array.from(text).length !== 2 || !/^\p{Script=Han}{2}$/u.test(text) || !allWords_default.includes(text)) {
|
|
918
914
|
return null;
|
|
919
915
|
}
|
|
920
916
|
return text;
|
package/package.json
CHANGED
package/readme.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
koishi-plugin-ciyi
|
|
2
|
-
==================
|
|
3
|
-
|
|
4
|
-
[<img alt="github" src="https://img.shields.io/badge/github-araea/koishi__plugin__ciyi-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/araea/koishi-plugin-ciyi)
|
|
5
|
-
[<img alt="npm" src="https://img.shields.io/npm/v/koishi-plugin-ciyi.svg?style=for-the-badge&color=fc8d62&logo=npm" height="20">](https://www.npmjs.com/package/koishi-plugin-ciyi)
|
|
6
|
-
|
|
7
|
-
Koishi 的词意猜词插件。
|
|
8
|
-
|
|
9
|
-
## 使用
|
|
10
|
-
|
|
11
|
-
设置指令别名后,发送 `ciyi` 查看玩法。每日藏一个两字词,使用 `ciyi.猜 <词>` 提交第一次猜测并开题;开题后可直接发送两字词继续猜测。`ciyi.裸词` 可在当前群临时切换这一行为,不改插件配置,重启后自动复原。
|
|
12
|
-
|
|
13
|
-
## 指令
|
|
14
|
-
|
|
15
|
-
| 指令 | 说明 |
|
|
16
|
-
| --- | --- |
|
|
17
|
-
| `ciyi` | 玩法说明 |
|
|
18
|
-
| `ciyi.猜 <词>` | 开始今日游戏并提交猜测 |
|
|
19
|
-
| `ciyi.裸词 [开/关]` | 临时切换本群裸词续猜 |
|
|
20
|
-
| `ciyi.排行榜` | 猜中次数榜 |
|
|
21
|
-
|
|
22
|
-
## QQ 群
|
|
23
|
-
|
|
24
|
-
956758505
|
|
25
|
-
|
|
26
|
-
<br>
|
|
27
|
-
|
|
28
|
-
#### License
|
|
29
|
-
|
|
30
|
-
<sup>
|
|
31
|
-
Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
|
|
32
|
-
2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
|
|
33
|
-
</sup>
|
|
34
|
-
|
|
35
|
-
<br>
|
|
36
|
-
|
|
37
|
-
<sub>
|
|
38
|
-
Unless you explicitly state otherwise, any contribution intentionally submitted
|
|
39
|
-
for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
|
|
40
|
-
be dual licensed as above, without any additional terms or conditions.
|
|
41
|
-
</sub>
|