mioku-plugin-deerpipe 2.0.0 → 2.0.2

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.
Files changed (3) hide show
  1. package/index.ts +13 -11
  2. package/package.json +2 -76
  3. package/utils.ts +5 -5
package/index.ts CHANGED
@@ -1,12 +1,10 @@
1
- import { definePlugin, type MiokuContext } from "mioku";
1
+ import { definePlugin, type CommandDefinition, type MessageEvent, type MiokuContext } from "mioku";
2
2
  import { getService, Services } from "mioku";
3
3
  import { initDeerDatabase, type DeerDatabase } from "./db";
4
4
  import { handleDeerCommand, parseDeerCommand } from "./commands";
5
5
 
6
6
  const deerpipePlugin = definePlugin({
7
7
  name: "deerpipe",
8
- version: "1.0.0",
9
- description: "🦌管签到插件,支持自🦌、帮🦌、补🦌、🦌历、🦌榜",
10
8
 
11
9
  async setup(ctx: MiokuContext) {
12
10
  ctx.logger.info("deerpipe 插件正在初始化...");
@@ -30,7 +28,6 @@ const deerpipePlugin = definePlugin({
30
28
  };
31
29
  }
32
30
 
33
- // 启动时清掉非本月的旧数据,与原版 cleanup 行为一致
34
31
  try {
35
32
  const now = new Date();
36
33
  await db.cleanupOtherMonths(now.getFullYear(), now.getMonth() + 1);
@@ -38,7 +35,6 @@ const deerpipePlugin = definePlugin({
38
35
  ctx.logger.warn(`deerpipe 启动期数据清理失败: ${error}`);
39
36
  }
40
37
 
41
- // 每周一 4:00 清理跨月数据
42
38
  ctx.cron("0 4 * * 1", async () => {
43
39
  try {
44
40
  const now = new Date();
@@ -49,13 +45,9 @@ const deerpipePlugin = definePlugin({
49
45
  }
50
46
  });
51
47
 
52
- ctx.handle("message", async (event) => {
53
- const text = ctx.text(event);
54
- if (!text) return;
55
-
48
+ const run = async (event: MessageEvent, text: string) => {
56
49
  const cmd = parseDeerCommand(text, Array.from(event.message ?? []));
57
50
  if (cmd.type === "none") return;
58
-
59
51
  try {
60
52
  await handleDeerCommand(cmd, {
61
53
  ctx,
@@ -71,7 +63,17 @@ const deerpipePlugin = definePlugin({
71
63
  // 忽略二次失败
72
64
  }
73
65
  }
74
- });
66
+ };
67
+
68
+ const cmd = (command: CommandDefinition) =>
69
+ ctx.command({ ...command, prefixes: false });
70
+
71
+ cmd({ name: "🦌", match: /^(?:🦌|鹿)(?:\s|$|@)/, description: "签到一次(可加 @某人 帮其签到)", usage: "🦌 / 🦌 @张三", handler: ({ event, body }) => run(event, body) });
72
+ cmd({ name: "补🦌", match: /^补(?:🦌|鹿)(?:\s|\d|$)/, description: "补签本月之前未签到的某天", usage: "补🦌 5", handler: ({ event, body }) => run(event, body) });
73
+ cmd({ name: "🦌历", match: /^(?:🦌|鹿)历(?:\s|$|@)/, description: "查看本月🦌签到日历(可加 @某人)", usage: "🦌历 / 🦌历 @张三", handler: ({ event, body }) => run(event, body) });
74
+ cmd({ name: "🦌榜", match: /^(?:🦌|鹿)榜(?:\s|$)/, description: "查看本月本群🦌签到排行榜(仅群组)", usage: "🦌榜", handler: ({ event, body }) => run(event, body) });
75
+ cmd({ name: "帮🦌", match: /^帮(?:🦌|鹿)(?:\s|$|@)/, description: "允许/禁止被别人帮🦌;@某人需管理员", usage: "帮🦌 off", handler: ({ event, body }) => run(event, body) });
76
+ cmd({ name: "禁🦌", match: /^禁(?:🦌|鹿)(?:\s|@|$)/, description: "禁止某人在一段时间内🦌,省略时长视为解禁(仅管理员)", usage: "禁🦌 @张三 1d", handler: ({ event, body }) => run(event, body) });
75
77
 
76
78
  ctx.logger.info("deerpipe 插件初始化完成");
77
79
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mioku-plugin-deerpipe",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "🦌管签到插件,支持自🦌、帮🦌、补🦌、🦌历、🦌榜",
5
5
  "main": "index.ts",
6
6
  "type": "module",
@@ -15,81 +15,7 @@
15
15
  "services": [
16
16
  "screenshot",
17
17
  "help"
18
- ],
19
- "accessHooks": [
20
- {
21
- "id": "🦌",
22
- "match": "/^(?:🦌|鹿)(?:\\s|$|@)/",
23
- "description": "自🦌或帮🦌"
24
- },
25
- {
26
- "id": "补🦌",
27
- "match": "/^补(?:🦌|鹿)(?:\\s|\\d|$)/",
28
- "description": "补签本月之前未签到的某天"
29
- },
30
- {
31
- "id": "🦌历",
32
- "match": "/^(?:🦌|鹿)历(?:\\s|$|@)/",
33
- "description": "查看本月🦌签到日历"
34
- },
35
- {
36
- "id": "🦌榜",
37
- "match": "/^(?:🦌|鹿)榜(?:\\s|$)/",
38
- "description": "查看本月🦌签到排行榜"
39
- },
40
- {
41
- "id": "帮🦌",
42
- "match": "/^帮(?:🦌|鹿)(?:\\s|$|@)/",
43
- "description": "允许/禁止被别人帮🦌"
44
- },
45
- {
46
- "id": "禁🦌",
47
- "match": "/^禁(?:🦌|鹿)(?:\\s|@|$)/",
48
- "description": "禁止某人在一段时间内🦌"
49
- }
50
- ],
51
- "help": {
52
- "title": "🦌管签到",
53
- "description": "每月🦌管签到,含日历与排行榜",
54
- "commands": [
55
- {
56
- "cmd": "🦌",
57
- "desc": "签到一次(可加 @某人 帮其签到)",
58
- "usage": "🦌 / 🦌 @张三",
59
- "role": "member"
60
- },
61
- {
62
- "cmd": "补🦌 <日>",
63
- "desc": "补签本月之前未签到的某天",
64
- "usage": "补🦌 5",
65
- "role": "member"
66
- },
67
- {
68
- "cmd": "🦌历",
69
- "desc": "查看本月🦌签到日历(可加 @某人)",
70
- "usage": "🦌历 / 🦌历 @张三",
71
- "role": "member"
72
- },
73
- {
74
- "cmd": "🦌榜",
75
- "desc": "查看本月本群🦌签到排行榜(仅群组)",
76
- "usage": "🦌榜",
77
- "role": "member"
78
- },
79
- {
80
- "cmd": "帮🦌 <on|off> [@某人]",
81
- "desc": "允许/禁止被别人帮🦌;@某人需管理员",
82
- "usage": "帮🦌 off",
83
- "role": "member"
84
- },
85
- {
86
- "cmd": "禁🦌 @某人 [时长]",
87
- "desc": "禁止某人在一段时间内🦌,省略时长视为解禁(仅管理员)",
88
- "usage": "禁🦌 @张三 1d",
89
- "role": "admin"
90
- }
91
- ]
92
- }
18
+ ]
93
19
  },
94
20
  "peerDependencies": {
95
21
  "mioku": "^1.0.0"
package/utils.ts CHANGED
@@ -103,11 +103,11 @@ export function formatDateTime(timestamp: number): string {
103
103
 
104
104
  export function escapeHtml(value: string): string {
105
105
  return String(value)
106
- .replace(/&/g, "&amp);")
107
- .replace(/</g, "&lt);")
108
- .replace(/>/g, "&gt);")
109
- .replace(/"/g, "&quot);")
110
- .replace(/'/g, "&#39);");
106
+ .replace(/&/g, "&amp;")
107
+ .replace(/</g, "&lt;")
108
+ .replace(/>/g, "&gt;")
109
+ .replace(/"/g, "&quot;")
110
+ .replace(/'/g, "&#39;");
111
111
  }
112
112
 
113
113
  // 19:00–07:00 视为夜间模式,与 help 插件保持一致