@azimiao/koishi-plugin-cafe-bot-exp 0.0.5 → 0.0.7
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/cat/config.d.ts +9 -0
- package/lib/cat/index.d.ts +10 -0
- package/lib/common/DailySeededName.d.ts +1 -0
- package/lib/common/PseudoRandom.d.ts +11 -0
- package/lib/common/at.d.ts +1 -0
- package/lib/config.d.ts +4 -21
- package/lib/draw/config.d.ts +22 -0
- package/lib/draw/index.d.ts +11 -0
- package/lib/draw/templete/html.d.ts +2 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +289 -174
- package/lib/quiz/config.d.ts +11 -0
- package/lib/quiz/index.d.ts +11 -0
- package/package.json +12 -3
- package/readme.md +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Schema } from "koishi";
|
|
2
|
+
export interface CafeBotCatConfig {
|
|
3
|
+
catName: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const CafeBotCatConfig: Schema<Schemastery.ObjectS<{
|
|
6
|
+
catName: Schema<string, string>;
|
|
7
|
+
}>, Schemastery.ObjectT<{
|
|
8
|
+
catName: Schema<string, string>;
|
|
9
|
+
}>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 黑猫柯贝
|
|
3
|
+
*/
|
|
4
|
+
import { Context, Schema } from 'koishi';
|
|
5
|
+
import { CafeBotCatConfig } from './config';
|
|
6
|
+
export declare const name = "cafe-bot-exp.cat";
|
|
7
|
+
export interface Config extends CafeBotCatConfig {
|
|
8
|
+
}
|
|
9
|
+
export declare const Config: Schema<Config>;
|
|
10
|
+
export declare function apply(ctx: Context): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function DailySeededName(uid: any): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function At(argv: any, newLine?: boolean): string;
|
package/lib/config.d.ts
CHANGED
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
import { Schema } from "koishi";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
MinCount: number;
|
|
7
|
-
MaxCount: number;
|
|
8
|
-
Star1Name: string;
|
|
9
|
-
Star1Chance: number;
|
|
10
|
-
Star2Name: string;
|
|
11
|
-
Star2Chance: number;
|
|
12
|
-
Star3Name: string;
|
|
13
|
-
Star3Chance: number;
|
|
14
|
-
Star4Name: string;
|
|
15
|
-
Star4Chance: number;
|
|
16
|
-
Star5Name: string;
|
|
17
|
-
Star5Chance: number;
|
|
18
|
-
}
|
|
19
|
-
export interface CafeBotQuizConfig {
|
|
20
|
-
baseQuizUrl: string;
|
|
21
|
-
}
|
|
22
|
-
export type Config = CafeBotDrawConfig & CafeBotQuizConfig;
|
|
2
|
+
import { CafeBotDrawConfig } from "./draw/config";
|
|
3
|
+
import { CafeBotQuizConfig } from "./quiz/config";
|
|
4
|
+
import { CafeBotCatConfig } from "./cat/config";
|
|
5
|
+
export type Config = CafeBotDrawConfig & CafeBotQuizConfig & CafeBotCatConfig;
|
|
23
6
|
export declare const Config: Schema<Config>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 轨迹抽卡配置
|
|
3
|
+
*/
|
|
4
|
+
import { Schema } from "koishi";
|
|
5
|
+
export interface CafeBotDrawConfig {
|
|
6
|
+
baseDataUrl: string;
|
|
7
|
+
ImageServer: string;
|
|
8
|
+
ImageServerAuth: string;
|
|
9
|
+
MinCount: number;
|
|
10
|
+
MaxCount: number;
|
|
11
|
+
Star1Name: string;
|
|
12
|
+
Star1Chance: number;
|
|
13
|
+
Star2Name: string;
|
|
14
|
+
Star2Chance: number;
|
|
15
|
+
Star3Name: string;
|
|
16
|
+
Star3Chance: number;
|
|
17
|
+
Star4Name: string;
|
|
18
|
+
Star4Chance: number;
|
|
19
|
+
Star5Name: string;
|
|
20
|
+
Star5Chance: number;
|
|
21
|
+
}
|
|
22
|
+
export declare const CafeBotDrawConfig: Schema<CafeBotDrawConfig>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 轨迹抽卡
|
|
3
|
+
*/
|
|
4
|
+
import { Context, Schema } from 'koishi';
|
|
5
|
+
import { CafeBotDrawConfig } from './config';
|
|
6
|
+
export declare const name = "cafe-bot-exp.draw";
|
|
7
|
+
export declare const inject: string[];
|
|
8
|
+
export interface Config extends CafeBotDrawConfig {
|
|
9
|
+
}
|
|
10
|
+
export declare const Config: Schema<Config>;
|
|
11
|
+
export declare function apply(ctx: Context, config: Config): Promise<void>;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 主入口文件
|
|
3
|
+
*/
|
|
1
4
|
import { Context } from 'koishi';
|
|
2
5
|
import { Config } from './config';
|
|
3
6
|
export declare const name = "cafe-bot-exp";
|
|
4
|
-
export declare const inject: string[];
|
|
5
7
|
export * from "./config";
|
|
6
8
|
export declare function apply(ctx: Context, config: Config): Promise<void>;
|
package/lib/index.js
CHANGED
|
@@ -6,8 +6,8 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
for (var
|
|
10
|
-
__defProp(target,
|
|
9
|
+
for (var name5 in all)
|
|
10
|
+
__defProp(target, name5, { get: all[name5], enumerable: true });
|
|
11
11
|
};
|
|
12
12
|
var __copyProps = (to, from, except, desc) => {
|
|
13
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -30,15 +30,25 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
Config: () => Config4,
|
|
34
|
+
apply: () => apply4,
|
|
35
|
+
name: () => name4
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(src_exports);
|
|
38
|
+
|
|
39
|
+
// src/draw/index.ts
|
|
40
|
+
var draw_exports = {};
|
|
41
|
+
__export(draw_exports, {
|
|
33
42
|
Config: () => Config,
|
|
34
43
|
apply: () => apply,
|
|
35
44
|
inject: () => inject,
|
|
36
45
|
name: () => name
|
|
37
46
|
});
|
|
38
|
-
|
|
39
|
-
var
|
|
47
|
+
var fs = __toESM(require("fs/promises"));
|
|
48
|
+
var path = __toESM(require("path"));
|
|
49
|
+
var import_fs_promises = __toESM(require("fs.promises.exists"));
|
|
40
50
|
|
|
41
|
-
// src/DailySeededName.ts
|
|
51
|
+
// src/common/DailySeededName.ts
|
|
42
52
|
function DailySeededName(uid) {
|
|
43
53
|
const now = /* @__PURE__ */ new Date();
|
|
44
54
|
const utc = now.getTime() + now.getTimezoneOffset() * 6e4;
|
|
@@ -53,7 +63,7 @@ function DailySeededName(uid) {
|
|
|
53
63
|
}
|
|
54
64
|
__name(DailySeededName, "DailySeededName");
|
|
55
65
|
|
|
56
|
-
// src/PseudoRandom.ts
|
|
66
|
+
// src/common/PseudoRandom.ts
|
|
57
67
|
var UniformRandom = require("@stdlib/random-base-uniform");
|
|
58
68
|
function stringToSeed(str) {
|
|
59
69
|
let hash = 2166136261;
|
|
@@ -88,7 +98,7 @@ var PseudoRandom = class {
|
|
|
88
98
|
};
|
|
89
99
|
var PseudoRandom_default = PseudoRandom;
|
|
90
100
|
|
|
91
|
-
// src/templete/html.ts
|
|
101
|
+
// src/draw/templete/html.ts
|
|
92
102
|
function HtmlCreator(cardList) {
|
|
93
103
|
const fullHtml = `
|
|
94
104
|
<!DOCTYPE html>
|
|
@@ -98,104 +108,129 @@ function HtmlCreator(cardList) {
|
|
|
98
108
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
99
109
|
<title>抽卡结果</title>
|
|
100
110
|
<style>
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
111
|
+
:root {
|
|
112
|
+
--ur-color: #ff9900;
|
|
113
|
+
--ssr-color: #ff4db8;
|
|
114
|
+
--sr-color: #3399ff;
|
|
115
|
+
--r-color: #eee;
|
|
116
|
+
--n-color: #eee;
|
|
107
117
|
}
|
|
118
|
+
|
|
108
119
|
body {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
120
|
+
font-family: Arial, sans-serif;
|
|
121
|
+
background: #dceffc;
|
|
122
|
+
background-image: url("https://cdn.trails-game.com/wp-content/uploads/2020/07/20_Sunshine.jpg");
|
|
123
|
+
background-size: cover;
|
|
124
|
+
margin: 0;
|
|
125
|
+
padding: 0;
|
|
126
|
+
height: 100vh;
|
|
127
|
+
width: 100vw;
|
|
117
128
|
}
|
|
129
|
+
|
|
118
130
|
.gacha-wrapper {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
131
|
+
display: flex;
|
|
132
|
+
justify-content: center;
|
|
133
|
+
position: absolute;
|
|
134
|
+
transform: translate(-50%, -50%);
|
|
135
|
+
left: 50%;
|
|
136
|
+
top: 50%;
|
|
137
|
+
width: calc(100% - 40px);
|
|
138
|
+
padding-left: 20px;
|
|
139
|
+
padding-right: 20px;
|
|
125
140
|
}
|
|
141
|
+
|
|
126
142
|
.gacha-container {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-wrap: wrap;
|
|
145
|
+
gap: 20px;
|
|
146
|
+
justify-content: center;
|
|
147
|
+
width: 100%;
|
|
132
148
|
}
|
|
149
|
+
|
|
133
150
|
.card {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
151
|
+
background: #fff;
|
|
152
|
+
border-radius: 10px;
|
|
153
|
+
overflow: hidden;
|
|
154
|
+
width: 130px !important;
|
|
155
|
+
height: 155px !important;
|
|
156
|
+
overflow: hidden;
|
|
157
|
+
text-align: center;
|
|
158
|
+
box-shadow: 1px 1px 3px rgb(122, 122, 122);
|
|
159
|
+
border: 3px solid #fff;
|
|
160
|
+
transform: skew(-10deg);
|
|
161
|
+
box-sizing: border-box;
|
|
145
162
|
}
|
|
146
163
|
|
|
147
|
-
.card.rarity-5{
|
|
148
|
-
|
|
149
|
-
|
|
164
|
+
.card.rarity-5 {
|
|
165
|
+
box-shadow: 1px 1px 3px var(--ur-color);
|
|
166
|
+
border: 3px solid var(--ur-color);
|
|
150
167
|
}
|
|
151
168
|
|
|
152
|
-
.card.rarity-4{
|
|
153
|
-
|
|
154
|
-
|
|
169
|
+
.card.rarity-4 {
|
|
170
|
+
box-shadow: 1px 1px 3px var(--ssr-color);
|
|
171
|
+
border: 3px solid var(--ssr-color)
|
|
155
172
|
}
|
|
156
173
|
|
|
157
|
-
.card.rarity-3{
|
|
158
|
-
|
|
159
|
-
|
|
174
|
+
.card.rarity-3 {
|
|
175
|
+
box-shadow: 1px 1px 3px var(--sr-color);
|
|
176
|
+
border: 3px solid var(--sr-color)
|
|
160
177
|
}
|
|
161
178
|
|
|
162
|
-
.card.rarity-2{
|
|
163
|
-
|
|
164
|
-
|
|
179
|
+
.card.rarity-2 {
|
|
180
|
+
box-shadow: 1px 1px 3px var(--r-color);
|
|
181
|
+
border: 3px solid var(--r-color)
|
|
165
182
|
}
|
|
166
183
|
|
|
167
|
-
.card.rarity-1{
|
|
168
|
-
|
|
169
|
-
|
|
184
|
+
.card.rarity-1 {
|
|
185
|
+
box-shadow: 1px 1px 3px var(--n-color);
|
|
186
|
+
border: 3px solid var(--n-color);
|
|
170
187
|
}
|
|
171
|
-
|
|
188
|
+
|
|
172
189
|
.card .card-img {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
190
|
+
position: absolute;
|
|
191
|
+
left: 0;
|
|
192
|
+
top: 0;
|
|
193
|
+
width: 100%;
|
|
194
|
+
height: 115px;
|
|
195
|
+
transform: skew(10deg) scale(1.2);
|
|
196
|
+
background-repeat: no-repeat !important;
|
|
197
|
+
background-size: 100% !important;
|
|
181
198
|
}
|
|
182
199
|
|
|
183
200
|
.rarity {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
201
|
+
position: absolute;
|
|
202
|
+
bottom: 0px;
|
|
203
|
+
padding: 5px;
|
|
204
|
+
background: #34495e;
|
|
205
|
+
font-weight: bold;
|
|
206
|
+
width: 100%;
|
|
207
|
+
text-align: center;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.rarity.rarity-5 {
|
|
211
|
+
color: var(--ur-color);
|
|
212
|
+
border-top: 3px solid var(--ur-color);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.rarity.rarity-4 {
|
|
216
|
+
color: var(--ssr-color);
|
|
217
|
+
border-top: 3px solid var(--ssr-color);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.rarity.rarity-3 {
|
|
221
|
+
color: var(--sr-color);
|
|
222
|
+
border-top: 3px solid var(--sr-color);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.rarity.rarity-2 {
|
|
226
|
+
color: var(--r-color);
|
|
227
|
+
border-top: 3px solid var(--r-color);
|
|
192
228
|
}
|
|
193
229
|
|
|
194
|
-
.rarity.rarity-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
.rarity.rarity-1 { color: var(--n-color); }
|
|
230
|
+
.rarity.rarity-1 {
|
|
231
|
+
color: var(--n-color);
|
|
232
|
+
border-top: 3px solid var(--n-color);
|
|
233
|
+
}
|
|
199
234
|
</style>
|
|
200
235
|
</head>
|
|
201
236
|
<body>
|
|
@@ -220,91 +255,41 @@ function HtmlCreator(cardList) {
|
|
|
220
255
|
__name(HtmlCreator, "HtmlCreator");
|
|
221
256
|
var html_default = HtmlCreator;
|
|
222
257
|
|
|
223
|
-
// src/
|
|
224
|
-
var fs = __toESM(require("fs/promises"));
|
|
225
|
-
var path = __toESM(require("path"));
|
|
226
|
-
var import_fs_promises = __toESM(require("fs.promises.exists"));
|
|
227
|
-
|
|
228
|
-
// src/config.ts
|
|
258
|
+
// src/draw/config.ts
|
|
229
259
|
var import_koishi = require("koishi");
|
|
230
|
-
var
|
|
231
|
-
import_koishi.Schema.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}).description("抽卡设置"),
|
|
248
|
-
import_koishi.Schema.object({
|
|
249
|
-
baseQuizUrl: import_koishi.Schema.string().description("答题数据 Url")
|
|
250
|
-
}).description("答题配置")
|
|
251
|
-
]);
|
|
260
|
+
var CafeBotDrawConfig = import_koishi.Schema.object({
|
|
261
|
+
baseDataUrl: import_koishi.Schema.string().description("数据链接").default("https://www.azimiao.com/kiseki.json"),
|
|
262
|
+
ImageServer: import_koishi.Schema.string().description("图像生成服务器").default("http://127.0.0.1:3000/screenshot"),
|
|
263
|
+
ImageServerAuth: import_koishi.Schema.string().description("图像生成服务器密码").default(""),
|
|
264
|
+
MinCount: import_koishi.Schema.number().description("最小抽取次数").default(0),
|
|
265
|
+
MaxCount: import_koishi.Schema.number().description("最大抽取次数").default(8),
|
|
266
|
+
Star1Name: import_koishi.Schema.string().description("1星名称").default("N"),
|
|
267
|
+
Star1Chance: import_koishi.Schema.number().description("1星概率").default(0.5),
|
|
268
|
+
Star2Name: import_koishi.Schema.string().description("2星名称").default("R"),
|
|
269
|
+
Star2Chance: import_koishi.Schema.number().description("2星概率").default(0.34),
|
|
270
|
+
Star3Name: import_koishi.Schema.string().description("3星名称").default("SR"),
|
|
271
|
+
Star3Chance: import_koishi.Schema.number().description("3星概率").default(0.22),
|
|
272
|
+
Star4Name: import_koishi.Schema.string().description("4星名称").default("SSR"),
|
|
273
|
+
Star4Chance: import_koishi.Schema.number().description("4星概率").default(0.12),
|
|
274
|
+
Star5Name: import_koishi.Schema.string().description("5星名称").default("UR"),
|
|
275
|
+
Star5Chance: import_koishi.Schema.number().description("5星概率").default(0.04)
|
|
276
|
+
}).description("抽卡配置");
|
|
252
277
|
|
|
253
|
-
// src/
|
|
254
|
-
var
|
|
255
|
-
|
|
278
|
+
// src/common/at.ts
|
|
279
|
+
var import_koishi2 = require("koishi");
|
|
280
|
+
function At(argv, newLine = true) {
|
|
281
|
+
let AtStr = argv.session && !argv.session.isDirect ? `${import_koishi2.segment.at(argv.session.userId)}${newLine ? "\r\n" : ""}` : "";
|
|
282
|
+
return AtStr;
|
|
283
|
+
}
|
|
284
|
+
__name(At, "At");
|
|
285
|
+
|
|
286
|
+
// src/draw/index.ts
|
|
287
|
+
var name = "cafe-bot-exp.draw";
|
|
256
288
|
var inject = ["http"];
|
|
257
|
-
var
|
|
258
|
-
"喵呀呜~ ",
|
|
259
|
-
"喵呀~呵",
|
|
260
|
-
// 走这边。(带路时)
|
|
261
|
-
"喵呀~~噢",
|
|
262
|
-
// 说得没错。就是这样。
|
|
263
|
-
"喵呀~嘎~",
|
|
264
|
-
// 高兴的表现。
|
|
265
|
-
"喵呀~~呵",
|
|
266
|
-
// 稍等一下。(引起注意)
|
|
267
|
-
"喵嘎",
|
|
268
|
-
// 爪子痒痒了。(焦躁不安)
|
|
269
|
-
"喵嘎~~ ",
|
|
270
|
-
// 肚子饿了。
|
|
271
|
-
"喵嘎呜~~",
|
|
272
|
-
// 警戒的表现。
|
|
273
|
-
"喵呜",
|
|
274
|
-
// 困了。乏了。累了。
|
|
275
|
-
"喵呜?",
|
|
276
|
-
// 您是哪位?
|
|
277
|
-
"喵呜—",
|
|
278
|
-
// 是的。
|
|
279
|
-
"喵噢?",
|
|
280
|
-
// 怎么了?
|
|
281
|
-
"喵—噢",
|
|
282
|
-
// 呦,又见面了。 (短期内再会时的招呼)
|
|
283
|
-
"喵—呵",
|
|
284
|
-
// 好久不见了。还好吗?
|
|
285
|
-
"喵~呜",
|
|
286
|
-
// 再见
|
|
287
|
-
"喵~噢",
|
|
288
|
-
// 是,就是这样。(强烈肯定)
|
|
289
|
-
"喵~~呵",
|
|
290
|
-
// 你好。
|
|
291
|
-
"呜咪嘎~ ",
|
|
292
|
-
// 打哈欠。
|
|
293
|
-
"咪呜?",
|
|
294
|
-
// 你说什么?(听到坏话反问的语气)
|
|
295
|
-
"咪~呜 ",
|
|
296
|
-
// 肚子饿了。(幼猫语)
|
|
297
|
-
"咪~~呵"
|
|
298
|
-
// 对不起
|
|
299
|
-
];
|
|
289
|
+
var Config = CafeBotDrawConfig;
|
|
300
290
|
var animals = ["瑟蕾奴", "可鲁贝洛斯", "捷欧", "基库", "蔡特", "柯贝", "古利亚诺斯", "小星", "影良", "fio", "xeros"];
|
|
301
|
-
var starEnum = [
|
|
302
|
-
|
|
303
|
-
4,
|
|
304
|
-
3,
|
|
305
|
-
2,
|
|
306
|
-
1
|
|
307
|
-
];
|
|
291
|
+
var starEnum = [5, 4, 3, 2, 1];
|
|
292
|
+
var cafebotCardData = [];
|
|
308
293
|
function shuffleWithCustomRandom(array, rand) {
|
|
309
294
|
for (let i = array.length - 1; i > 0; i--) {
|
|
310
295
|
const a = rand();
|
|
@@ -319,7 +304,7 @@ async function downloadCardDataIfNotExist(ctx, config) {
|
|
|
319
304
|
if (cafebotCardData != null && cafebotCardData.length > 0) {
|
|
320
305
|
return;
|
|
321
306
|
}
|
|
322
|
-
const root = path.join(ctx.baseDir, "data",
|
|
307
|
+
const root = path.join(ctx.baseDir, "data", `${name}-data`);
|
|
323
308
|
await fs.mkdir(root, { recursive: true });
|
|
324
309
|
const cardFilePath = path.join(root, "card.json");
|
|
325
310
|
var a = await (0, import_fs_promises.default)(cardFilePath);
|
|
@@ -393,16 +378,7 @@ async function getCards(seed, ctx, config) {
|
|
|
393
378
|
return result;
|
|
394
379
|
}
|
|
395
380
|
__name(getCards, "getCards");
|
|
396
|
-
function At(argv, newLine = true) {
|
|
397
|
-
let AtStr = argv.session && !argv.session.isDirect ? `${import_koishi2.segment.at(argv.session.userId)}${newLine ? "\r\n" : ""}` : "";
|
|
398
|
-
return AtStr;
|
|
399
|
-
}
|
|
400
|
-
__name(At, "At");
|
|
401
381
|
async function apply(ctx, config) {
|
|
402
|
-
downloadCardDataIfNotExist(ctx, config);
|
|
403
|
-
ctx.command("关于", "about").action(async (argv, _) => {
|
|
404
|
-
argv.session?.send(`我是轨迹Cafe群聊机器人概念版~`);
|
|
405
|
-
});
|
|
406
382
|
ctx.command("轨迹抽卡/给我抽", "进行每日抽卡").action(async (argv, _) => {
|
|
407
383
|
let seed = DailySeededName(argv.session.userId);
|
|
408
384
|
console.log(`getcard for ${seed}`);
|
|
@@ -481,17 +457,156 @@ async function apply(ctx, config) {
|
|
|
481
457
|
});
|
|
482
458
|
return;
|
|
483
459
|
});
|
|
460
|
+
}
|
|
461
|
+
__name(apply, "apply");
|
|
462
|
+
|
|
463
|
+
// src/cat/index.ts
|
|
464
|
+
var cat_exports = {};
|
|
465
|
+
__export(cat_exports, {
|
|
466
|
+
Config: () => Config2,
|
|
467
|
+
apply: () => apply2,
|
|
468
|
+
name: () => name2
|
|
469
|
+
});
|
|
470
|
+
var import_koishi4 = require("koishi");
|
|
471
|
+
|
|
472
|
+
// src/cat/config.ts
|
|
473
|
+
var import_koishi3 = require("koishi");
|
|
474
|
+
var CafeBotCatConfig = import_koishi3.Schema.object({
|
|
475
|
+
catName: import_koishi3.Schema.string().description("名称/占位").default("柯贝")
|
|
476
|
+
}).description("猫猫配置");
|
|
477
|
+
|
|
478
|
+
// src/cat/index.ts
|
|
479
|
+
var name2 = "cafe-bot-exp.cat";
|
|
480
|
+
var Config2 = CafeBotCatConfig;
|
|
481
|
+
var catWords = [
|
|
482
|
+
"喵呀呜~ ",
|
|
483
|
+
"喵呀~呵",
|
|
484
|
+
// 走这边。(带路时)
|
|
485
|
+
"喵呀~~噢",
|
|
486
|
+
// 说得没错。就是这样。
|
|
487
|
+
"喵呀~嘎~",
|
|
488
|
+
// 高兴的表现。
|
|
489
|
+
"喵呀~~呵",
|
|
490
|
+
// 稍等一下。(引起注意)
|
|
491
|
+
"喵嘎",
|
|
492
|
+
// 爪子痒痒了。(焦躁不安)
|
|
493
|
+
"喵嘎~~ ",
|
|
494
|
+
// 肚子饿了。
|
|
495
|
+
"喵嘎呜~~",
|
|
496
|
+
// 警戒的表现。
|
|
497
|
+
"喵呜",
|
|
498
|
+
// 困了。乏了。累了。
|
|
499
|
+
"喵呜?",
|
|
500
|
+
// 您是哪位?
|
|
501
|
+
"喵呜—",
|
|
502
|
+
// 是的。
|
|
503
|
+
"喵噢?",
|
|
504
|
+
// 怎么了?
|
|
505
|
+
"喵—噢",
|
|
506
|
+
// 呦,又见面了。 (短期内再会时的招呼)
|
|
507
|
+
"喵—呵",
|
|
508
|
+
// 好久不见了。还好吗?
|
|
509
|
+
"喵~呜",
|
|
510
|
+
// 再见
|
|
511
|
+
"喵~噢",
|
|
512
|
+
// 是,就是这样。(强烈肯定)
|
|
513
|
+
"喵~~呵",
|
|
514
|
+
// 你好。
|
|
515
|
+
"呜咪嘎~ ",
|
|
516
|
+
// 打哈欠。
|
|
517
|
+
"咪呜?",
|
|
518
|
+
// 你说什么?(听到坏话反问的语气)
|
|
519
|
+
"咪~呜 ",
|
|
520
|
+
// 肚子饿了。(幼猫语)
|
|
521
|
+
"咪~~呵"
|
|
522
|
+
// 对不起
|
|
523
|
+
];
|
|
524
|
+
async function apply2(ctx) {
|
|
484
525
|
ctx.command("黑猫柯贝/摸猫", "摸摸柯贝").action(async (argv, _) => {
|
|
485
|
-
const random = new
|
|
526
|
+
const random = new import_koishi4.Random(() => Math.random());
|
|
486
527
|
let catWord = random.pick(catWords);
|
|
487
528
|
argv.session?.send(`${At(argv)}🐱:${catWord}`);
|
|
488
529
|
});
|
|
489
530
|
}
|
|
490
|
-
__name(
|
|
531
|
+
__name(apply2, "apply");
|
|
532
|
+
|
|
533
|
+
// src/quiz/index.ts
|
|
534
|
+
var quiz_exports = {};
|
|
535
|
+
__export(quiz_exports, {
|
|
536
|
+
Config: () => Config3,
|
|
537
|
+
apply: () => apply3,
|
|
538
|
+
inject: () => inject2,
|
|
539
|
+
name: () => name3
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
// src/quiz/config.ts
|
|
543
|
+
var import_koishi5 = require("koishi");
|
|
544
|
+
var CafeBotQuizConfig = import_koishi5.Schema.object({
|
|
545
|
+
baseQuizUrl: import_koishi5.Schema.string().description("答题数据 Url").default("https://www.azimiao.com/quiz.json"),
|
|
546
|
+
maxQuizPerDay: import_koishi5.Schema.number().description("每日单人最大答题数").default(5),
|
|
547
|
+
redisServer: import_koishi5.Schema.string().description("redis服务器地址"),
|
|
548
|
+
// TODO: 计划: 分数存储使用 sqlite, 临时数据(如当前题目)用内存就行了?
|
|
549
|
+
redisAuth: import_koishi5.Schema.string().description("redis服务器密码")
|
|
550
|
+
}).description("答题配置");
|
|
551
|
+
|
|
552
|
+
// src/quiz/index.ts
|
|
553
|
+
var name3 = "cafe-bot-exp.quiz";
|
|
554
|
+
var inject2 = ["http"];
|
|
555
|
+
var Config3 = CafeBotQuizConfig;
|
|
556
|
+
var validOptions = {
|
|
557
|
+
"A": 0,
|
|
558
|
+
"B": 1,
|
|
559
|
+
"C": 2,
|
|
560
|
+
"D": 3,
|
|
561
|
+
"a": 0,
|
|
562
|
+
"b": 1,
|
|
563
|
+
"c": 2,
|
|
564
|
+
"d": 3,
|
|
565
|
+
"1": 0,
|
|
566
|
+
"2": 1,
|
|
567
|
+
"3": 2,
|
|
568
|
+
"4": 3
|
|
569
|
+
};
|
|
570
|
+
async function apply3(ctx, config) {
|
|
571
|
+
ctx.command("轨迹答题/出题").action(async (argv, _) => {
|
|
572
|
+
await argv.session?.send("开发中");
|
|
573
|
+
return;
|
|
574
|
+
});
|
|
575
|
+
ctx.command("轨迹答题/回答 <answer:text>", `使用"回答+选项"回答问题,如"回答 A"`).action(async (argv, answer) => {
|
|
576
|
+
await argv.session?.send("开发中");
|
|
577
|
+
return;
|
|
578
|
+
let selectNumber = -1;
|
|
579
|
+
if (answer in validOptions) {
|
|
580
|
+
selectNumber = validOptions[answer];
|
|
581
|
+
} else {
|
|
582
|
+
argv.session?.send(`${At(argv)}回答错误~`);
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
__name(apply3, "apply");
|
|
587
|
+
|
|
588
|
+
// src/config.ts
|
|
589
|
+
var import_koishi6 = require("koishi");
|
|
590
|
+
var Config4 = import_koishi6.Schema.intersect([
|
|
591
|
+
CafeBotDrawConfig.collapse(),
|
|
592
|
+
CafeBotQuizConfig.collapse(),
|
|
593
|
+
CafeBotCatConfig.collapse()
|
|
594
|
+
]);
|
|
595
|
+
|
|
596
|
+
// src/index.ts
|
|
597
|
+
var name4 = "cafe-bot-exp";
|
|
598
|
+
async function apply4(ctx, config) {
|
|
599
|
+
ctx.plugin(draw_exports, config);
|
|
600
|
+
ctx.plugin(quiz_exports, config);
|
|
601
|
+
ctx.plugin(cat_exports, config);
|
|
602
|
+
ctx.command("关于", "about").action(async (argv, _) => {
|
|
603
|
+
argv.session?.send(`我是轨迹Cafe群聊机器人概念版~`);
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
__name(apply4, "apply");
|
|
491
607
|
// Annotate the CommonJS export names for ESM import in node:
|
|
492
608
|
0 && (module.exports = {
|
|
493
609
|
Config,
|
|
494
610
|
apply,
|
|
495
|
-
inject,
|
|
496
611
|
name
|
|
497
612
|
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 轨迹答题配置
|
|
3
|
+
*/
|
|
4
|
+
import { Schema } from "koishi";
|
|
5
|
+
export interface CafeBotQuizConfig {
|
|
6
|
+
baseQuizUrl: string;
|
|
7
|
+
maxQuizPerDay: number;
|
|
8
|
+
redisServer: string;
|
|
9
|
+
redisAuth: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const CafeBotQuizConfig: Schema<CafeBotQuizConfig>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 轨迹答题
|
|
3
|
+
*/
|
|
4
|
+
import { Context, Schema } from 'koishi';
|
|
5
|
+
import { CafeBotQuizConfig } from './config';
|
|
6
|
+
export declare const name = "cafe-bot-exp.quiz";
|
|
7
|
+
export declare const inject: string[];
|
|
8
|
+
export interface Config extends CafeBotQuizConfig {
|
|
9
|
+
}
|
|
10
|
+
export declare const Config: Schema<Config>;
|
|
11
|
+
export declare function apply(ctx: Context, config: Config): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azimiao/koishi-plugin-cafe-bot-exp",
|
|
3
3
|
"description": "cafe bot experiment",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/Azimiao/koishi-plugin-cafe-bot-exp.git"
|
|
10
|
+
},
|
|
11
|
+
"author": {
|
|
12
|
+
"name": "WildRabbit",
|
|
13
|
+
"email": "admin@azimao.com",
|
|
14
|
+
"url": "https://www.azimiao.com"
|
|
15
|
+
},
|
|
7
16
|
"files": [
|
|
8
17
|
"lib",
|
|
9
18
|
"dist"
|
|
@@ -19,7 +28,7 @@
|
|
|
19
28
|
},
|
|
20
29
|
"koishi": {
|
|
21
30
|
"description": {
|
|
22
|
-
"zh": "轨迹
|
|
31
|
+
"zh": "轨迹CafeBot概念版"
|
|
23
32
|
},
|
|
24
33
|
"service": {
|
|
25
34
|
"required": [
|
|
@@ -35,4 +44,4 @@
|
|
|
35
44
|
"@stdlib/random-base-uniform": "^0.2.1",
|
|
36
45
|
"fs.promises.exists": "^1.1.4"
|
|
37
46
|
}
|
|
38
|
-
}
|
|
47
|
+
}
|
package/readme.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# koishi-plugin-cafe-bot-exp
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/koishi-plugin-cafe-bot-exp)
|
|
3
|
+
[](https://www.npmjs.com/package/@azimiao/koishi-plugin-cafe-bot-exp)
|
|
4
4
|
|
|
5
5
|
cafe bot experiment
|