koishi-plugin-mai-ocr
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -20,1 +20,2 @@ import { Context, Dict, Schema } from 'koishi'; | ||
export declare function apply(ctx: Context, config: Config): void; | ||
export declare function censorText(ctx: any, text: string): Promise<any>; |
@@ -6,3 +6,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.apply = exports.Config = exports.inject = exports.name = void 0; | ||
exports.Config = exports.inject = exports.name = void 0; | ||
exports.apply = apply; | ||
exports.censorText = censorText; | ||
const koishi_1 = require("koishi"); | ||
@@ -13,3 +15,3 @@ const crypto_1 = __importDefault(require("crypto")); | ||
exports.inject = { | ||
optional: ['translator'] | ||
optional: ['translator', 'censor'] | ||
}; | ||
@@ -104,5 +106,5 @@ exports.Config = koishi_1.Schema.intersect([ | ||
//计算签名 | ||
const kDate = sha256(date, "TC3" + config.SECRET_KEY); | ||
const kService = sha256(service, kDate); | ||
const kSigning = sha256("tc3_request", kService); | ||
const kDate = sha256(date, "TC3" + config.SECRET_KEY, "hex"); | ||
const kService = sha256(service, kDate, "hex"); | ||
const kSigning = sha256("tc3_request", kService, "hex"); | ||
const signature = sha256(stringToSign, kSigning, "hex"); | ||
@@ -178,5 +180,5 @@ //拼接 Authorization | ||
}); | ||
const characterString = characters.map(characterObject => characterObject.character).join(' ').replace(/\./g, "۔"); | ||
const characterString = await censorText(ctx, characters.map(characterObject => characterObject.character).join(' ').replace(/\./g, "۔")); | ||
if (config.是否翻译) { | ||
const translation = await session.app['translator'].translate({ target: config.目标语言, input: characterString }); | ||
const translation = await censorText(ctx, await session.app['translator'].translate({ target: config.目标语言, input: characterString })); | ||
if (config.使用MD) { | ||
@@ -284,2 +286,6 @@ const c1 = mdCreate(characterString, translation, session); | ||
} | ||
exports.apply = apply; | ||
async function censorText(ctx, text) { | ||
const a = [(0, koishi_1.Element)('text', { content: text })]; | ||
const [b] = await ctx.censor.transform(a); | ||
return b.attrs.content; | ||
} |
{ | ||
"name": "koishi-plugin-mai-ocr", | ||
"description": "通过腾讯的ocr接口进行文字识别,并且提供翻译功能", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"main": "lib/index.js", | ||
@@ -24,4 +24,4 @@ "typings": "lib/index.d.ts", | ||
"peerDependencies": { | ||
"koishi": "^4.16.4" | ||
"koishi": "^4.17.2" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14181
306