Skip to content

Commit

Permalink
feat: support quote (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: Shigma <[email protected]>
  • Loading branch information
std-microblock and shigma authored Feb 9, 2023
1 parent e87e9dc commit 4f951b3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ export function apply(ctx: Context, config: Config = {}) {
return '令牌失效导致访问失败,请联系机器人作者。'
})

ctx.command('search [image]', '搜图片')
ctx.command('search [image:text]', '搜图片')
.shortcut('搜图', { fuzzy: true })
.action(search(mixedSearch))
ctx.command('search/saucenao [image]', '使用 saucenao 搜图')
ctx.command('search/saucenao [image:text]', '使用 saucenao 搜图')
.action(search(saucenao))
ctx.command('search/ascii2d [image]', '使用 ascii2d 搜图')
ctx.command('search/ascii2d [image:text]', '使用 ascii2d 搜图')
.action(search(ascii2d))
ctx.command('search/iqdb [image]', '使用 iqdb 搜图')
ctx.command('search/iqdb [image:text]', '使用 iqdb 搜图')
.action(search(iqdb))

const pendings = new Set<string>()
Expand All @@ -61,11 +61,11 @@ export function apply(ctx: Context, config: Config = {}) {
}

function search(callback: SearchCallback): Command.Action {
return async ({ session }) => {
return async ({ session }, image) => {
const id = session.channelId
if (pendings.has(id)) return '存在正在进行的查询,请稍后再试。'

const code = segment.from(session.content, { type: 'image' })
const [code] = segment.select(image, 'image')
if (code && code.data.url) {
pendings.add(id)
return searchUrl(session, code.data.url, callback)
Expand Down

0 comments on commit 4f951b3

Please sign in to comment.