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.
Files changed (2) hide show
  1. package/lib/index.js +7 -1
  2. 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
- if (!rawParams && !session.quote && !options.tags && !options.status) return searchHelp;
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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-phimg2",
3
3
  "description": "Koishi 插件,让机器人通过Philomena API在使用Philomena搭建的图站上使用标签(tags)搜图或图搜图",
4
- "version": "1.0.7",
4
+ "version": "1.0.8",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [