Skip to content

Commit

Permalink
fix(ascii2d): changed to ascii2d GET interface, fix #26 (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
Container-Zero authored Apr 16, 2024
1 parent 26f9fa5 commit eb623dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 3 additions & 3 deletions 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.3",
"version": "4.2.4",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
Expand Down Expand Up @@ -42,7 +42,7 @@
}
},
"peerDependencies": {
"koishi": "^4.16.3"
"koishi": "^4.17.0"
},
"dependencies": {
"cheerio": "^1.0.0-rc.12",
Expand All @@ -51,7 +51,7 @@
},
"devDependencies": {
"@types/node": "^20.10.2",
"koishi": "^4.16.3",
"koishi": "^4.17.0",
"typescript": "^5.3.2"
}
}
8 changes: 2 additions & 6 deletions src/ascii2d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import { load } from 'cheerio'
import { Logger, Quester, Session } from 'koishi'
import { Config, getShareText, OutputConfig } from './utils'
import FormData from 'form-data'

const baseURL = 'https://ascii2d.net'
const logger = new Logger('search')

export default async function (http: Quester, url: string, session: Session, config: Config) {
try {
const tasks: Promise<string[]>[] = []
const form = new FormData()
form.append('file', await http.get(url, { responseType: 'stream' }))
const colorHTML = await http.post(`${baseURL}/search/file`, form, {
const colorHTML = await http.get(`${baseURL}/search/url/${encodeURIComponent(url)}`,{
headers: {
'User-Agent': 'PostmanRuntime/7.29.0',
...form.getHeaders(),
'User-Agent': 'PostmanRuntime/7.29.0',
},
})
tasks.push(session.send('ascii2d 色合检索\n' + getDetail(colorHTML, config.output)))
Expand Down

0 comments on commit eb623dc

Please sign in to comment.