mioku-plugin-deerpipe 1.1.2 → 2.0.1
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/commands.ts +6 -6
- package/index.ts +3 -3
- package/package.json +3 -5
- package/utils.ts +8 -12
package/commands.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ScreenshotService } from "mioku";
|
|
2
|
-
import type {
|
|
2
|
+
import type { MiokuContext } from "mioku";
|
|
3
3
|
import type { DeerDatabase } from "./db";
|
|
4
4
|
import { generateCalendarImage, generateRankImage } from "./image";
|
|
5
5
|
import {
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
const MAX_NO_DEER_DURATION_S = 30 * 86400;
|
|
15
15
|
|
|
16
16
|
interface CommandContext {
|
|
17
|
-
ctx:
|
|
17
|
+
ctx: MiokuContext;
|
|
18
18
|
db: DeerDatabase;
|
|
19
19
|
screenshot: ScreenshotService;
|
|
20
20
|
event: any;
|
|
@@ -176,7 +176,7 @@ async function handleDeer(
|
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
const prefix = targetUserId
|
|
179
|
-
? [{ type: "text", data: { text: "成功帮 " } }, ctx.segment.at(targetUserId), { type: "text", data: { text: " 🦌了\n" } }]
|
|
179
|
+
? [{ type: "text", data: { text: "成功帮 " } }, ctx.segment.at(String(targetUserId)), { type: "text", data: { text: " 🦌了\n" } }]
|
|
180
180
|
: [{ type: "text", data: { text: "成功🦌了\n" } }];
|
|
181
181
|
|
|
182
182
|
await replyImage(event, ctx.segment, imagePath, prefix);
|
|
@@ -312,7 +312,7 @@ async function handleSetCanBeHelped(
|
|
|
312
312
|
await event.reply(
|
|
313
313
|
[
|
|
314
314
|
{ type: "text", data: { text: `已${allowed ? "允许" : "禁止"}帮 ` } },
|
|
315
|
-
ctx.segment.at(targetUserId),
|
|
315
|
+
ctx.segment.at(String(targetUserId)),
|
|
316
316
|
{ type: "text", data: { text: " 🦌" } },
|
|
317
317
|
],
|
|
318
318
|
true,
|
|
@@ -361,7 +361,7 @@ async function handleSetNoDeer(
|
|
|
361
361
|
await event.reply(
|
|
362
362
|
[
|
|
363
363
|
{ type: "text", data: { text: "已解禁 " } },
|
|
364
|
-
ctx.segment.at(targetUserId),
|
|
364
|
+
ctx.segment.at(String(targetUserId)),
|
|
365
365
|
{ type: "text", data: { text: " 的🦌权" } },
|
|
366
366
|
],
|
|
367
367
|
true,
|
|
@@ -370,7 +370,7 @@ async function handleSetNoDeer(
|
|
|
370
370
|
await event.reply(
|
|
371
371
|
[
|
|
372
372
|
{ type: "text", data: { text: "已禁止 " } },
|
|
373
|
-
ctx.segment.at(targetUserId),
|
|
373
|
+
ctx.segment.at(String(targetUserId)),
|
|
374
374
|
{
|
|
375
375
|
type: "text",
|
|
376
376
|
data: {
|
package/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { definePlugin, type
|
|
1
|
+
import { definePlugin, 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";
|
|
@@ -8,7 +8,7 @@ const deerpipePlugin = definePlugin({
|
|
|
8
8
|
version: "1.0.0",
|
|
9
9
|
description: "🦌管签到插件,支持自🦌、帮🦌、补🦌、🦌历、🦌榜",
|
|
10
10
|
|
|
11
|
-
async setup(ctx:
|
|
11
|
+
async setup(ctx: MiokuContext) {
|
|
12
12
|
ctx.logger.info("deerpipe 插件正在初始化...");
|
|
13
13
|
|
|
14
14
|
const screenshotService = getService(ctx, Services.Screenshot);
|
|
@@ -53,7 +53,7 @@ const deerpipePlugin = definePlugin({
|
|
|
53
53
|
const text = ctx.text(event);
|
|
54
54
|
if (!text) return;
|
|
55
55
|
|
|
56
|
-
const cmd = parseDeerCommand(text, event.message ?? []);
|
|
56
|
+
const cmd = parseDeerCommand(text, Array.from(event.message ?? []));
|
|
57
57
|
if (cmd.type === "none") return;
|
|
58
58
|
|
|
59
59
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mioku-plugin-deerpipe",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "🦌管签到插件,支持自🦌、帮🦌、补🦌、🦌历、🦌榜",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -92,11 +92,9 @@
|
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"mioku": "^0.
|
|
96
|
-
"mioki": "^0.16.0"
|
|
95
|
+
"mioku": "^1.0.0"
|
|
97
96
|
},
|
|
98
97
|
"devDependencies": {
|
|
99
|
-
"mioku": "workspace:*"
|
|
100
|
-
"mioki": "^0.16.0"
|
|
98
|
+
"mioku": "workspace:*"
|
|
101
99
|
}
|
|
102
100
|
}
|
package/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { createGroupRef, type MiokuContext } from "mioku";
|
|
2
2
|
import * as fs from "fs/promises";
|
|
3
3
|
import type { DeerScene } from "./types";
|
|
4
4
|
|
|
@@ -34,16 +34,14 @@ export function resolveScene(event: any): DeerScene {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export async function resolveUserName(
|
|
37
|
-
ctx:
|
|
37
|
+
ctx: MiokuContext,
|
|
38
38
|
event: any,
|
|
39
39
|
userId: number,
|
|
40
40
|
): Promise<string> {
|
|
41
|
-
const
|
|
42
|
-
if (event?.message_type === "group" && event?.group_id != null) {
|
|
41
|
+
const bot = event?.bot;
|
|
42
|
+
if (event?.message_type === "group" && event?.group_id != null && bot) {
|
|
43
43
|
try {
|
|
44
|
-
const member = await
|
|
45
|
-
.pickBot(selfId)
|
|
46
|
-
.getGroupMemberInfo(Number(event.group_id), userId);
|
|
44
|
+
const member = await createGroupRef(bot, String(event.group_id)).getMemberInfo(userId);
|
|
47
45
|
const name =
|
|
48
46
|
String(member?.card || "").trim() ||
|
|
49
47
|
String(member?.nickname || "").trim();
|
|
@@ -59,11 +57,9 @@ export async function resolveUserName(
|
|
|
59
57
|
if (name) return name;
|
|
60
58
|
}
|
|
61
59
|
try {
|
|
62
|
-
const stranger =
|
|
63
|
-
.
|
|
64
|
-
|
|
65
|
-
| { nickname?: string }
|
|
66
|
-
| undefined;
|
|
60
|
+
const stranger = bot
|
|
61
|
+
? await bot.getFriendInfo(userId)
|
|
62
|
+
: undefined;
|
|
67
63
|
const name = String(stranger?.nickname || "").trim();
|
|
68
64
|
if (name) return name;
|
|
69
65
|
} catch {
|