koishi-plugin-best-cave 1.5.5 → 1.5.6
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.d.ts +24 -0
- package/lib/index.js +2 -3
- package/lib/types.d.ts +24 -0
- package/lib/utils/AuditHandler.d.ts +2 -28
- package/lib/utils/MediaHandler.d.ts +1 -23
- package/lib/utils/ProcessHandle.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import { Context, Schema } from 'koishi';
|
|
2
2
|
export declare const name = "best-cave";
|
|
3
3
|
export declare const inject: string[];
|
|
4
|
+
export interface BaseElement {
|
|
5
|
+
type: 'text' | 'img' | 'video';
|
|
6
|
+
index: number;
|
|
7
|
+
}
|
|
8
|
+
export interface TextElement extends BaseElement {
|
|
9
|
+
type: 'text';
|
|
10
|
+
content: string;
|
|
11
|
+
}
|
|
12
|
+
export interface MediaElement extends BaseElement {
|
|
13
|
+
type: 'img' | 'video';
|
|
14
|
+
file?: string;
|
|
15
|
+
fileName?: string;
|
|
16
|
+
fileSize?: string;
|
|
17
|
+
filePath?: string;
|
|
18
|
+
}
|
|
19
|
+
export type Element = TextElement | MediaElement;
|
|
20
|
+
export interface CaveObject {
|
|
21
|
+
cave_id: number;
|
|
22
|
+
elements: Element[];
|
|
23
|
+
contributor_number: string;
|
|
24
|
+
contributor_name: string;
|
|
25
|
+
}
|
|
26
|
+
export interface PendingCave extends CaveObject {
|
|
27
|
+
}
|
|
4
28
|
/**
|
|
5
29
|
* 插件配置项
|
|
6
30
|
* @type {Schema}
|
package/lib/index.js
CHANGED
|
@@ -985,10 +985,9 @@ var import_koishi4 = require("koishi");
|
|
|
985
985
|
var fs4 = __toESM(require("fs"));
|
|
986
986
|
var path4 = __toESM(require("path"));
|
|
987
987
|
var AuditManager = class {
|
|
988
|
-
constructor(ctx, config,
|
|
988
|
+
constructor(ctx, config, idManager) {
|
|
989
989
|
this.ctx = ctx;
|
|
990
990
|
this.config = config;
|
|
991
|
-
this.caveDir = caveDir;
|
|
992
991
|
this.idManager = idManager;
|
|
993
992
|
}
|
|
994
993
|
static {
|
|
@@ -1509,7 +1508,7 @@ async function apply(ctx, config) {
|
|
|
1509
1508
|
await FileHandler.ensureJsonFile(path7.join(caveDir, "hash.json"));
|
|
1510
1509
|
const idManager = new IdManager(ctx.baseDir);
|
|
1511
1510
|
const contentHashManager = new HashManager(caveDir);
|
|
1512
|
-
const auditManager = new AuditManager(ctx, config,
|
|
1511
|
+
const auditManager = new AuditManager(ctx, config, idManager);
|
|
1513
1512
|
await Promise.all([
|
|
1514
1513
|
idManager.initialize(path7.join(caveDir, "cave.json"), path7.join(caveDir, "pending.json")),
|
|
1515
1514
|
contentHashManager.initialize()
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface BaseElement {
|
|
2
|
+
type: 'text' | 'img' | 'video';
|
|
3
|
+
index: number;
|
|
4
|
+
}
|
|
5
|
+
export interface TextElement extends BaseElement {
|
|
6
|
+
type: 'text';
|
|
7
|
+
content: string;
|
|
8
|
+
}
|
|
9
|
+
export interface MediaElement extends BaseElement {
|
|
10
|
+
type: 'img' | 'video';
|
|
11
|
+
file?: string;
|
|
12
|
+
fileName?: string;
|
|
13
|
+
fileSize?: string;
|
|
14
|
+
filePath?: string;
|
|
15
|
+
}
|
|
16
|
+
export type Element = TextElement | MediaElement;
|
|
17
|
+
export interface CaveObject {
|
|
18
|
+
cave_id: number;
|
|
19
|
+
elements: Element[];
|
|
20
|
+
contributor_number: string;
|
|
21
|
+
contributor_name: string;
|
|
22
|
+
}
|
|
23
|
+
export interface PendingCave extends CaveObject {
|
|
24
|
+
}
|
|
@@ -1,37 +1,12 @@
|
|
|
1
1
|
import { Context } from 'koishi';
|
|
2
|
-
import { Config } from '
|
|
2
|
+
import { Config, PendingCave } from '..';
|
|
3
3
|
import { IdManager } from './IdManager';
|
|
4
|
-
export interface CaveObject {
|
|
5
|
-
cave_id: number;
|
|
6
|
-
elements: Element[];
|
|
7
|
-
contributor_number: string;
|
|
8
|
-
contributor_name: string;
|
|
9
|
-
}
|
|
10
|
-
interface BaseElement {
|
|
11
|
-
type: 'text' | 'img' | 'video';
|
|
12
|
-
index: number;
|
|
13
|
-
}
|
|
14
|
-
interface TextElement extends BaseElement {
|
|
15
|
-
type: 'text';
|
|
16
|
-
content: string;
|
|
17
|
-
}
|
|
18
|
-
interface MediaElement extends BaseElement {
|
|
19
|
-
type: 'img' | 'video';
|
|
20
|
-
file?: string;
|
|
21
|
-
fileName?: string;
|
|
22
|
-
fileSize?: string;
|
|
23
|
-
filePath?: string;
|
|
24
|
-
}
|
|
25
|
-
type Element = TextElement | MediaElement;
|
|
26
|
-
export interface PendingCave extends CaveObject {
|
|
27
|
-
}
|
|
28
4
|
export declare class AuditManager {
|
|
29
5
|
private ctx;
|
|
30
6
|
private config;
|
|
31
|
-
private caveDir;
|
|
32
7
|
private idManager;
|
|
33
8
|
private logger;
|
|
34
|
-
constructor(ctx: Context, config: Config,
|
|
9
|
+
constructor(ctx: Context, config: Config, idManager: IdManager);
|
|
35
10
|
processAudit(pendingData: PendingCave[], isApprove: boolean, caveFilePath: string, resourceDir: string, pendingFilePath: string, session: any, targetId?: number): Promise<string>;
|
|
36
11
|
private handleSingleAudit;
|
|
37
12
|
private handleBatchAudit;
|
|
@@ -40,4 +15,3 @@ export declare class AuditManager {
|
|
|
40
15
|
private cleanElementsForSave;
|
|
41
16
|
private sendMessage;
|
|
42
17
|
}
|
|
43
|
-
export {};
|
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
import { Context } from 'koishi';
|
|
2
|
-
|
|
3
|
-
type: 'text' | 'img' | 'video';
|
|
4
|
-
index: number;
|
|
5
|
-
}
|
|
6
|
-
interface CaveObject {
|
|
7
|
-
cave_id: number;
|
|
8
|
-
elements: Element[];
|
|
9
|
-
contributor_number: string;
|
|
10
|
-
contributor_name: string;
|
|
11
|
-
}
|
|
12
|
-
export interface TextElement extends BaseElement {
|
|
13
|
-
type: 'text';
|
|
14
|
-
content: string;
|
|
15
|
-
}
|
|
16
|
-
export interface MediaElement extends BaseElement {
|
|
17
|
-
type: 'img' | 'video';
|
|
18
|
-
file?: string;
|
|
19
|
-
fileName?: string;
|
|
20
|
-
fileSize?: string;
|
|
21
|
-
filePath?: string;
|
|
22
|
-
}
|
|
23
|
-
export type Element = TextElement | MediaElement;
|
|
2
|
+
import { Element, CaveObject } from '..';
|
|
24
3
|
export declare function buildMessage(cave: CaveObject, resourceDir: string, session?: any): Promise<string>;
|
|
25
4
|
export declare function sendMessage(session: any, key: string, params?: any[], isTemp?: boolean, timeout?: number): Promise<string>;
|
|
26
5
|
export declare function processMediaFile(filePath: string, type: 'image' | 'video'): Promise<string | null>;
|
|
@@ -49,4 +28,3 @@ export declare function saveMedia(urls: string[], fileNames: (string | undefined
|
|
|
49
28
|
imageDuplicateThreshold: number;
|
|
50
29
|
textDuplicateThreshold: number;
|
|
51
30
|
}, ctx: Context, session: any, buffers?: Buffer[]): Promise<string[]>;
|
|
52
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config } from '
|
|
1
|
+
import { Config } from '..';
|
|
2
2
|
import { IdManager } from './IdManager';
|
|
3
3
|
import { HashManager } from './HashManager';
|
|
4
4
|
export declare function processList(session: any, config: Config, idManager: IdManager, userId?: string, pageNum?: number): Promise<string>;
|