Skip to content

Commit

Permalink
fix: fix search error, close #16
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Feb 19, 2023
1 parent 4f951b3 commit 7c2f6c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-plugin-image-search",
"description": "Image searching plugin for Koishi",
"version": "4.2.0",
"version": "4.2.2",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ export function apply(ctx: Context, config: Config = {}) {
const id = session.channelId
if (pendings.has(id)) return '存在正在进行的查询,请稍后再试。'

const [code] = segment.select(image, 'image')
if (code && code.data.url) {
const [code] = segment.select(image || [], 'image')
if (code && code.attrs.url) {
pendings.add(id)
return searchUrl(session, code.data.url, callback)
}

const dispose = session.middleware(({ content }, next) => {
dispose()
const code = segment.from(content, { type: 'image' })
if (!code || !code.data.url) return next()
const [code] = segment.select(content || [], 'image')
if (!code || !code.attrs.url) return next()
return searchUrl(session, code.data.url, callback)
})

Expand Down

0 comments on commit 7c2f6c7

Please sign in to comment.