koishi-plugin-phimg2 1.0.2 → 1.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.
Files changed (2) hide show
  1. package/lib/index.js +6 -7
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -131,7 +131,7 @@ function apply(ctx, config) {
131
131
  }
132
132
  response = await import_axios.default.post(url, formData, axiosConfig);
133
133
  }
134
- if (response.data.total === 0) {
134
+ if (!response.data.images || response.data.images.length === 0) {
135
135
  throw new Error("未找到匹配的图片");
136
136
  }
137
137
  return response.data;
@@ -173,7 +173,7 @@ function apply(ctx, config) {
173
173
  提示:
174
174
  图搜图使用方式为引用图片,默认匹配距离为0.25
175
175
  所有参数及变量全部遵循呆站(Philomena系图站)搜索API规范`;
176
- const configHelp = `用法: .搜图-c [选项]
176
+ const configHelp = `用法: 搜图-c [选项]
177
177
 
178
178
  可选项:
179
179
  --add [tags] 添加标签,多个标签用逗号分隔
@@ -183,10 +183,10 @@ function apply(ctx, config) {
183
183
  --onglobal 启用全局标签
184
184
  --offglobal 关闭全局标签
185
185
  `;
186
- ctx.command("搜图 [params:text]", "从图站搜索图片").option("tags", "--tags 获取当前群聊内置标签列表").option("status", "--status 获取当前群聊的搜图功能状态").option("pp", "--pp <per_page:number> 每页结果数量,默认为50", { fallback: 50 }).option("p", "--p <page:number> 页码,默认为1", { fallback: 1 }).option("sf", "--sf <sf:string> 排序字段,默认为score", { fallback: "score" }).option("sd", "--sd <sd:string> 排序方向,默认为desc", { fallback: "desc" }).option("i", "--i <index:number> 选择结果索引,默认为-1(即随机)", { fallback: -1 }).action(async ({ session, options }, params) => {
186
+ ctx.command("搜图 [...params]", "从图站搜索图片").option("tags", "--tags 获取当前群聊内置标签列表").option("status", "--status 获取当前群聊的搜图功能状态").option("pp", "--pp <per_page:number> 每页结果数量,默认为50", { fallback: 50 }).option("p", "--p <page:number> 页码,默认为1", { fallback: 1 }).option("sf", "--sf <sf:string> 排序字段,默认为score", { fallback: "score" }).option("sd", "--sd <sd:string> 排序方向,默认为desc", { fallback: "desc" }).option("i", "--i <index:number> 选择结果索引,默认为-1(即随机)", { fallback: -1 }).action(async ({ session, options }, ...paramsArray) => {
187
187
  if (!session?.guildId) return "搜图仅限群聊使用。";
188
- const tokens = session.argv?.tokens || [];
189
- if (!params && tokens.length <= 1 && !session.quote) {
188
+ let params = paramsArray.join(" ");
189
+ if (!params && !session.quote && !options.tags && !options.status) {
190
190
  return searchHelp;
191
191
  }
192
192
  const groupId = session.guildId;
@@ -286,8 +286,7 @@ tags: ${queryParams.q}`;
286
286
  const confirmOffGlobal = /* @__PURE__ */ new Set();
287
287
  ctx.command("搜图-c", "配置搜图功能", { authority: 3 }).option("on", "--on 开启当前群聊的搜图功能").option("off", "--off 关闭当前群聊的搜图功能").option("onglobal", "--onglobal 启用全局标签").option("offglobal", "--offglobal 关闭全局标签").option("add", "--add <tags:string> 添加标签,多个标签用逗号分隔").option("rm", "--rm <tags:string> 删除标签,多个标签用逗号分隔").action(async ({ session, options }) => {
288
288
  if (!session?.guildId) return "搜图配置仅限群聊使用。";
289
- const tokens = session.argv?.tokens || [];
290
- if (tokens.length <= 1) {
289
+ if (Object.keys(options).length === 0) {
291
290
  return configHelp;
292
291
  }
293
292
  const groupId = session.guildId;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-phimg2",
3
3
  "description": "该插件可以让机器人通过Philomena API在使用Philomena搭建的图站上使用标签(tags)搜图",
4
- "version": "1.0.2",
4
+ "version": "1.0.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [