koishi-plugin-go-bank 0.0.1
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/api.d.ts +44 -0
- package/lib/index.d.ts +26 -0
- package/lib/middleware.d.ts +4 -0
- package/lib/parser.d.ts +13 -0
- package/lib/scheduler.d.ts +24 -0
- package/lib/session.d.ts +5 -0
- package/lib/types.d.ts +121 -0
- package/package.json +22 -0
package/lib/api.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Problem, ReviewResult, TodayReviewItem, ReviewStats, PlanOut, PlanDailyOut, PlanSessionResult, PlanProgressRender } from './types';
|
|
2
|
+
export declare class GoBankAPI {
|
|
3
|
+
private baseUrl;
|
|
4
|
+
constructor(baseUrl: string);
|
|
5
|
+
private get;
|
|
6
|
+
private post;
|
|
7
|
+
private del;
|
|
8
|
+
randomProblem(params: {
|
|
9
|
+
type?: string;
|
|
10
|
+
difficulty?: string;
|
|
11
|
+
difficulty_match?: string;
|
|
12
|
+
}): Promise<Problem>;
|
|
13
|
+
randomProblems(difficulty: string, type: string, count: number): Promise<Problem[]>;
|
|
14
|
+
submitReview(data: {
|
|
15
|
+
qq_number: string;
|
|
16
|
+
problem_id: number;
|
|
17
|
+
quality: number;
|
|
18
|
+
}): Promise<ReviewResult>;
|
|
19
|
+
getTodayReview(qqNumber: string): Promise<{
|
|
20
|
+
total: number;
|
|
21
|
+
items: TodayReviewItem[];
|
|
22
|
+
}>;
|
|
23
|
+
getReviewStats(qqNumber: string): Promise<ReviewStats>;
|
|
24
|
+
getPlan(qqNumber: string): Promise<PlanOut>;
|
|
25
|
+
savePlan(data: {
|
|
26
|
+
qq_number: string;
|
|
27
|
+
difficulty: string;
|
|
28
|
+
daily_groups: number;
|
|
29
|
+
problems_per_group: number;
|
|
30
|
+
}): Promise<PlanOut>;
|
|
31
|
+
resetPlan(qqNumber: string): Promise<PlanProgressRender>;
|
|
32
|
+
generateDailyPlan(data: {
|
|
33
|
+
qq_number: string;
|
|
34
|
+
difficulty: string;
|
|
35
|
+
daily_groups: number;
|
|
36
|
+
problems_per_group: number;
|
|
37
|
+
}): Promise<PlanDailyOut>;
|
|
38
|
+
getDailyPlan(qqNumber: string): Promise<PlanDailyOut>;
|
|
39
|
+
planSessionSubmit(data: {
|
|
40
|
+
qq_number: string;
|
|
41
|
+
session_id: number;
|
|
42
|
+
quality: number;
|
|
43
|
+
}): Promise<PlanSessionResult>;
|
|
44
|
+
}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Context, Schema } from 'koishi';
|
|
2
|
+
export declare const name = "go-bank";
|
|
3
|
+
export interface Config {
|
|
4
|
+
apiBaseUrl: string;
|
|
5
|
+
dailyPush: {
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
time: string;
|
|
8
|
+
difficulty: string;
|
|
9
|
+
type: string;
|
|
10
|
+
count: number;
|
|
11
|
+
groups: string[];
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
hourlyPush: {
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
startHour: number;
|
|
17
|
+
endHour: number;
|
|
18
|
+
difficulty: string;
|
|
19
|
+
type: string;
|
|
20
|
+
count: number;
|
|
21
|
+
groups: string[];
|
|
22
|
+
message: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export declare const Config: Schema<Config>;
|
|
26
|
+
export declare function apply(ctx: Context, config: Config): void;
|
package/lib/parser.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { QuickCommand } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parse quick commands like:
|
|
4
|
+
* !8k → difficulty=8K, count=1
|
|
5
|
+
* !8k 10 → difficulty=8K, count=10
|
|
6
|
+
* !官子 → type=guanzi, count=1
|
|
7
|
+
* !官子 10 → type=guanzi, count=10
|
|
8
|
+
* !官子-8k → type=guanzi, difficulty=8K, count=1
|
|
9
|
+
* !官子-8k 5 → type=guanzi, difficulty=8K, count=5
|
|
10
|
+
*
|
|
11
|
+
* Returns null if not a valid quick command.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseQuickCommand(text: string): QuickCommand | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Context } from 'koishi';
|
|
2
|
+
export interface DailyPushConfig {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
time: string;
|
|
5
|
+
difficulty: string;
|
|
6
|
+
type: string;
|
|
7
|
+
count: number;
|
|
8
|
+
groups: string[];
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
11
|
+
export interface HourlyPushConfig {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
startHour: number;
|
|
14
|
+
endHour: number;
|
|
15
|
+
difficulty: string;
|
|
16
|
+
type: string;
|
|
17
|
+
count: number;
|
|
18
|
+
groups: string[];
|
|
19
|
+
message: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Start push schedulers. Checks every 60 seconds.
|
|
23
|
+
*/
|
|
24
|
+
export declare function startScheduler(ctx: Context, daily: DailyPushConfig, hourly: HourlyPushConfig, fetchRandom: (difficulty: string, type: string, count: number) => Promise<any[]>): void;
|
package/lib/session.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { UserSession, SessionMode } from './types';
|
|
2
|
+
export declare function getSession(userId: string): UserSession | undefined;
|
|
3
|
+
export declare function setSession(userId: string, session: UserSession): void;
|
|
4
|
+
export declare function clearSession(userId: string): void;
|
|
5
|
+
export declare function createSession(mode: SessionMode, overrides?: Partial<UserSession>): UserSession;
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export interface Problem {
|
|
2
|
+
id: number;
|
|
3
|
+
problem_number: string;
|
|
4
|
+
difficulty: string;
|
|
5
|
+
type: string;
|
|
6
|
+
image_url: string;
|
|
7
|
+
answer_image_url: string | null;
|
|
8
|
+
is_active: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ReviewResult {
|
|
11
|
+
problem_id: number;
|
|
12
|
+
problem_number: string;
|
|
13
|
+
quality: number;
|
|
14
|
+
ease_factor: number;
|
|
15
|
+
interval_days: number;
|
|
16
|
+
repetitions: number;
|
|
17
|
+
status: string;
|
|
18
|
+
next_review_time: string;
|
|
19
|
+
}
|
|
20
|
+
export interface TodayReviewItem {
|
|
21
|
+
problem_id: number;
|
|
22
|
+
problem_number: string;
|
|
23
|
+
difficulty: string;
|
|
24
|
+
type: string;
|
|
25
|
+
image_url: string;
|
|
26
|
+
answer_image_url: string | null;
|
|
27
|
+
status: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ReviewStats {
|
|
30
|
+
total_problems: number;
|
|
31
|
+
new_count: number;
|
|
32
|
+
learning_count: number;
|
|
33
|
+
review_count: number;
|
|
34
|
+
mastered_count: number;
|
|
35
|
+
today_reviewed: number;
|
|
36
|
+
today_remaining: number;
|
|
37
|
+
total_reviews: number;
|
|
38
|
+
accuracy_rate: number;
|
|
39
|
+
}
|
|
40
|
+
export interface PlanOut {
|
|
41
|
+
id: number;
|
|
42
|
+
user_id: number;
|
|
43
|
+
difficulty: string;
|
|
44
|
+
daily_groups: number;
|
|
45
|
+
problems_per_group: number;
|
|
46
|
+
is_active: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface PlanDailyItem {
|
|
49
|
+
session_id: number;
|
|
50
|
+
problem: Problem;
|
|
51
|
+
group_num: number;
|
|
52
|
+
order_in_group: number;
|
|
53
|
+
source: 'new' | 'review';
|
|
54
|
+
completed: boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface PlanDailyOut {
|
|
57
|
+
plan_date: string;
|
|
58
|
+
difficulty: string;
|
|
59
|
+
daily_groups: number;
|
|
60
|
+
problems_per_group: number;
|
|
61
|
+
total_new: number;
|
|
62
|
+
total_review: number;
|
|
63
|
+
total_done: number;
|
|
64
|
+
current_group: number;
|
|
65
|
+
group_progress: number;
|
|
66
|
+
carryover: number;
|
|
67
|
+
items: PlanDailyItem[];
|
|
68
|
+
}
|
|
69
|
+
export interface PlanSessionResult {
|
|
70
|
+
session_id: number;
|
|
71
|
+
quality: number;
|
|
72
|
+
next_problem: PlanDailyItem | null;
|
|
73
|
+
group_complete: boolean;
|
|
74
|
+
all_complete: boolean;
|
|
75
|
+
daily_progress: string;
|
|
76
|
+
}
|
|
77
|
+
export interface PlanProgressRender {
|
|
78
|
+
plan: PlanOut | null;
|
|
79
|
+
total_done_today: number;
|
|
80
|
+
total_done_all: number;
|
|
81
|
+
status_text: string;
|
|
82
|
+
}
|
|
83
|
+
export type SessionMode = 'idle' | 'immersive' | 'review' | 'plan';
|
|
84
|
+
export interface UserSession {
|
|
85
|
+
mode: SessionMode;
|
|
86
|
+
currentProblem: Problem | PlanDailyItem;
|
|
87
|
+
lastInteraction: Date;
|
|
88
|
+
immersiveCriteria?: {
|
|
89
|
+
type?: string;
|
|
90
|
+
difficulty?: string;
|
|
91
|
+
};
|
|
92
|
+
reviewQueue?: TodayReviewItem[];
|
|
93
|
+
reviewIndex?: number;
|
|
94
|
+
reviewTotal?: number;
|
|
95
|
+
planSession?: {
|
|
96
|
+
difficulty: string;
|
|
97
|
+
dailyGroups: number;
|
|
98
|
+
problemsPerGroup: number;
|
|
99
|
+
currentGroup: number;
|
|
100
|
+
groupProgress: number;
|
|
101
|
+
dailyTotal: number;
|
|
102
|
+
dailyDone: number;
|
|
103
|
+
};
|
|
104
|
+
pendingPlanTemplate?: boolean;
|
|
105
|
+
}
|
|
106
|
+
export interface QuickCommand {
|
|
107
|
+
type: 'difficulty' | 'type' | 'both';
|
|
108
|
+
difficulty?: string;
|
|
109
|
+
problemType?: string;
|
|
110
|
+
count: number;
|
|
111
|
+
}
|
|
112
|
+
export declare const TYPE_MAP: Record<string, string>;
|
|
113
|
+
export declare const TYPE_REVERSE_MAP: Record<string, string>;
|
|
114
|
+
export declare const STATUS_MAP: Record<string, string>;
|
|
115
|
+
export declare const DIFFICULTY_HIERARCHY: string[];
|
|
116
|
+
export declare const VALID_TYPES: string[];
|
|
117
|
+
export declare function getTypeName(type: string): string;
|
|
118
|
+
export declare function getTypeCode(name: string): string;
|
|
119
|
+
export declare function getStatusName(status: string): string;
|
|
120
|
+
/** Get the next harder difficulty tier. Returns null if already at max. */
|
|
121
|
+
export declare function getNextDifficulty(diff: string): string | null;
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "koishi-plugin-go-bank",
|
|
3
|
+
"description": "围棋题库管理与训练插件",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"typings": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"chatbot",
|
|
14
|
+
"koishi",
|
|
15
|
+
"plugin",
|
|
16
|
+
"go",
|
|
17
|
+
"围棋"
|
|
18
|
+
],
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"koishi": "^4.18.7"
|
|
21
|
+
}
|
|
22
|
+
}
|