koishi-plugin-starfx-bot 0.1.0 → 0.1.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.
- package/lib/index.d.ts +2 -2
- package/lib/index.js +14 -0
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ export declare const Config: Schema<Config>;
|
|
|
9
9
|
export declare const usage = "StarFreedomX\u7684\u81EA\u7528\u63D2\u4EF6 \u653E\u4E86\u4E00\u4E9B\u5C0F\u529F\u80FD";
|
|
10
10
|
export declare function apply(ctx: Context, cfg: Config): void;
|
|
11
11
|
export declare function getImageSrc(session: Session, param: string): Promise<string>;
|
|
12
|
-
export declare function drawLock(baseImage: string): Promise<h>;
|
|
13
|
-
export declare function drawSold(baseImage: string): Promise<h>;
|
|
12
|
+
export declare function drawLock(baseImage: string): Promise<"输入无效。" | h>;
|
|
13
|
+
export declare function drawSold(baseImage: string): Promise<"输入无效。" | h>;
|
|
14
14
|
export declare function getMemberInfo(member: Universal.GuildMember, id: string): string[];
|
package/lib/index.js
CHANGED
|
@@ -79,6 +79,7 @@ async function getImageSrc(session, param) {
|
|
|
79
79
|
const { gid } = session;
|
|
80
80
|
let userid = "";
|
|
81
81
|
let imageSrc = "";
|
|
82
|
+
console.log(param);
|
|
82
83
|
if (!param) {
|
|
83
84
|
console.log("no");
|
|
84
85
|
userid = session.userId;
|
|
@@ -90,6 +91,13 @@ async function getImageSrc(session, param) {
|
|
|
90
91
|
return param.match(/<img[^>]*\s+src="([^"]+)"/i)?.[1] ?? null;
|
|
91
92
|
} else {
|
|
92
93
|
console.log("other");
|
|
94
|
+
const index = param.indexOf("<");
|
|
95
|
+
param = param.slice(index);
|
|
96
|
+
if (param?.length) {
|
|
97
|
+
return getImageSrc(session, param);
|
|
98
|
+
} else {
|
|
99
|
+
return "";
|
|
100
|
+
}
|
|
93
101
|
}
|
|
94
102
|
if (userid) {
|
|
95
103
|
const memberList = await getMemberList(session, gid);
|
|
@@ -114,6 +122,9 @@ async function getMemberList(session, gid) {
|
|
|
114
122
|
}
|
|
115
123
|
__name(getMemberList, "getMemberList");
|
|
116
124
|
async function drawLock(baseImage) {
|
|
125
|
+
if (!baseImage) {
|
|
126
|
+
return "输入无效。";
|
|
127
|
+
}
|
|
117
128
|
const lockUrl = `${baseDir}/data/starfx-bot/assets/lock.png`;
|
|
118
129
|
const image = await import_jimp.Jimp.read(baseImage);
|
|
119
130
|
const size1 = image.width > image.height ? image.height : image.width;
|
|
@@ -125,6 +136,9 @@ async function drawLock(baseImage) {
|
|
|
125
136
|
}
|
|
126
137
|
__name(drawLock, "drawLock");
|
|
127
138
|
async function drawSold(baseImage) {
|
|
139
|
+
if (!baseImage) {
|
|
140
|
+
return "输入无效。";
|
|
141
|
+
}
|
|
128
142
|
const soldUrl = `${baseDir}/data/starfx-bot/assets/sold.png`;
|
|
129
143
|
const image = await import_jimp.Jimp.read(baseImage);
|
|
130
144
|
const size1 = image.width > image.height ? image.height : image.width;
|