Skip to content

Commit

Permalink
fix(image-search): adjust output message
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Oct 1, 2020
1 parent b4d47e1 commit 40142f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/plugin-image-search/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Context, Session, Group, CommandAction } from 'koishi-core'
import { noop } from 'koishi-utils'
import ascii2d from './ascii2d'
import saucenao from './saucenao'

Expand Down Expand Up @@ -45,7 +46,8 @@ export function apply(ctx: Context, config: Config = {}) {
return async ({ session }) => {
const urls = extractImages(session.message)
if (urls.length) {
await Promise.all(urls.map(url => callback(url, session, config)))
await Promise.all(urls.map(url => callback(url, session, config).catch(noop)))
return
}

const dispose = session.$use(({ message }, next) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-image-search/src/saucenao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ export default async function saucenao(sourceUrl: string, session: Session, conf

if (long_remaining < 20) {
output.push(`注意:24h 内搜图次数仅剩 ${long_remaining} 次。`)
} else if (short_remaining < 5) {
output.push(`注意:30s 内搜图次数仅剩 ${short_remaining}次。`)
} else if (short_remaining < 3) {
output.push(`注意:30s 内搜图次数仅剩 ${short_remaining} 次。`)
}

await session.$send(output.join('\n'))
Expand Down

0 comments on commit 40142f6

Please sign in to comment.