koishi-plugin-ccb-plus 0.1.7 → 0.1.9
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 +9 -0
- package/lib/index.js +41 -24
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { Context, Schema } from 'koishi';
|
|
2
2
|
export declare const name = "ccb-plus";
|
|
3
|
+
export interface CheatConfig {
|
|
4
|
+
userId: string;
|
|
5
|
+
ywWindow: number;
|
|
6
|
+
ywThreshold: number;
|
|
7
|
+
ywProbability: number;
|
|
8
|
+
critProb: number;
|
|
9
|
+
ywBanDuration: number;
|
|
10
|
+
}
|
|
3
11
|
export interface CCBConfig {
|
|
4
12
|
ywWindow: number;
|
|
5
13
|
ywThreshold: number;
|
|
@@ -9,6 +17,7 @@ export interface CCBConfig {
|
|
|
9
17
|
selfCcb: boolean;
|
|
10
18
|
critProb: number;
|
|
11
19
|
isLog: boolean;
|
|
20
|
+
cheatList: CheatConfig[];
|
|
12
21
|
}
|
|
13
22
|
export interface CCBData {
|
|
14
23
|
[groupId: string]: CCBGroupData[];
|
package/lib/index.js
CHANGED
|
@@ -40,14 +40,23 @@ var import_fs = require("fs");
|
|
|
40
40
|
var path = __toESM(require("path"));
|
|
41
41
|
var name = "ccb-plus";
|
|
42
42
|
var Config = import_koishi.Schema.object({
|
|
43
|
-
ywWindow: import_koishi.Schema.number().default(60).description("
|
|
44
|
-
ywThreshold: import_koishi.Schema.number().default(5).description("
|
|
45
|
-
ywBanDuration: import_koishi.Schema.number().default(900).description("
|
|
46
|
-
ywProbability: import_koishi.Schema.number().default(0.1).min(0).max(1).description("
|
|
47
|
-
whiteList: import_koishi.Schema.array(String).default([]).description("不能进行ccb的id
|
|
43
|
+
ywWindow: import_koishi.Schema.number().default(60).description("全局触发赛博阳痿的窗口时间(秒)"),
|
|
44
|
+
ywThreshold: import_koishi.Schema.number().default(5).description("全局窗口时间内最大ccb数"),
|
|
45
|
+
ywBanDuration: import_koishi.Schema.number().default(900).description("全局养胃时长(秒)"),
|
|
46
|
+
ywProbability: import_koishi.Schema.number().default(0.1).min(0).max(1).description("全局随机养胃概率"),
|
|
47
|
+
whiteList: import_koishi.Schema.array(String).default([]).description("不能进行ccb的id列表(黑名单)"),
|
|
48
48
|
selfCcb: import_koishi.Schema.boolean().default(false).description("是否允许对自己ccb"),
|
|
49
|
-
critProb: import_koishi.Schema.number().default(0.2).min(0).max(1).description("
|
|
50
|
-
isLog: import_koishi.Schema.boolean().default(false).description("完整日志记录")
|
|
49
|
+
critProb: import_koishi.Schema.number().default(0.2).min(0).max(1).description("全局暴击概率"),
|
|
50
|
+
isLog: import_koishi.Schema.boolean().default(false).description("完整日志记录"),
|
|
51
|
+
// --- 新增:开挂配置 Schema ---
|
|
52
|
+
cheatList: import_koishi.Schema.array(import_koishi.Schema.object({
|
|
53
|
+
userId: import_koishi.Schema.string().required().description("用户ID"),
|
|
54
|
+
ywWindow: import_koishi.Schema.number().default(10).description("特权窗口时间(秒)"),
|
|
55
|
+
ywThreshold: import_koishi.Schema.number().default(999).description("特权窗口内最大次数"),
|
|
56
|
+
ywProbability: import_koishi.Schema.number().default(0).min(0).max(1).description("特权养胃概率"),
|
|
57
|
+
critProb: import_koishi.Schema.number().default(0.8).min(0).max(1).description("特权暴击概率"),
|
|
58
|
+
ywBanDuration: import_koishi.Schema.number().default(60).description("特权养胃时长(秒)")
|
|
59
|
+
})).role("table").description("开挂名单(优先级高于全局设置)")
|
|
51
60
|
});
|
|
52
61
|
function apply(ctx, config) {
|
|
53
62
|
const DATA_FILE = path.join(ctx.baseDir, "data", "ccb.json");
|
|
@@ -312,7 +321,7 @@ function apply(ctx, config) {
|
|
|
312
321
|
return message;
|
|
313
322
|
}
|
|
314
323
|
__name(createNewCCBRecord, "createNewCCBRecord");
|
|
315
|
-
ctx.command("ccb [target:user]", "
|
|
324
|
+
ctx.command("ccb [target:user]", "给群友注入生命因子").action(async ({ session }, target) => {
|
|
316
325
|
const checkResult = checkGroupCommand(session);
|
|
317
326
|
if (checkResult) {
|
|
318
327
|
return checkResult;
|
|
@@ -320,21 +329,29 @@ function apply(ctx, config) {
|
|
|
320
329
|
const senderId = session.userId;
|
|
321
330
|
const actorId = senderId;
|
|
322
331
|
const now = Date.now() / 1e3;
|
|
332
|
+
const cheatSetting = config.cheatList.find((c) => c.userId === actorId);
|
|
333
|
+
const currentConfig = {
|
|
334
|
+
ywWindow: cheatSetting ? cheatSetting.ywWindow : config.ywWindow,
|
|
335
|
+
ywThreshold: cheatSetting ? cheatSetting.ywThreshold : config.ywThreshold,
|
|
336
|
+
ywBanDuration: cheatSetting ? cheatSetting.ywBanDuration : config.ywBanDuration,
|
|
337
|
+
ywProbability: cheatSetting ? cheatSetting.ywProbability : config.ywProbability,
|
|
338
|
+
critProb: cheatSetting ? cheatSetting.critProb : config.critProb
|
|
339
|
+
};
|
|
323
340
|
const banEnd = banList[actorId] || 0;
|
|
324
341
|
if (now < banEnd) {
|
|
325
342
|
const remain = Math.floor(banEnd - now);
|
|
326
343
|
const m = Math.floor(remain / 60);
|
|
327
344
|
const s = remain % 60;
|
|
328
|
-
return
|
|
345
|
+
return `嘻嘻,你已经一滴不剩了,填充还剩 ${m}分${s}秒`;
|
|
329
346
|
}
|
|
330
347
|
const times = actionTimes[actorId] = actionTimes[actorId] || [];
|
|
331
|
-
const cutoff = now -
|
|
348
|
+
const cutoff = now - currentConfig.ywWindow;
|
|
332
349
|
while (times.length > 0 && times[0] < cutoff) {
|
|
333
350
|
times.shift();
|
|
334
351
|
}
|
|
335
352
|
times.push(now);
|
|
336
|
-
if (times.length >
|
|
337
|
-
banList[actorId] = now +
|
|
353
|
+
if (times.length > currentConfig.ywThreshold) {
|
|
354
|
+
banList[actorId] = now + currentConfig.ywBanDuration;
|
|
338
355
|
actionTimes[actorId] = [];
|
|
339
356
|
return "冲得出来吗你就冲,再冲就给你折了";
|
|
340
357
|
}
|
|
@@ -344,14 +361,14 @@ function apply(ctx, config) {
|
|
|
344
361
|
}
|
|
345
362
|
if (config.whiteList.includes(targetUserId)) {
|
|
346
363
|
const nickname = await getUserNickname(session, targetUserId) || targetUserId;
|
|
347
|
-
return `${nickname}
|
|
364
|
+
return `${nickname} 不能ccb(悲`;
|
|
348
365
|
}
|
|
349
366
|
if (targetUserId === actorId && !config.selfCcb) {
|
|
350
|
-
return "
|
|
367
|
+
return "兄啊怎么还能捅到自己的啊(恼)";
|
|
351
368
|
}
|
|
352
369
|
const duration = parseFloat((Math.random() * 59 + 1).toFixed(2));
|
|
353
370
|
let V = parseFloat((Math.random() * 99 + 1).toFixed(2));
|
|
354
|
-
const prob =
|
|
371
|
+
const prob = currentConfig.critProb;
|
|
355
372
|
let crit = false;
|
|
356
373
|
if (Math.random() < prob) {
|
|
357
374
|
V = parseFloat((V * 2).toFixed(2));
|
|
@@ -379,14 +396,14 @@ function apply(ctx, config) {
|
|
|
379
396
|
return "对方拒绝了和你ccb";
|
|
380
397
|
}
|
|
381
398
|
}
|
|
382
|
-
if (Math.random() <
|
|
383
|
-
banList[actorId] = now +
|
|
399
|
+
if (Math.random() < currentConfig.ywProbability) {
|
|
400
|
+
banList[actorId] = now + currentConfig.ywBanDuration;
|
|
384
401
|
await session.send(message);
|
|
385
|
-
return "
|
|
402
|
+
return "💥你炸膛了!再也不能ccb了(悲)";
|
|
386
403
|
}
|
|
387
404
|
return message;
|
|
388
405
|
});
|
|
389
|
-
ctx.command("ccbtop", "按次数排行"
|
|
406
|
+
ctx.command("ccbtop", "按次数排行").action(async ({ session }) => {
|
|
390
407
|
const checkResult = checkGroupCommand(session);
|
|
391
408
|
if (checkResult) {
|
|
392
409
|
return checkResult;
|
|
@@ -407,7 +424,7 @@ function apply(ctx, config) {
|
|
|
407
424
|
}
|
|
408
425
|
return msg.trim();
|
|
409
426
|
});
|
|
410
|
-
ctx.command("ccbvol", "按注入量排行"
|
|
427
|
+
ctx.command("ccbvol", "按注入量排行").action(async ({ session }) => {
|
|
411
428
|
const checkResult = checkGroupCommand(session);
|
|
412
429
|
if (checkResult) {
|
|
413
430
|
return checkResult;
|
|
@@ -428,7 +445,7 @@ function apply(ctx, config) {
|
|
|
428
445
|
}
|
|
429
446
|
return msg.trim();
|
|
430
447
|
});
|
|
431
|
-
ctx.command("ccbmax", "按max值排行并输出产生者"
|
|
448
|
+
ctx.command("ccbmax", "按max值排行并输出产生者").action(async ({ session }) => {
|
|
432
449
|
const checkResult = checkGroupCommand(session);
|
|
433
450
|
if (checkResult) {
|
|
434
451
|
return checkResult;
|
|
@@ -505,7 +522,7 @@ function apply(ctx, config) {
|
|
|
505
522
|
}
|
|
506
523
|
return msg.trim();
|
|
507
524
|
});
|
|
508
|
-
ctx.command("ccbinfo [target:user]", "查询某人ccb信息:第一次对他ccb的人,被ccb的总次数,注入总量"
|
|
525
|
+
ctx.command("ccbinfo [target:user]", "查询某人ccb信息:第一次对他ccb的人,被ccb的总次数,注入总量").action(async ({ session }, target) => {
|
|
509
526
|
const checkResult = checkGroupCommand(session);
|
|
510
527
|
if (checkResult) {
|
|
511
528
|
return checkResult;
|
|
@@ -594,7 +611,7 @@ function apply(ctx, config) {
|
|
|
594
611
|
].join("\n");
|
|
595
612
|
return msg;
|
|
596
613
|
});
|
|
597
|
-
ctx.command("xnn", "XNN榜 - 计算群中最xnn特质的群友"
|
|
614
|
+
ctx.command("xnn", "XNN榜 - 计算群中最xnn特质的群友").action(async ({ session }) => {
|
|
598
615
|
const checkResult = checkGroupCommand(session);
|
|
599
616
|
if (checkResult) {
|
|
600
617
|
return checkResult;
|
|
@@ -628,7 +645,7 @@ function apply(ctx, config) {
|
|
|
628
645
|
const userIds = top5.map((item) => item[0]);
|
|
629
646
|
const nicknamePromises = userIds.map((uid) => getUserNickname(session, uid));
|
|
630
647
|
const nicknames = await Promise.all(nicknamePromises);
|
|
631
|
-
let msg = "💎
|
|
648
|
+
let msg = "💎 XNN TOP5 💎\n";
|
|
632
649
|
for (let i = 0; i < top5.length; i++) {
|
|
633
650
|
const [uid, xnn_val] = top5[i];
|
|
634
651
|
const nick = nicknames[i] || uid;
|