koishi-plugin-phimg2 1.0.7 → 1.0.8
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 +7 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -147,6 +147,7 @@ function apply(ctx, config) {
|
|
|
147
147
|
|
|
148
148
|
用法说明:
|
|
149
149
|
引用图片: 进行以图搜图 (默认距离 0.25)
|
|
150
|
+
直接发图: 发送指令时附带图片进行以图搜图
|
|
150
151
|
输入文本: 进行标签搜索
|
|
151
152
|
|
|
152
153
|
可选项:
|
|
@@ -169,7 +170,8 @@ function apply(ctx, config) {
|
|
|
169
170
|
ctx.command("搜图 [...params]", "从图站搜索图片").option("tags", "--tags").option("status", "--status").option("pp", "--pp <per_page:number>", { fallback: 50 }).option("p", "--p <page:number>", { fallback: 1 }).option("sf", "--sf <sf:string>", { fallback: "score" }).option("sd", "--sd <sd:string>", { fallback: "desc" }).option("i", "--i <index:number>", { fallback: -1 }).action(async ({ session, options }, ...paramsArray) => {
|
|
170
171
|
if (!session?.guildId) return "搜图仅限群聊使用。";
|
|
171
172
|
const rawParams = paramsArray.join(" ");
|
|
172
|
-
|
|
173
|
+
const hasImageInContent = !!(import_koishi.h.select(session.content, "image")[0] || import_koishi.h.select(session.content, "img")[0]);
|
|
174
|
+
if (!rawParams && !session.quote && !hasImageInContent && !options.tags && !options.status) return searchHelp;
|
|
173
175
|
const groupId = session.guildId;
|
|
174
176
|
const groupConfig = await getGroupConfig(groupId);
|
|
175
177
|
if (options.status) {
|
|
@@ -191,6 +193,10 @@ function apply(ctx, config) {
|
|
|
191
193
|
const img = import_koishi.h.select(session.quote.content, "image")[0] || import_koishi.h.select(session.quote.content, "img")[0];
|
|
192
194
|
if (img) imageUrl = img.attrs.url || img.attrs.src;
|
|
193
195
|
}
|
|
196
|
+
if (!imageUrl) {
|
|
197
|
+
const img = import_koishi.h.select(session.content, "image")[0] || import_koishi.h.select(session.content, "img")[0];
|
|
198
|
+
if (img) imageUrl = img.attrs.url || img.attrs.src;
|
|
199
|
+
}
|
|
194
200
|
try {
|
|
195
201
|
if (imageUrl) {
|
|
196
202
|
let distance = 0.25;
|