koishi-plugin-vrchat 0.0.2 → 0.0.3
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.js +28 -9
- package/package.json +4 -4
- package/readme.md +1 -1
package/lib/index.js
CHANGED
|
@@ -94,6 +94,10 @@ function apply(ctx, config) {
|
|
|
94
94
|
} catch {
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
if (avatarlist.length === 0) {
|
|
98
|
+
await session.bot.deleteMessage(session.channelId, msgId);
|
|
99
|
+
return "无检索结果";
|
|
100
|
+
}
|
|
97
101
|
await session.send(`<message forward>${avatarlist.map(
|
|
98
102
|
(e) => `<message>模型名:
|
|
99
103
|
${e.name}
|
|
@@ -129,6 +133,10 @@ ${new Date(e.updated_at).toLocaleString()}<img src="${e.imageUrl}"></img></messa
|
|
|
129
133
|
},
|
|
130
134
|
responseType: "json"
|
|
131
135
|
});
|
|
136
|
+
if (resp.length === 0) {
|
|
137
|
+
await session.bot.deleteMessage(session.channelId, msgId);
|
|
138
|
+
return "无检索结果";
|
|
139
|
+
}
|
|
132
140
|
const messages = [];
|
|
133
141
|
for (const item of resp) {
|
|
134
142
|
let tags = [];
|
|
@@ -159,7 +167,7 @@ ${item.favorites}
|
|
|
159
167
|
${new Date(item.created_at).toLocaleString()}
|
|
160
168
|
|
|
161
169
|
最后更新时间:
|
|
162
|
-
${new Date(item.updated_at).toLocaleString()}<img src="${item.
|
|
170
|
+
${new Date(item.updated_at).toLocaleString()}<img src="${item.thumbnailImageUrl}"></img></message>`);
|
|
163
171
|
}
|
|
164
172
|
await session.send(`<message forward>${messages.join("")}</message>`);
|
|
165
173
|
await session.bot.deleteMessage(session.channelId, msgId);
|
|
@@ -175,6 +183,10 @@ ${new Date(item.updated_at).toLocaleString()}<img src="${item.imageUrl}"></img><
|
|
|
175
183
|
},
|
|
176
184
|
responseType: "json"
|
|
177
185
|
});
|
|
186
|
+
if (resp.length === 0) {
|
|
187
|
+
await session.bot.deleteMessage(session.channelId, msgId);
|
|
188
|
+
return "无检索结果";
|
|
189
|
+
}
|
|
178
190
|
const users = [];
|
|
179
191
|
for (const item of resp) {
|
|
180
192
|
const resp2 = await ctx.http.get(`https://api.vrchat.cloud/api/1/users/${item.id}`, {
|
|
@@ -189,14 +201,19 @@ ${new Date(item.updated_at).toLocaleString()}<img src="${item.imageUrl}"></img><
|
|
|
189
201
|
const messages = [];
|
|
190
202
|
for (const item of users) {
|
|
191
203
|
let avatar = "";
|
|
204
|
+
let currentAvatarImageUrl = item.currentAvatarImageUrl;
|
|
192
205
|
if (item.currentAvatarImageUrl.startsWith("https://api.vrchat.cloud")) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
206
|
+
try {
|
|
207
|
+
const resp2 = await ctx.http.get(item.currentAvatarImageUrl.slice(0, -7), {
|
|
208
|
+
headers: {
|
|
209
|
+
"User-Agent": "VRCX 2026.02.11"
|
|
210
|
+
},
|
|
211
|
+
responseType: "json"
|
|
212
|
+
});
|
|
213
|
+
avatar = resp2.name.split(" - ")[1];
|
|
214
|
+
} catch {
|
|
215
|
+
currentAvatarImageUrl = void 0;
|
|
216
|
+
}
|
|
200
217
|
}
|
|
201
218
|
let location = item.location;
|
|
202
219
|
if (item.location.startsWith("wrld_")) {
|
|
@@ -209,6 +226,8 @@ ${new Date(item.updated_at).toLocaleString()}<img src="${item.imageUrl}"></img><
|
|
|
209
226
|
});
|
|
210
227
|
location = resp2.name;
|
|
211
228
|
}
|
|
229
|
+
let imgUrl = item.userIcon || currentAvatarImageUrl;
|
|
230
|
+
const img = imgUrl ? `<img src="${imgUrl}"></img>` : "";
|
|
212
231
|
messages.push(`<message>玩家名:
|
|
213
232
|
${item.displayName}
|
|
214
233
|
|
|
@@ -234,7 +253,7 @@ ${item.bio}
|
|
|
234
253
|
${item.bioLinks.join("\n")}
|
|
235
254
|
|
|
236
255
|
账号创建日期:
|
|
237
|
-
${item.date_joined}
|
|
256
|
+
${item.date_joined}${img}</message>`);
|
|
238
257
|
}
|
|
239
258
|
await session.send(`<message forward>${messages.join("")}</message>`);
|
|
240
259
|
await session.bot.deleteMessage(session.channelId, msgId);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-vrchat",
|
|
3
|
-
"description": "Search VRChat
|
|
4
|
-
"version": "0.0.
|
|
3
|
+
"description": "Search VRChat avatars, worlds, and users",
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"koishi": {
|
|
27
27
|
"description": {
|
|
28
|
-
"zh": "检索 VRChat
|
|
29
|
-
"en": "Search VRChat
|
|
28
|
+
"zh": "检索 VRChat 模型、世界和玩家",
|
|
29
|
+
"en": "Search VRChat avatars, worlds, and users"
|
|
30
30
|
},
|
|
31
31
|
"browser": true
|
|
32
32
|
}
|
package/readme.md
CHANGED