koishi-plugin-cocoyyy-console 1.0.10 → 1.0.12-beta.0
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 +1 -1
- package/lib/index.js +538 -72
- package/lib/infra/redis_init.d.ts +4 -0
- package/lib/models/kuro_user.d.ts +23 -0
- package/lib/services/kuro_func/kuro_commands.d.ts +3 -0
- package/lib/services/kuro_func/kuro_db_service.d.ts +5 -0
- package/lib/services/kuro_func/kuro_service.d.ts +25 -0
- package/lib/utils/config.d.ts +1 -1
- package/lib/utils/configs/function_config.d.ts +1 -0
- package/lib/utils/configs/mysql_config.d.ts +1 -2
- package/lib/utils/configs/redis_config.d.ts +6 -0
- package/package.json +5 -2
- package/lib/services/img_service.d.ts +0 -8
- package/lib/services/rbq_func/random_temp.d.ts +0 -0
- package/lib/services/repeat_func/repeat_temp.d.ts +0 -1
- package/lib/services/tag_service.d.ts +0 -20
package/lib/index.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ export declare const name = "cocoyyy-console";
|
|
|
4
4
|
export declare let dev_mode: boolean;
|
|
5
5
|
export interface Config {
|
|
6
6
|
function_config?: my_config.FunctionConfig;
|
|
7
|
+
redis_config?: my_config.RedisConfig;
|
|
7
8
|
mysql_config?: my_config.MysqlConfig;
|
|
8
9
|
tag_config?: my_config.SaveConfig;
|
|
9
10
|
repeat_config?: my_config.RepeatConfig;
|
|
10
|
-
rbq_config?: my_config.RbqConfig;
|
|
11
11
|
}
|
|
12
12
|
export declare const Config: Schema<Config>;
|
|
13
13
|
export declare let logger: Logger;
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
8
|
var __export = (target, all) => {
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -36,7 +46,8 @@ var FunctionConfigSchema = import_koishi.Schema.object({
|
|
|
36
46
|
dev_mode: import_koishi.Schema.boolean().default(false).description("开发测试模式"),
|
|
37
47
|
tag_flag: import_koishi.Schema.boolean().default(true).description("标签功能是否启用"),
|
|
38
48
|
repeat_flag: import_koishi.Schema.boolean().default(true).description("复读功能是否启用"),
|
|
39
|
-
rbq_flag: import_koishi.Schema.boolean().default(true).description("*人功能是否启用")
|
|
49
|
+
rbq_flag: import_koishi.Schema.boolean().default(true).description("*人功能是否启用"),
|
|
50
|
+
kuro_flag: import_koishi.Schema.boolean().default(true).description("鸣潮功能是否启用")
|
|
40
51
|
});
|
|
41
52
|
|
|
42
53
|
// src/utils/configs/mysql_config.ts
|
|
@@ -48,16 +59,6 @@ var MysqlConfigSchema = import_koishi2.Schema.object({
|
|
|
48
59
|
password: import_koishi2.Schema.string().role("secret").default("").description("密码"),
|
|
49
60
|
database: import_koishi2.Schema.string().default("test").description("数据库名")
|
|
50
61
|
});
|
|
51
|
-
function loadMysqlConfigFromEnv(env = process.env) {
|
|
52
|
-
return {
|
|
53
|
-
host: env.MYSQL_HOST || "127.0.0.1",
|
|
54
|
-
port: Number(env.MYSQL_PORT || 3306),
|
|
55
|
-
user: env.MYSQL_USER || "root",
|
|
56
|
-
password: env.MYSQL_PASSWORD || "",
|
|
57
|
-
database: env.MYSQL_DATABASE || "test"
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
__name(loadMysqlConfigFromEnv, "loadMysqlConfigFromEnv");
|
|
61
62
|
|
|
62
63
|
// src/utils/configs/tag_config.ts
|
|
63
64
|
var import_koishi3 = require("koishi");
|
|
@@ -79,22 +80,17 @@ var RepeatConfigSchema = import_koishi4.Schema.object({
|
|
|
79
80
|
resetInterval: import_koishi4.Schema.number().default(300).description("过期秒数")
|
|
80
81
|
});
|
|
81
82
|
|
|
82
|
-
// src/utils/configs/
|
|
83
|
+
// src/utils/configs/redis_config.ts
|
|
83
84
|
var import_koishi5 = require("koishi");
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
probability: import_koishi5.Schema.number().default(1).description("触发概率[0-1]"),
|
|
87
|
-
guild_id: import_koishi5.Schema.string().default("").description("触发群聊id"),
|
|
88
|
-
uid: import_koishi5.Schema.string().default("").description("触发用户id"),
|
|
89
|
-
content: import_koishi5.Schema.string().default("*死你").description("触发内容")
|
|
90
|
-
})).description("触发配置")
|
|
85
|
+
var RedisConfigSchema = import_koishi5.Schema.object({
|
|
86
|
+
redis_url: import_koishi5.Schema.string().default("127.0.0.1:6379").description("Redis连接字符串")
|
|
91
87
|
});
|
|
92
88
|
|
|
93
89
|
// src/infra/mysql_init.ts
|
|
94
90
|
var import_sequelize = require("sequelize");
|
|
95
91
|
var sequelize = null;
|
|
96
92
|
function initSequelize(cfg) {
|
|
97
|
-
const conf = cfg
|
|
93
|
+
const conf = cfg;
|
|
98
94
|
sequelize = new import_sequelize.Sequelize(conf.database, conf.user, conf.password, {
|
|
99
95
|
host: conf.host,
|
|
100
96
|
port: conf.port,
|
|
@@ -129,12 +125,6 @@ var TagsModel = class extends import_sequelize2.Model {
|
|
|
129
125
|
static {
|
|
130
126
|
__name(this, "TagsModel");
|
|
131
127
|
}
|
|
132
|
-
id;
|
|
133
|
-
tags;
|
|
134
|
-
alias;
|
|
135
|
-
guild_id;
|
|
136
|
-
status;
|
|
137
|
-
createtime;
|
|
138
128
|
};
|
|
139
129
|
var inited = false;
|
|
140
130
|
function getTagsModel() {
|
|
@@ -202,11 +192,6 @@ var ImgsModel = class extends import_sequelize3.Model {
|
|
|
202
192
|
static {
|
|
203
193
|
__name(this, "ImgsModel");
|
|
204
194
|
}
|
|
205
|
-
id;
|
|
206
|
-
tag_id;
|
|
207
|
-
img_url;
|
|
208
|
-
status;
|
|
209
|
-
createtime;
|
|
210
195
|
};
|
|
211
196
|
var inited2 = false;
|
|
212
197
|
function getImgsModel() {
|
|
@@ -304,6 +289,11 @@ var menuList = [
|
|
|
304
289
|
name: "rbq",
|
|
305
290
|
description: "*人功能,用于*人",
|
|
306
291
|
command: "无"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
name: "kuro",
|
|
295
|
+
description: "库洛相关功能,用于鸣潮相关功能",
|
|
296
|
+
command: "无"
|
|
307
297
|
}
|
|
308
298
|
];
|
|
309
299
|
function getMenuList(command = null, functionConfig) {
|
|
@@ -323,6 +313,10 @@ function getMenuList(command = null, functionConfig) {
|
|
|
323
313
|
if (!functionConfig.rbq_flag)
|
|
324
314
|
return "*人功能已关闭";
|
|
325
315
|
return getRbqFuncMenu(command);
|
|
316
|
+
case "kuro":
|
|
317
|
+
if (!functionConfig.kuro_flag)
|
|
318
|
+
return "库洛相关功能已关闭";
|
|
319
|
+
return getKuroFuncMenu(command);
|
|
326
320
|
default:
|
|
327
321
|
return `[所有命令都需要@bot]
|
|
328
322
|
当前可用功能列表:
|
|
@@ -409,6 +403,25 @@ function getRbqFuncMenu(command = null) {
|
|
|
409
403
|
输入对应指令使用*人功能,如果遇到问题请联系开发人员。`;
|
|
410
404
|
}
|
|
411
405
|
__name(getRbqFuncMenu, "getRbqFuncMenu");
|
|
406
|
+
var kuroFuncMenuList = [
|
|
407
|
+
{
|
|
408
|
+
name: "login",
|
|
409
|
+
description: "库街区登录",
|
|
410
|
+
command: "login [手机号] [验证码]"
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
name: "signin",
|
|
414
|
+
description: "库街区签到",
|
|
415
|
+
command: "signin"
|
|
416
|
+
}
|
|
417
|
+
];
|
|
418
|
+
function getKuroFuncMenu(command = null) {
|
|
419
|
+
return `[所有命令都需要@bot]
|
|
420
|
+
库洛相关功能菜单:
|
|
421
|
+
${kuroFuncMenuList.map((item) => item.command + ": " + item.description).join("\n ")}
|
|
422
|
+
输入对应指令使用库洛相关功能,如果遇到问题请联系开发人员。`;
|
|
423
|
+
}
|
|
424
|
+
__name(getKuroFuncMenu, "getKuroFuncMenu");
|
|
412
425
|
function registerMenuCommands(ctx, connected, functionConfig) {
|
|
413
426
|
ctx.command("help <参数>", "帮助菜单").action(async ({ session }, ...args) => {
|
|
414
427
|
if (!dev_mode) {
|
|
@@ -901,10 +914,6 @@ var RbqPersonModel = class extends import_sequelize5.Model {
|
|
|
901
914
|
static {
|
|
902
915
|
__name(this, "RbqPersonModel");
|
|
903
916
|
}
|
|
904
|
-
id;
|
|
905
|
-
guild_id;
|
|
906
|
-
uid_list;
|
|
907
|
-
createtime;
|
|
908
917
|
};
|
|
909
918
|
var inited3 = false;
|
|
910
919
|
function getRbqPersonModel() {
|
|
@@ -964,11 +973,6 @@ var RbqContentModel = class extends import_sequelize6.Model {
|
|
|
964
973
|
static {
|
|
965
974
|
__name(this, "RbqContentModel");
|
|
966
975
|
}
|
|
967
|
-
id;
|
|
968
|
-
guild_id;
|
|
969
|
-
content;
|
|
970
|
-
tag_uid;
|
|
971
|
-
createtime;
|
|
972
976
|
};
|
|
973
977
|
var inited4 = false;
|
|
974
978
|
function getRbqContentModel() {
|
|
@@ -1189,23 +1193,19 @@ __name(create_content, "create_content");
|
|
|
1189
1193
|
async function get_content_list(guild_id, tar_uid) {
|
|
1190
1194
|
try {
|
|
1191
1195
|
const RbqContent = getRbqContentModel();
|
|
1196
|
+
const whereBase = { guild_id };
|
|
1192
1197
|
const existed = await RbqContent.findAll({
|
|
1193
|
-
where: {
|
|
1194
|
-
guild_id,
|
|
1195
|
-
tag_uid: null
|
|
1196
|
-
}
|
|
1198
|
+
where: { ...whereBase, tag_uid: null }
|
|
1197
1199
|
});
|
|
1198
|
-
let result_list =
|
|
1200
|
+
let result_list = existed.map((item) => item.get("content")).filter(Boolean);
|
|
1199
1201
|
result_list.push(...existed.map((item) => item.get("content")).filter(Boolean));
|
|
1200
1202
|
if (tar_uid) {
|
|
1201
1203
|
const tar_existed = await RbqContent.findAll({
|
|
1202
|
-
where: {
|
|
1203
|
-
guild_id,
|
|
1204
|
-
tag_uid: tar_uid
|
|
1205
|
-
}
|
|
1204
|
+
where: { ...whereBase, tag_uid: tar_uid }
|
|
1206
1205
|
});
|
|
1207
1206
|
result_list.push(...tar_existed.map((item) => item.get("content")).filter(Boolean));
|
|
1208
1207
|
}
|
|
1208
|
+
result_list = Array.from(new Set(result_list.map((s) => s.trim()).filter((s) => s.length > 0)));
|
|
1209
1209
|
return result_list;
|
|
1210
1210
|
} catch (e) {
|
|
1211
1211
|
logger.error("[get_content_list Error]: " + e?.message || String(e));
|
|
@@ -1222,9 +1222,14 @@ function registerRbqCommands(ctx, connected) {
|
|
|
1222
1222
|
if (!connected) return;
|
|
1223
1223
|
if (!is_at_bot(session)) return;
|
|
1224
1224
|
}
|
|
1225
|
-
const
|
|
1226
|
-
return
|
|
1227
|
-
|
|
1225
|
+
const guildId = session.guildId;
|
|
1226
|
+
if (!guildId) return "无法获取群号";
|
|
1227
|
+
const list = await get_person_list(guildId);
|
|
1228
|
+
if (!list || list.length === 0) {
|
|
1229
|
+
return "当前群聊还没有设置任何rbq";
|
|
1230
|
+
}
|
|
1231
|
+
return `当前群聊rbq列表:
|
|
1232
|
+
${list.map((item) => (0, import_koishi8.h)("at", { id: item })).join(",")}`;
|
|
1228
1233
|
});
|
|
1229
1234
|
ctx.command("rbqadd <参数>", "添加rbq").action(async ({ session }, ...args) => {
|
|
1230
1235
|
if (!dev_mode) {
|
|
@@ -1241,8 +1246,8 @@ ${list.join(",")}`;
|
|
|
1241
1246
|
}
|
|
1242
1247
|
exec = await create_person(session.guildId, uid);
|
|
1243
1248
|
if (!exec.result)
|
|
1244
|
-
return `添加rbq
|
|
1245
|
-
return `已添加rbq
|
|
1249
|
+
return `添加rbq失败: ${exec.error}`;
|
|
1250
|
+
return `已添加rbq: ${(0, import_koishi8.h)("at", { id: uid })}`;
|
|
1246
1251
|
});
|
|
1247
1252
|
ctx.command("rbqinstead <参数>", "替换rbq").action(async ({ session }, ...args) => {
|
|
1248
1253
|
if (!dev_mode) {
|
|
@@ -1301,7 +1306,7 @@ ${list.join(",")}`;
|
|
|
1301
1306
|
let content = "*死你";
|
|
1302
1307
|
if (contents && contents.length > 0) {
|
|
1303
1308
|
const random = new import_koishi8.Random(() => Math.random());
|
|
1304
|
-
content = contents[random.int(0, contents.length
|
|
1309
|
+
content = contents[random.int(0, contents.length)];
|
|
1305
1310
|
}
|
|
1306
1311
|
return (0, import_koishi8.h)("at", { id: matchedUid }) + " " + content;
|
|
1307
1312
|
} catch (error) {
|
|
@@ -1313,53 +1318,512 @@ ${list.join(",")}`;
|
|
|
1313
1318
|
__name(registerRbqCommands, "registerRbqCommands");
|
|
1314
1319
|
|
|
1315
1320
|
// src/services/test_command.ts
|
|
1321
|
+
var import_axios = __toESM(require("axios"));
|
|
1322
|
+
var import_qs = __toESM(require("qs"));
|
|
1323
|
+
var userMap = /* @__PURE__ */ new Map();
|
|
1316
1324
|
function registerTestCommands(ctx) {
|
|
1317
|
-
ctx.command("test <参数>", "
|
|
1318
|
-
if (!
|
|
1319
|
-
const bot = ctx.bots[session.uid] || Object.values(ctx.bots)[0];
|
|
1320
|
-
if (!bot) return "未找到可用的机器人实例";
|
|
1321
|
-
if (bot.platform !== "onebot") return "当前平台不支持该操作";
|
|
1325
|
+
ctx.command("test <参数>", "test").action(async ({ session }, phoneNumber, code) => {
|
|
1326
|
+
if (!phoneNumber || !code) return "请提供手机号和验证码";
|
|
1322
1327
|
try {
|
|
1323
|
-
const
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1328
|
+
const token = await getToken(phoneNumber, code);
|
|
1329
|
+
if (token.status) {
|
|
1330
|
+
return `验证码登录成功,库街区用户: ${token.data.userName}`;
|
|
1331
|
+
} else {
|
|
1332
|
+
return `验证码登录失败: ${token.msg}`;
|
|
1327
1333
|
}
|
|
1328
|
-
const ids = members.map((m) => m.user?.id).filter(Boolean).join("\n");
|
|
1329
|
-
console.log(`[群 ${guildId}] 成员数量: ${members.length}`);
|
|
1330
|
-
return `群 ${guildId} 共 ${members.length} 位成员:
|
|
1331
|
-
${ids}`;
|
|
1332
1334
|
} catch (err) {
|
|
1333
1335
|
console.error(err);
|
|
1334
|
-
return
|
|
1336
|
+
return `test error: ${err.message}`;
|
|
1337
|
+
}
|
|
1338
|
+
});
|
|
1339
|
+
ctx.command("getuser <参数>", "getuser").action(async ({ session }, mobile) => {
|
|
1340
|
+
if (!mobile) return "请提供手机号";
|
|
1341
|
+
const user = userMap.get(mobile);
|
|
1342
|
+
if (user) {
|
|
1343
|
+
return `库街区用户: ${JSON.stringify(user)}`;
|
|
1344
|
+
} else {
|
|
1345
|
+
return `库街区用户不存在`;
|
|
1335
1346
|
}
|
|
1336
1347
|
});
|
|
1337
1348
|
}
|
|
1338
1349
|
__name(registerTestCommands, "registerTestCommands");
|
|
1350
|
+
var CONSTANTS = {
|
|
1351
|
+
REQUEST_HEADERS_BASE: {
|
|
1352
|
+
"source": "ios"
|
|
1353
|
+
}
|
|
1354
|
+
};
|
|
1355
|
+
async function getToken(mobile, code) {
|
|
1356
|
+
const devCode = [...Array(40)].map(() => "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.random() * 36 | 0]).join("");
|
|
1357
|
+
let data = import_qs.default.stringify({
|
|
1358
|
+
mobile,
|
|
1359
|
+
code
|
|
1360
|
+
});
|
|
1361
|
+
try {
|
|
1362
|
+
const response = await import_axios.default.post("https://api.kurobbs.com/user/sdkLogin", data, { headers: { ...CONSTANTS.REQUEST_HEADERS_BASE, devCode } });
|
|
1363
|
+
if (response.data.code === 200) {
|
|
1364
|
+
userMap.set(mobile, response.data.data);
|
|
1365
|
+
logger.info(`验证码登录成功,库街区用户: ${response.data.data.userName}`);
|
|
1366
|
+
return { status: true, data: response.data.data };
|
|
1367
|
+
} else {
|
|
1368
|
+
logger.error(`验证码登录失败: ${response.data.msg}`);
|
|
1369
|
+
return { status: false, msg: response.data.msg };
|
|
1370
|
+
}
|
|
1371
|
+
} catch (error) {
|
|
1372
|
+
logger.error(`验证码登录失败,疑似网络问题: ${error}`);
|
|
1373
|
+
return { status: false, msg: "登录失败,疑似网络问题,请检查控制台日志" };
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
__name(getToken, "getToken");
|
|
1377
|
+
|
|
1378
|
+
// src/infra/redis_init.ts
|
|
1379
|
+
var import_ioredis = __toESM(require("ioredis"));
|
|
1380
|
+
var redis;
|
|
1381
|
+
function init_redis(config) {
|
|
1382
|
+
try {
|
|
1383
|
+
if (!redis) {
|
|
1384
|
+
redis = new import_ioredis.default(config.redis_url);
|
|
1385
|
+
}
|
|
1386
|
+
redis.ping();
|
|
1387
|
+
logger.info("redis连接成功");
|
|
1388
|
+
return true;
|
|
1389
|
+
} catch (error) {
|
|
1390
|
+
logger.error("redis连接失败: " + error);
|
|
1391
|
+
return false;
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
__name(init_redis, "init_redis");
|
|
1395
|
+
|
|
1396
|
+
// src/services/kuro_func/kuro_service.ts
|
|
1397
|
+
var import_axios2 = __toESM(require("axios"));
|
|
1398
|
+
var import_qs2 = __toESM(require("qs"));
|
|
1399
|
+
|
|
1400
|
+
// src/models/kuro_user.ts
|
|
1401
|
+
var import_sequelize8 = require("sequelize");
|
|
1402
|
+
var KuroUserModel = class extends import_sequelize8.Model {
|
|
1403
|
+
static {
|
|
1404
|
+
__name(this, "KuroUserModel");
|
|
1405
|
+
}
|
|
1406
|
+
};
|
|
1407
|
+
var inited5 = false;
|
|
1408
|
+
function getKuroUserModel() {
|
|
1409
|
+
const sequelize2 = getSequelize();
|
|
1410
|
+
if (!inited5) {
|
|
1411
|
+
KuroUserModel.init(
|
|
1412
|
+
{
|
|
1413
|
+
id: {
|
|
1414
|
+
type: import_sequelize8.DataTypes.INTEGER.UNSIGNED,
|
|
1415
|
+
allowNull: false,
|
|
1416
|
+
autoIncrement: true,
|
|
1417
|
+
primaryKey: true
|
|
1418
|
+
},
|
|
1419
|
+
qq_uid: {
|
|
1420
|
+
type: import_sequelize8.DataTypes.STRING(128),
|
|
1421
|
+
allowNull: false
|
|
1422
|
+
},
|
|
1423
|
+
user_id: {
|
|
1424
|
+
type: import_sequelize8.DataTypes.STRING(128),
|
|
1425
|
+
allowNull: false
|
|
1426
|
+
},
|
|
1427
|
+
user_name: {
|
|
1428
|
+
type: import_sequelize8.DataTypes.STRING(128),
|
|
1429
|
+
allowNull: false
|
|
1430
|
+
},
|
|
1431
|
+
role_id: {
|
|
1432
|
+
type: import_sequelize8.DataTypes.STRING(128),
|
|
1433
|
+
allowNull: true
|
|
1434
|
+
},
|
|
1435
|
+
server_id: {
|
|
1436
|
+
type: import_sequelize8.DataTypes.STRING(512),
|
|
1437
|
+
allowNull: true
|
|
1438
|
+
},
|
|
1439
|
+
token: {
|
|
1440
|
+
type: import_sequelize8.DataTypes.STRING(512),
|
|
1441
|
+
allowNull: true
|
|
1442
|
+
},
|
|
1443
|
+
updatetime: {
|
|
1444
|
+
type: import_sequelize8.DataTypes.DATE,
|
|
1445
|
+
allowNull: false,
|
|
1446
|
+
defaultValue: import_sequelize8.DataTypes.NOW,
|
|
1447
|
+
field: "updatetime",
|
|
1448
|
+
set(value) {
|
|
1449
|
+
if (typeof value === "number") {
|
|
1450
|
+
const ts = value > 1e12 ? value : value * 1e3;
|
|
1451
|
+
this.setDataValue("updatetime", new Date(ts));
|
|
1452
|
+
} else {
|
|
1453
|
+
this.setDataValue("updatetime", value);
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
},
|
|
1458
|
+
{
|
|
1459
|
+
sequelize: sequelize2,
|
|
1460
|
+
tableName: "kuro_user",
|
|
1461
|
+
modelName: "KuroUser",
|
|
1462
|
+
timestamps: false,
|
|
1463
|
+
underscored: false
|
|
1464
|
+
}
|
|
1465
|
+
);
|
|
1466
|
+
inited5 = true;
|
|
1467
|
+
}
|
|
1468
|
+
return KuroUserModel;
|
|
1469
|
+
}
|
|
1470
|
+
__name(getKuroUserModel, "getKuroUserModel");
|
|
1471
|
+
|
|
1472
|
+
// src/services/kuro_func/kuro_db_service.ts
|
|
1473
|
+
async function createUpdateUser(requestResult) {
|
|
1474
|
+
const KuroUser = getKuroUserModel();
|
|
1475
|
+
try {
|
|
1476
|
+
const user = await KuroUser.findOne({ where: { qq_uid: requestResult.qq_uid } });
|
|
1477
|
+
if (user) {
|
|
1478
|
+
user.user_id = requestResult.user_id;
|
|
1479
|
+
user.user_name = requestResult.user_name;
|
|
1480
|
+
user.role_id = requestResult.role_id;
|
|
1481
|
+
user.server_id = requestResult.server_id;
|
|
1482
|
+
user.token = requestResult.token;
|
|
1483
|
+
user.updatetime = new Date(Date.now() + 8 * 60 * 60 * 1e3);
|
|
1484
|
+
await user.save();
|
|
1485
|
+
} else {
|
|
1486
|
+
await KuroUser.create({
|
|
1487
|
+
qq_uid: requestResult.qq_uid,
|
|
1488
|
+
user_id: requestResult.user_id,
|
|
1489
|
+
user_name: requestResult.user_name,
|
|
1490
|
+
role_id: requestResult.role_id,
|
|
1491
|
+
server_id: requestResult.server_id,
|
|
1492
|
+
token: requestResult.token,
|
|
1493
|
+
updatetime: new Date(Date.now() + 8 * 60 * 60 * 1e3)
|
|
1494
|
+
});
|
|
1495
|
+
}
|
|
1496
|
+
return { status: true, msg: null };
|
|
1497
|
+
} catch (e) {
|
|
1498
|
+
logger.error(`[createUpdateUser Error]: ${e?.message || String(e)}`);
|
|
1499
|
+
return { status: false, msg: e?.message || String(e) };
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
__name(createUpdateUser, "createUpdateUser");
|
|
1503
|
+
|
|
1504
|
+
// src/services/kuro_func/kuro_service.ts
|
|
1505
|
+
var userTokenMap = /* @__PURE__ */ new Map();
|
|
1506
|
+
var CONSTANTS2 = {
|
|
1507
|
+
BASE_URL: "https://api.kurobbs.com",
|
|
1508
|
+
LOGIN_URL: "/user/sdkLogin",
|
|
1509
|
+
GAME_DATA_URL: "/gamer/role/list",
|
|
1510
|
+
REFRESH_URL: "/aki/roleBox/akiBox/refreshData",
|
|
1511
|
+
TOKEN_REFRESH_URL: "/aki/roleBox/requestToken",
|
|
1512
|
+
// GAME_DATA_URL: '/gamer/widget/game3/refresh',
|
|
1513
|
+
// BASE_DATA_URL: '/aki/roleBox/akiBox/baseData',
|
|
1514
|
+
ROLE_DATA_URL: "/aki/roleBox/akiBox/roleData",
|
|
1515
|
+
// CALABASH_DATA_URL: '/aki/roleBox/akiBox/calabashData',
|
|
1516
|
+
// CHALLENGE_DATA_URL: '/aki/roleBox/akiBox/challengeDetails',
|
|
1517
|
+
// EXPLORE_DATA_URL: '/aki/roleBox/akiBox/exploreIndex',
|
|
1518
|
+
SIGNIN_URL: "/encourage/signIn/v2",
|
|
1519
|
+
// QUERY_RECORD_URL: '/encourage/signIn/queryRecordV2',
|
|
1520
|
+
// GACHA_URL: 'https://gmserver-api.aki-game2.com/gacha/record/query',
|
|
1521
|
+
// INTL_GACHA_URL: 'https://gmserver-api.aki-game2.net/gacha/record/query',
|
|
1522
|
+
// ROLE_DETAIL_URL: '/aki/roleBox/akiBox/getRoleDetail',
|
|
1523
|
+
// EVENT_LIST_URL: '/forum/companyEvent/findEventList',
|
|
1524
|
+
// SELF_TOWER_DATA_URL: '/aki/roleBox/akiBox/towerDataDetail',
|
|
1525
|
+
// OTHER_TOWER_DATA_URL: '/aki/roleBox/akiBox/towerIndex',
|
|
1526
|
+
REQUEST_HEADERS_BASE: {
|
|
1527
|
+
"source": "ios"
|
|
1528
|
+
}
|
|
1529
|
+
};
|
|
1530
|
+
var wavesApi = import_axios2.default.create();
|
|
1531
|
+
wavesApi.interceptors.request.use(
|
|
1532
|
+
async (config) => {
|
|
1533
|
+
if (config.url.startsWith("/")) {
|
|
1534
|
+
config.url = CONSTANTS2.BASE_URL + config.url;
|
|
1535
|
+
}
|
|
1536
|
+
return config;
|
|
1537
|
+
},
|
|
1538
|
+
(error) => {
|
|
1539
|
+
return Promise.reject(error);
|
|
1540
|
+
}
|
|
1541
|
+
);
|
|
1542
|
+
async function init_userMap() {
|
|
1543
|
+
const KuroUser = getKuroUserModel();
|
|
1544
|
+
try {
|
|
1545
|
+
const existed = await KuroUser.findAll();
|
|
1546
|
+
if (!existed) return;
|
|
1547
|
+
existed.forEach(async (item) => {
|
|
1548
|
+
const qq_uid = item.get("qq_uid");
|
|
1549
|
+
const user_id = item.get("user_id");
|
|
1550
|
+
const user_name = item.get("user_name");
|
|
1551
|
+
const role_id = item.get("role_id");
|
|
1552
|
+
const server_id = item.get("server_id");
|
|
1553
|
+
const token = item.get("token");
|
|
1554
|
+
userTokenMap.set(qq_uid, { user_id, user_name, role_id, server_id, token, bat: null });
|
|
1555
|
+
});
|
|
1556
|
+
return true;
|
|
1557
|
+
} catch (e) {
|
|
1558
|
+
logger.error("[init_userMap Error]: " + e?.message || String(e));
|
|
1559
|
+
return false;
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
__name(init_userMap, "init_userMap");
|
|
1563
|
+
async function checkUserToken(qq_uid) {
|
|
1564
|
+
const userInfo = userTokenMap.get(qq_uid);
|
|
1565
|
+
if (!userInfo) {
|
|
1566
|
+
return null;
|
|
1567
|
+
}
|
|
1568
|
+
const available_response = await isAvailable(userInfo.server_id, userInfo.role_id, userInfo.token);
|
|
1569
|
+
if (!available_response.status) {
|
|
1570
|
+
return null;
|
|
1571
|
+
}
|
|
1572
|
+
userTokenMap.set(qq_uid, { ...userInfo, bat: available_response.data });
|
|
1573
|
+
return userInfo;
|
|
1574
|
+
}
|
|
1575
|
+
__name(checkUserToken, "checkUserToken");
|
|
1576
|
+
async function getToken2(session, mobile, code) {
|
|
1577
|
+
const existed = await checkUserToken(session.uid);
|
|
1578
|
+
if (existed) {
|
|
1579
|
+
return { status: true, data: existed };
|
|
1580
|
+
}
|
|
1581
|
+
const devCode = [...Array(40)].map(() => "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.random() * 36 | 0]).join("");
|
|
1582
|
+
let data = import_qs2.default.stringify({
|
|
1583
|
+
mobile,
|
|
1584
|
+
code
|
|
1585
|
+
});
|
|
1586
|
+
try {
|
|
1587
|
+
const user_response = await wavesApi.post(CONSTANTS2.LOGIN_URL, data, { headers: { ...CONSTANTS2.REQUEST_HEADERS_BASE, devCode } });
|
|
1588
|
+
if (user_response.data.code != 200) {
|
|
1589
|
+
logger.error(`验证码登录失败: ${user_response.data.msg}`);
|
|
1590
|
+
return { status: false, msg: user_response.data.msg };
|
|
1591
|
+
}
|
|
1592
|
+
const game_response = await getGameData(user_response.data.data.token);
|
|
1593
|
+
if (!game_response.status) {
|
|
1594
|
+
return { status: false, msg: game_response.msg };
|
|
1595
|
+
}
|
|
1596
|
+
if (game_response.data === null) {
|
|
1597
|
+
return { status: false, msg: "未检测到鸣潮信息" };
|
|
1598
|
+
}
|
|
1599
|
+
const available_response = await isAvailable(game_response.data.serverId, game_response.data.roleId, user_response.data.data.token);
|
|
1600
|
+
if (!available_response.status) {
|
|
1601
|
+
return { status: false, msg: available_response.msg };
|
|
1602
|
+
}
|
|
1603
|
+
const userInfo = {
|
|
1604
|
+
qq_uid: session.uid,
|
|
1605
|
+
user_id: user_response.data.data.userId,
|
|
1606
|
+
user_name: user_response.data.data.userName,
|
|
1607
|
+
role_id: game_response.data.roleId,
|
|
1608
|
+
server_id: game_response.data.serverId,
|
|
1609
|
+
token: user_response.data.data.token,
|
|
1610
|
+
bat: available_response.data
|
|
1611
|
+
};
|
|
1612
|
+
createUpdateUser(userInfo);
|
|
1613
|
+
userTokenMap.set(session.uid, userInfo);
|
|
1614
|
+
logger.info(`[getToken Info]: 验证码登录成功,库街区用户: ${user_response.data.data.userName}`);
|
|
1615
|
+
return { status: true, data: user_response.data.data };
|
|
1616
|
+
} catch (error) {
|
|
1617
|
+
logger.error(`[getToken Error]: ${error.message}`);
|
|
1618
|
+
return { status: false, msg: "疑似网络问题,请检查控制台日志" };
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
__name(getToken2, "getToken");
|
|
1622
|
+
async function getGameData(token) {
|
|
1623
|
+
try {
|
|
1624
|
+
let data = import_qs2.default.stringify({
|
|
1625
|
+
"gameId": 3
|
|
1626
|
+
});
|
|
1627
|
+
const response = await wavesApi.post(CONSTANTS2.GAME_DATA_URL, data, { headers: { ...CONSTANTS2.REQUEST_HEADERS_BASE, "token": token } });
|
|
1628
|
+
if (response.data.code === 200) {
|
|
1629
|
+
return { status: true, data: response.data.data[0] };
|
|
1630
|
+
} else {
|
|
1631
|
+
logger.error(`[getGameData Error]: ${response.data.msg}`);
|
|
1632
|
+
return { status: false, msg: response.data.msg };
|
|
1633
|
+
}
|
|
1634
|
+
} catch (error) {
|
|
1635
|
+
logger.error(`[getGameData Error]: ${error.message}`);
|
|
1636
|
+
return { status: false, msg: "疑似网络问题,请检查控制台日志" };
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
__name(getGameData, "getGameData");
|
|
1640
|
+
async function isAvailable(serverId, roleId, token) {
|
|
1641
|
+
let data = import_qs2.default.stringify({
|
|
1642
|
+
"serverId": serverId,
|
|
1643
|
+
"roleId": roleId
|
|
1644
|
+
});
|
|
1645
|
+
try {
|
|
1646
|
+
const response = await wavesApi.post(CONSTANTS2.TOKEN_REFRESH_URL, data, { headers: { ...CONSTANTS2.REQUEST_HEADERS_BASE, "token": token } });
|
|
1647
|
+
if (response.data.code === 220) {
|
|
1648
|
+
logger.info(`${roleId} 获取可用性成功,账号已过期`);
|
|
1649
|
+
return { status: false, msg: "账号已过期" };
|
|
1650
|
+
} else {
|
|
1651
|
+
logger.error(`${roleId} 获取可用性成功,账号可用`);
|
|
1652
|
+
return { status: true, data: JSON.parse(response.data.data).accessToken };
|
|
1653
|
+
}
|
|
1654
|
+
} catch (error) {
|
|
1655
|
+
logger.error(`[isAvailable Error]: ${error.message}`);
|
|
1656
|
+
return { status: false, msg: "疑似网络问题,请检查控制台日志" };
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
__name(isAvailable, "isAvailable");
|
|
1660
|
+
async function refreshData(bat, serverId, roleId, token) {
|
|
1661
|
+
let data = import_qs2.default.stringify({
|
|
1662
|
+
"gameId": 3,
|
|
1663
|
+
"serverId": serverId,
|
|
1664
|
+
"roleId": roleId
|
|
1665
|
+
});
|
|
1666
|
+
try {
|
|
1667
|
+
const response = await wavesApi.post(CONSTANTS2.REFRESH_URL, data, { headers: { ...CONSTANTS2.REQUEST_HEADERS_BASE, "token": token, "b-at": bat } });
|
|
1668
|
+
if (response.data.code === 10902 || response.data.code === 200) {
|
|
1669
|
+
return { status: true, data: response.data.data };
|
|
1670
|
+
} else {
|
|
1671
|
+
logger.error(`[refreshData Error]: ${response.data.msg}`);
|
|
1672
|
+
return { status: false, msg: response.data.msg };
|
|
1673
|
+
}
|
|
1674
|
+
} catch (error) {
|
|
1675
|
+
logger.error(`[refreshData Error]: ${error.message}`);
|
|
1676
|
+
return { status: false, msg: "疑似网络问题,请检查控制台日志" };
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
__name(refreshData, "refreshData");
|
|
1680
|
+
async function signIn(qq_uid) {
|
|
1681
|
+
const userInfo = await checkUserToken(qq_uid);
|
|
1682
|
+
if (!userInfo) {
|
|
1683
|
+
return { status: false, msg: "未检测到登录信息或信息已过期,请重新登录!" };
|
|
1684
|
+
}
|
|
1685
|
+
await refreshData(userInfo.bat, userInfo.server_id, userInfo.role_id, userInfo.token);
|
|
1686
|
+
let data = import_qs2.default.stringify({
|
|
1687
|
+
"gameId": 3,
|
|
1688
|
+
"serverId": userInfo.server_id,
|
|
1689
|
+
"roleId": userInfo.role_id,
|
|
1690
|
+
"userId": userInfo.user_id,
|
|
1691
|
+
"reqMonth": ((/* @__PURE__ */ new Date()).getMonth() + 1).toString().padStart(2, "0")
|
|
1692
|
+
});
|
|
1693
|
+
try {
|
|
1694
|
+
const response = await wavesApi.post(CONSTANTS2.SIGNIN_URL, data, { headers: { ...CONSTANTS2.REQUEST_HEADERS_BASE, "token": userInfo.token, devcode: "", "b-at": userInfo.bat } });
|
|
1695
|
+
if (response.data.code === 200) {
|
|
1696
|
+
if (response.data.data === null) {
|
|
1697
|
+
logger.info(`[signIn Info]: ${qq_uid} 签到失败,返回空数据`);
|
|
1698
|
+
return { status: false, msg: "查询信息失败,请检查库街区数据终端中对应板块的对外展示开关是否打开" };
|
|
1699
|
+
}
|
|
1700
|
+
return { status: true, msg: "签到成功" };
|
|
1701
|
+
} else {
|
|
1702
|
+
logger.error(`[signIn Error]: ${qq_uid} 签到失败: ${response.data.msg}`);
|
|
1703
|
+
return { status: false, msg: response.data.msg };
|
|
1704
|
+
}
|
|
1705
|
+
} catch (error) {
|
|
1706
|
+
logger.error(`[signIn Error]: ${error.message}`);
|
|
1707
|
+
return { status: false, msg: "疑似网络问题,请检查控制台日志" };
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
__name(signIn, "signIn");
|
|
1711
|
+
async function getRoleData(qq_uid) {
|
|
1712
|
+
const userInfo = await checkUserToken(qq_uid);
|
|
1713
|
+
if (!userInfo) {
|
|
1714
|
+
return { status: false, msg: "未检测到登录信息或信息已过期,请重新登录!" };
|
|
1715
|
+
}
|
|
1716
|
+
await refreshData(userInfo.bat, userInfo.server_id, userInfo.role_id, userInfo.token);
|
|
1717
|
+
let data = import_qs2.default.stringify({
|
|
1718
|
+
"gameId": 3,
|
|
1719
|
+
"serverId": userInfo.server_id,
|
|
1720
|
+
"roleId": userInfo.role_id
|
|
1721
|
+
});
|
|
1722
|
+
try {
|
|
1723
|
+
const response = await wavesApi.post(CONSTANTS2.ROLE_DATA_URL, data, { headers: { ...CONSTANTS2.REQUEST_HEADERS_BASE, "token": userInfo.token, "b-at": userInfo.bat } });
|
|
1724
|
+
if (response.data.code === 10902 || response.data.code === 200) {
|
|
1725
|
+
response.data.data = JSON.parse(response.data.data);
|
|
1726
|
+
if (response.data.data === null || !response.data.data.showToGuest) {
|
|
1727
|
+
logger.error(`[getRoleData Error]: ${qq_uid} 获取共鸣者失败,返回空数据`);
|
|
1728
|
+
return { status: false, msg: "查询信息失败,请检查库街区数据终端中对应板块的对外展示开关是否打开" };
|
|
1729
|
+
}
|
|
1730
|
+
logger.info(`[getRoleData Info]: ${qq_uid} 获取共鸣者成功`);
|
|
1731
|
+
return { status: true, data: response.data.data };
|
|
1732
|
+
} else {
|
|
1733
|
+
logger.error(`[getRoleData Error]: ${qq_uid} 获取共鸣者失败: ${response.data.msg}`);
|
|
1734
|
+
return { status: false, msg: response.data.msg };
|
|
1735
|
+
}
|
|
1736
|
+
} catch (error) {
|
|
1737
|
+
logger.error(`[getRoleData Error]: ${qq_uid} 获取共鸣者失败,疑似网络问题: ${error.message}`);
|
|
1738
|
+
return { status: false, msg: "获取共鸣者失败,疑似网络问题,请检查控制台日志" };
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
__name(getRoleData, "getRoleData");
|
|
1742
|
+
|
|
1743
|
+
// src/services/kuro_func/kuro_commands.ts
|
|
1744
|
+
function registerKuroCommands(ctx, connected) {
|
|
1745
|
+
init_userMap();
|
|
1746
|
+
ctx.command("login <参数>", "登录库街区账号").action(async ({ session }, phoneNumber, code) => {
|
|
1747
|
+
if (!dev_mode) {
|
|
1748
|
+
if (!connected) return;
|
|
1749
|
+
if (!is_at_bot(session)) return;
|
|
1750
|
+
}
|
|
1751
|
+
if (!phoneNumber || !code) return "请提供手机号和验证码,如:@bot login [手机号] [验证码]";
|
|
1752
|
+
try {
|
|
1753
|
+
const result = await getToken2(session, phoneNumber, code);
|
|
1754
|
+
if (result.status) {
|
|
1755
|
+
return `登录成功,库街区用户: ${result.data.user_name}`;
|
|
1756
|
+
} else {
|
|
1757
|
+
return `登录失败: ${result.msg}`;
|
|
1758
|
+
}
|
|
1759
|
+
} catch (err) {
|
|
1760
|
+
logger.error(`登录库街区账号失败: ${err.message}`);
|
|
1761
|
+
return `登录库街区账号失败: ${err.message}`;
|
|
1762
|
+
}
|
|
1763
|
+
});
|
|
1764
|
+
ctx.command("signin", "库街区签到").action(async ({ session }) => {
|
|
1765
|
+
if (!dev_mode) {
|
|
1766
|
+
if (!connected) return;
|
|
1767
|
+
if (!is_at_bot(session)) return;
|
|
1768
|
+
}
|
|
1769
|
+
try {
|
|
1770
|
+
const result = await signIn(session.uid);
|
|
1771
|
+
if (result.status) {
|
|
1772
|
+
return "库街区签到成功";
|
|
1773
|
+
} else {
|
|
1774
|
+
return `库街区签到失败: ${result.msg}`;
|
|
1775
|
+
}
|
|
1776
|
+
} catch (err) {
|
|
1777
|
+
logger.error(`库街区签到失败: ${err.message}`);
|
|
1778
|
+
return `库街区签到失败: ${err.message}`;
|
|
1779
|
+
}
|
|
1780
|
+
});
|
|
1781
|
+
ctx.command("roledata <参数>", "共鸣者数据").action(async ({ session }, roleName) => {
|
|
1782
|
+
if (!dev_mode) {
|
|
1783
|
+
if (!connected) return;
|
|
1784
|
+
if (!is_at_bot(session)) return;
|
|
1785
|
+
}
|
|
1786
|
+
if (!roleName) {
|
|
1787
|
+
try {
|
|
1788
|
+
const result = await getRoleData(session.uid);
|
|
1789
|
+
if (result.status) {
|
|
1790
|
+
return result.data;
|
|
1791
|
+
} else {
|
|
1792
|
+
return `共鸣者数据获取失败: ${result.msg}`;
|
|
1793
|
+
}
|
|
1794
|
+
} catch (err) {
|
|
1795
|
+
logger.error(`共鸣者数据获取失败: ${err.message}`);
|
|
1796
|
+
return `共鸣者数据获取失败: ${err.message}`;
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
});
|
|
1800
|
+
}
|
|
1801
|
+
__name(registerKuroCommands, "registerKuroCommands");
|
|
1339
1802
|
|
|
1340
1803
|
// src/index.ts
|
|
1341
1804
|
var name = "cocoyyy-console";
|
|
1342
1805
|
var dev_mode;
|
|
1343
1806
|
var Config = import_koishi9.Schema.object({
|
|
1344
1807
|
function_config: FunctionConfigSchema.description("功能开关配置"),
|
|
1808
|
+
redis_config: RedisConfigSchema.description("Redis配置"),
|
|
1345
1809
|
mysql_config: MysqlConfigSchema.description("MySQL 数据库配置"),
|
|
1346
1810
|
tag_config: SaveConfigSchema.description("tag图片保存配置"),
|
|
1347
1811
|
repeat_config: RepeatConfigSchema.description("复读配置")
|
|
1348
|
-
// rbq_config:my_config.RbqConfigSchema.description('*人配置')
|
|
1349
1812
|
});
|
|
1350
1813
|
var logger = new import_koishi9.Logger(name);
|
|
1351
1814
|
var savePath = null;
|
|
1352
1815
|
async function apply(ctx, config) {
|
|
1353
1816
|
ctx = ctx.guild();
|
|
1354
1817
|
dev_mode = config.function_config.dev_mode;
|
|
1355
|
-
|
|
1356
|
-
|
|
1818
|
+
initSequelize(config?.mysql_config);
|
|
1819
|
+
init_redis(config?.redis_config);
|
|
1357
1820
|
const connected = await testConnect();
|
|
1358
1821
|
if (connected) {
|
|
1359
1822
|
await getTagsModel().sync();
|
|
1360
1823
|
await getImgsModel().sync();
|
|
1361
1824
|
await getRbqPersonModel().sync();
|
|
1362
1825
|
await getRbqContentModel().sync();
|
|
1826
|
+
await getKuroUserModel().sync();
|
|
1363
1827
|
}
|
|
1364
1828
|
savePath = resolveTagBaseDir(config?.tag_config);
|
|
1365
1829
|
registerMenuCommands(ctx, connected, config.function_config);
|
|
@@ -1369,6 +1833,8 @@ async function apply(ctx, config) {
|
|
|
1369
1833
|
registerRepeatMiddleware(ctx, config?.repeat_config);
|
|
1370
1834
|
if (config.function_config.rbq_flag)
|
|
1371
1835
|
registerRbqCommands(ctx, connected);
|
|
1836
|
+
if (config.function_config)
|
|
1837
|
+
registerKuroCommands(ctx, connected);
|
|
1372
1838
|
if (dev_mode)
|
|
1373
1839
|
registerTestCommands(ctx);
|
|
1374
1840
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Model, Optional } from 'sequelize';
|
|
2
|
+
export interface KuroUserAttributes {
|
|
3
|
+
id: number;
|
|
4
|
+
qq_uid: string;
|
|
5
|
+
user_id: string;
|
|
6
|
+
user_name: string;
|
|
7
|
+
role_id: string;
|
|
8
|
+
server_id: string;
|
|
9
|
+
token: string;
|
|
10
|
+
updatetime: Date;
|
|
11
|
+
}
|
|
12
|
+
export type KuroUserCreationAttributes = Optional<KuroUserAttributes, 'id' | 'updatetime'>;
|
|
13
|
+
export declare class KuroUserModel extends Model<KuroUserAttributes, KuroUserCreationAttributes> implements KuroUserAttributes {
|
|
14
|
+
id: number;
|
|
15
|
+
qq_uid: string;
|
|
16
|
+
user_id: string;
|
|
17
|
+
user_name: string;
|
|
18
|
+
role_id: string;
|
|
19
|
+
server_id: string;
|
|
20
|
+
token: string;
|
|
21
|
+
updatetime: Date;
|
|
22
|
+
}
|
|
23
|
+
export declare function getKuroUserModel(): typeof KuroUserModel;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Session } from "koishi";
|
|
2
|
+
declare function init_userMap(): Promise<boolean>;
|
|
3
|
+
declare function getToken(session: Session, mobile: any, code: any): Promise<{
|
|
4
|
+
status: boolean;
|
|
5
|
+
data: any;
|
|
6
|
+
msg?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
status: boolean;
|
|
9
|
+
msg: any;
|
|
10
|
+
data?: undefined;
|
|
11
|
+
}>;
|
|
12
|
+
declare function signIn(qq_uid: string): Promise<{
|
|
13
|
+
status: boolean;
|
|
14
|
+
msg: any;
|
|
15
|
+
}>;
|
|
16
|
+
declare function getRoleData(qq_uid: any): Promise<{
|
|
17
|
+
status: boolean;
|
|
18
|
+
data: any;
|
|
19
|
+
msg?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
status: boolean;
|
|
22
|
+
msg: any;
|
|
23
|
+
data?: undefined;
|
|
24
|
+
}>;
|
|
25
|
+
export { init_userMap, getToken, signIn, getRoleData };
|
package/lib/utils/config.d.ts
CHANGED
|
@@ -7,6 +7,5 @@ interface MysqlConfig {
|
|
|
7
7
|
database: string;
|
|
8
8
|
}
|
|
9
9
|
declare const MysqlConfigSchema: Schema<MysqlConfig>;
|
|
10
|
-
declare function loadMysqlConfigFromEnv(env?: NodeJS.ProcessEnv): MysqlConfig;
|
|
11
10
|
declare function toMysqlUri(cfg: MysqlConfig): string;
|
|
12
|
-
export { MysqlConfig, MysqlConfigSchema,
|
|
11
|
+
export { MysqlConfig, MysqlConfigSchema, toMysqlUri, };
|
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.
|
|
4
|
+
"version": "1.0.12-beta.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"contributors": [
|
|
@@ -21,7 +21,10 @@
|
|
|
21
21
|
"koishi": "^4.18.7"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
+
"axios": "^1.12.2",
|
|
24
25
|
"mysql2": "^3.11.0",
|
|
25
|
-
"
|
|
26
|
+
"qs": "^6.14.0",
|
|
27
|
+
"sequelize": "^6.37.3",
|
|
28
|
+
"ioredis": "^5.8.2"
|
|
26
29
|
}
|
|
27
30
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Context } from "koishi";
|
|
2
|
-
declare function saveImg(ctx: Context, tag_name: string, imgurl: string, savePath: string): Promise<{
|
|
3
|
-
result: boolean;
|
|
4
|
-
error: string | null;
|
|
5
|
-
}>;
|
|
6
|
-
declare function randomImgByTag(tag_name: string): Promise<string | null>;
|
|
7
|
-
declare function getImgCountByTag(tag_id: number): Promise<number>;
|
|
8
|
-
export { saveImg, randomImgByTag, getImgCountByTag };
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { TagsModel } from '../models/tags';
|
|
2
|
-
declare function createorUpdateTag(tag_name: string, savePath?: string | null): Promise<{
|
|
3
|
-
result: boolean;
|
|
4
|
-
error: string | null;
|
|
5
|
-
}>;
|
|
6
|
-
declare function getTag(tag_name: string): Promise<TagsModel | null>;
|
|
7
|
-
declare function bindAlias(tag_name: string, alias: string): Promise<{
|
|
8
|
-
result: boolean;
|
|
9
|
-
error: string | null;
|
|
10
|
-
}>;
|
|
11
|
-
declare function unbindAlias(tag_name: string, alias: string): Promise<{
|
|
12
|
-
result: boolean;
|
|
13
|
-
error: string | null;
|
|
14
|
-
}>;
|
|
15
|
-
declare function getTagList(): Promise<{
|
|
16
|
-
tag: string;
|
|
17
|
-
alias: string;
|
|
18
|
-
count: number;
|
|
19
|
-
}[]>;
|
|
20
|
-
export { createorUpdateTag, getTag, bindAlias, unbindAlias, getTagList };
|