Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koishi-plugin-mai-ocr

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koishi-plugin-mai-ocr - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

1

lib/index.d.ts

@@ -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>;

22

lib/index.js

@@ -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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc