koishi-plugin-cocoyyy-console 1.0.16-beta.2 → 1.0.16-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -47,6 +47,7 @@ var FunctionConfigSchema = import_koishi.Schema.object({
47
47
  tag_flag: import_koishi.Schema.boolean().default(true).description("标签功能是否启用"),
48
48
  repeat_flag: import_koishi.Schema.boolean().default(true).description("复读功能是否启用"),
49
49
  rbq_flag: import_koishi.Schema.boolean().default(true).description("*人功能是否启用"),
50
+ shit_or_not_flag: import_koishi.Schema.boolean().default(true).description("鉴别史消息功能是否启用"),
50
51
  kuro_flag: import_koishi.Schema.boolean().default(true).description("鸣潮功能是否启用")
51
52
  });
52
53
 
@@ -1351,49 +1352,8 @@ function registerRbqCommands(ctx, connected) {
1351
1352
  }
1352
1353
  __name(registerRbqCommands, "registerRbqCommands");
1353
1354
 
1354
- // src/utils/ai_axios.ts
1355
- var import_axios = __toESM(require("axios"));
1356
- async function callOpenRouter(apiKey, messages, model = "gpt-4o-mini") {
1357
- try {
1358
- const { data } = await import_axios.default.post(
1359
- "https://openrouter.ai/api/v1/chat/completions",
1360
- {
1361
- model,
1362
- messages
1363
- },
1364
- {
1365
- headers: {
1366
- Authorization: `Bearer ${apiKey}`,
1367
- "Content-Type": "application/json"
1368
- }
1369
- }
1370
- );
1371
- const choices = data?.choices ?? [];
1372
- const reply = choices[0]?.message?.content;
1373
- let responseText;
1374
- if (typeof reply === "string") {
1375
- responseText = reply.trim();
1376
- } else if (Array.isArray(reply)) {
1377
- responseText = reply.map((part) => part?.text ?? "").join("").trim();
1378
- if (!responseText) {
1379
- responseText = "OpenRouter 返回空内容";
1380
- }
1381
- } else {
1382
- responseText = "OpenRouter 返回了未知格式,请检查日志";
1383
- }
1384
- return { err: null, resp: responseText };
1385
- } catch (error) {
1386
- const err = error;
1387
- const status = err.response?.status;
1388
- const detail = err.response?.data?.error || err.response?.data?.message || err.message;
1389
- logger.error(error, "OpenRouter 请求失败");
1390
- const errorMessage = `test error${status ? `(${status})` : ""}: ${detail}`;
1391
- return { err: errorMessage, resp: null };
1392
- }
1393
- }
1394
- __name(callOpenRouter, "callOpenRouter");
1395
-
1396
1355
  // src/services/test_command.ts
1356
+ var import_tesseract = require("tesseract.js");
1397
1357
  var CONSTANTS = {
1398
1358
  ESU: "前提条件"
1399
1359
  };
@@ -1409,18 +1369,16 @@ function registerTestCommands(ctx, config) {
1409
1369
  { role: "system", content: CONSTANTS.ESU },
1410
1370
  ...chatHistory
1411
1371
  ];
1412
- const { err, resp } = await callOpenRouter(apiKey, messages);
1413
- if (err) {
1414
- return err;
1415
- }
1416
- if (!resp) {
1417
- return "OpenRouter 返回空响应";
1418
- }
1419
- chatHistory.push({ role: "assistant", content: resp });
1420
- return resp;
1421
1372
  });
1422
- ctx.command("test <text>", "调用 OpenRouter 模型进行测试").action(async ({ session }, text) => {
1423
- return text;
1373
+ ctx.command("test <path>", "测试用").action(async ({ session }, path) => {
1374
+ const { content, uid, userId } = session;
1375
+ if (session.quote) {
1376
+ const quoteContent = session.quote.content;
1377
+ const quoteUserId = session.quote.user.id;
1378
+ logger.error(`quoteContent: ${quoteContent}, quoteUserId: ${quoteUserId},content: ${content} userId: ${userId}`);
1379
+ } else {
1380
+ logger.error(`content: ${content} userId: ${userId}`);
1381
+ }
1424
1382
  });
1425
1383
  ctx.middleware((session, next) => {
1426
1384
  const { content, uid, userId } = session;
@@ -1439,7 +1397,7 @@ function registerTestCommands(ctx, config) {
1439
1397
  __name(registerTestCommands, "registerTestCommands");
1440
1398
 
1441
1399
  // src/services/kuro_func/kuro_service.ts
1442
- var import_axios2 = __toESM(require("axios"));
1400
+ var import_axios = __toESM(require("axios"));
1443
1401
  var import_qs = __toESM(require("qs"));
1444
1402
 
1445
1403
  // src/models/kuro_user.ts
@@ -1572,7 +1530,7 @@ var CONSTANTS2 = {
1572
1530
  "source": "ios"
1573
1531
  }
1574
1532
  };
1575
- var wavesApi = import_axios2.default.create();
1533
+ var wavesApi = import_axios.default.create();
1576
1534
  wavesApi.interceptors.request.use(
1577
1535
  async (config) => {
1578
1536
  if (config.url.startsWith("/")) {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import { OpenRouterMessage } from '../../utils/ai_axios';
2
+ import { Session } from 'koishi';
3
+ declare function ocrImage(buffer: Buffer): Promise<string>;
4
+ declare function checkShitOrNot(session: Session, parttern_msg: string): Promise<OpenRouterMessage[]>;
5
+ export { checkShitOrNot, ocrImage };
@@ -1,4 +1,5 @@
1
1
  import { Context } from 'koishi';
2
2
  import { Config } from '..';
3
3
  declare function registerTestCommands(ctx: Context, config: Config): void;
4
+ export declare function ocrImage(buffer: Buffer): Promise<string>;
4
5
  export { registerTestCommands };
@@ -14,4 +14,4 @@ export interface OpenRouterResult {
14
14
  * @returns 返回包含错误和响应的对象 { err: string | null, resp: string | null }
15
15
  * err 不为 null 时表示出错,resp 不为 null 时表示成功
16
16
  */
17
- export declare function callOpenRouter(apiKey: string, messages: OpenRouterMessage[], model?: string): Promise<OpenRouterResult>;
17
+ export declare function callOpenRouter(api_url: string, api_key: string, api_model: string, messages: OpenRouterMessage[]): Promise<OpenRouterResult>;
@@ -4,6 +4,7 @@ interface FunctionConfig {
4
4
  tag_flag: boolean;
5
5
  repeat_flag: boolean;
6
6
  rbq_flag: boolean;
7
+ shit_or_not_flag: boolean;
7
8
  kuro_flag: boolean;
8
9
  }
9
10
  declare const FunctionConfigSchema: Schema<FunctionConfig>;
@@ -0,0 +1,8 @@
1
+ import { Schema } from 'koishi';
2
+ interface ShitOrNotConfig {
3
+ api_url?: string;
4
+ api_model?: string;
5
+ api_key?: string;
6
+ }
7
+ declare const ShitOrNotConfigSchema: Schema<ShitOrNotConfig>;
8
+ export { ShitOrNotConfig, ShitOrNotConfigSchema, };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-cocoyyy-console",
3
3
  "description": "自用koishi插件,功能包含复读,记录黑历史,*人等",
4
- "version": "1.0.16-beta.2",
4
+ "version": "1.0.16-beta.3",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [
@@ -25,6 +25,7 @@
25
25
  "mysql2": "^3.11.0",
26
26
  "qs": "^6.14.0",
27
27
  "sequelize": "^6.37.3",
28
- "ioredis": "^5.8.2"
28
+ "ioredis": "^5.8.2",
29
+ "tesseract.js": "^5.1.0"
29
30
  }
30
31
  }