koishi-plugin-toram 0.2.1 → 0.2.2-alpha.10
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.js +105 -20
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -21,27 +21,112 @@ async function apply(ctx, config) {
|
|
|
21
21
|
}, {
|
|
22
22
|
primary: 'id'
|
|
23
23
|
});
|
|
24
|
+
ctx.model.extend('toram_team', {
|
|
25
|
+
id: 'string',
|
|
26
|
+
form: 'number',
|
|
27
|
+
member_id: 'number',
|
|
28
|
+
member_name: 'string',
|
|
29
|
+
until_Unix: 'number',
|
|
30
|
+
until_string: 'string',
|
|
31
|
+
content: 'string'
|
|
32
|
+
}, {
|
|
33
|
+
primary: 'id'
|
|
34
|
+
});
|
|
24
35
|
let n;
|
|
25
36
|
let x;
|
|
26
37
|
let text;
|
|
27
38
|
let 等级差倍率 = [11, 11, 11, 11, 11, 10, 9, 7, 3];
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
ctx.command('组队 <截止时间> <求组内容>').action(async ({ session }, ...args) => {
|
|
40
|
+
let 截止时间 = args[0], 组队内容 = args[1];
|
|
41
|
+
let 截止时间_年 = 0;
|
|
42
|
+
if (截止时间 == undefined || 组队内容 == undefined || /^\d+月\d+日(前)?$/.test(截止时间) == false) {
|
|
43
|
+
return '如果你要发布组队信息,请输入"组队 时间/截止时间 求组内容"来进行发布哦?\n例如"组队 5月1日前 210升级"表示截止至5月1日结束前希望组队进行210升级;\n"组队 5月2日 190托环"表示5月2日当天希望组队进行190托环';
|
|
44
|
+
}
|
|
45
|
+
const 组队对象 = await ctx.database.get('toram_team', `${session.guildId}${session.userId}`);
|
|
46
|
+
if (组队对象) {
|
|
47
|
+
return '为防止资源占用,每个人同一时间只能发布一个组队哦~';
|
|
48
|
+
}
|
|
49
|
+
const 截止时间拆分 = 截止时间.split('月');
|
|
50
|
+
const 截止时间_月 = Number(截止时间拆分[0]);
|
|
51
|
+
const 截止时间_日 = Number(截止时间拆分[1].replace('日', ''));
|
|
52
|
+
const 当前时间date = new Date();
|
|
53
|
+
const 当前时间_年 = 当前时间date.getFullYear();
|
|
54
|
+
const 当前时间_月 = 当前时间date.getMonth() + 1;
|
|
55
|
+
const 当前时间_日 = 当前时间date.getDate();
|
|
56
|
+
if (截止时间_月 < 当前时间_月 || (截止时间_月 == 当前时间_月 && 截止时间_日 < 当前时间_日)) {
|
|
57
|
+
截止时间_年 = 当前时间_年 + 1;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
截止时间_年 = 当前时间_年;
|
|
61
|
+
}
|
|
62
|
+
;
|
|
63
|
+
const 截止时间字符串 = `${截止时间_年}-${截止时间_月}-${截止时间_日 + 1}`;
|
|
64
|
+
const 截止时间date = new Date(截止时间字符串);
|
|
65
|
+
if (isNaN(截止时间date.getTime())) {
|
|
66
|
+
return '你确定是这个日期吗?';
|
|
67
|
+
}
|
|
68
|
+
;
|
|
69
|
+
const 最大时间date = new Date(当前时间date.getTime() + 8 * 24 * 60 * 60 * 1000);
|
|
70
|
+
if (截止时间date > 最大时间date) {
|
|
71
|
+
return '为防止资源占用,只支持输入未来一周的时间哦~';
|
|
72
|
+
}
|
|
73
|
+
;
|
|
74
|
+
const { nickname } = await session.onebot.getGroupMemberInfo(session.guildId, session.userId, true);
|
|
75
|
+
await ctx.database.upsert('toram_team', [{ id: `${session.guildId}${session.userId}`, form: session.guildId, member_id: session.userId, member_name: nickname, until: 截止时间date.getTime(), until_string: 截止时间, content: 组队内容 }]);
|
|
76
|
+
return '成功发布求组信息到组队大厅!';
|
|
77
|
+
});
|
|
78
|
+
ctx.command('组队大厅 [页码]').action(async ({ session }, 输入页码) => {
|
|
79
|
+
{
|
|
80
|
+
let 起始索引 = 0;
|
|
81
|
+
let 结束索引 = 0;
|
|
82
|
+
let 页码 = 0;
|
|
83
|
+
const 当前时间date = new Date();
|
|
84
|
+
await ctx.database.remove('toram_team', { until: { $lte: 当前时间date.getTime() } });
|
|
85
|
+
const 本群组队 = await ctx.database.get('toram_team', { form: session.guildId });
|
|
86
|
+
const 本群组队数 = 本群组队.length;
|
|
87
|
+
const 总页数 = Math.max(Math.ceil(本群组队数 / 10), 1);
|
|
88
|
+
if (输入页码 == undefined || Number.isInteger(Number(输入页码)) == false || 输入页码 <= 0 || isNaN(Number(输入页码)) || 输入页码 > 总页数) {
|
|
89
|
+
页码 = 1;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
页码 = 输入页码;
|
|
93
|
+
}
|
|
94
|
+
;
|
|
95
|
+
text = '组队大厅\n';
|
|
96
|
+
if (本群组队数 == 0) {
|
|
97
|
+
text += '【还没有人发布组队信息呢】';
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
起始索引 = (页码 - 1) * 10;
|
|
101
|
+
结束索引 = Math.min(页码 * 10 - 1, 本群组队数 - 1);
|
|
102
|
+
const 目标页数据 = 本群组队.slice(起始索引, 结束索引);
|
|
103
|
+
const 目标页信息结果 = 目标页数据.map((team) => {
|
|
104
|
+
return `${team?.member_name} ${team?.until_string} ${team?.content}`;
|
|
105
|
+
}).join('\n');
|
|
106
|
+
text += 目标页信息结果;
|
|
107
|
+
}
|
|
108
|
+
text += '\n第' + 页码 + '/' + 总页数 + '页';
|
|
109
|
+
if (页码 != 输入页码) {
|
|
110
|
+
text += '\n可以输入"组队大厅 页码数"来查看指定的页码哦';
|
|
111
|
+
}
|
|
112
|
+
return text;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
ctx.command('取消组队').action(async ({ session }) => {
|
|
116
|
+
{
|
|
117
|
+
const 删除对象 = await ctx.database.get('toram_team', { id: `${session.guildId}${session.userId}` });
|
|
118
|
+
if (删除对象) {
|
|
119
|
+
await ctx.database.remove('toram_team', { id: 删除对象.id });
|
|
120
|
+
return '已取消组队';
|
|
121
|
+
}
|
|
122
|
+
return '你没有正在进行的组队';
|
|
123
|
+
}
|
|
124
|
+
});
|
|
39
125
|
ctx.command('升级 <等级数>').action(async ({ session }, 等级) => {
|
|
40
126
|
{
|
|
41
127
|
if (等级 != undefined) {
|
|
42
128
|
if (isNaN(Number(等级)) || Number.isInteger(Number(等级)) == false || 等级 <= 0 || 等级 >= config.版本等级) {
|
|
43
|
-
|
|
44
|
-
return 乱用升级回复[Math.ceil(Math.random() * n)];
|
|
129
|
+
return '没救了,别练了,埋了罢【无慈悲】';
|
|
45
130
|
}
|
|
46
131
|
;
|
|
47
132
|
if (等级 < 38) {
|
|
@@ -62,9 +147,9 @@ async function apply(ctx, config) {
|
|
|
62
147
|
const 等级符合定点王 = rows1.filter(row => row.type === '定点王');
|
|
63
148
|
n = 等级符合定点王.length - 1;
|
|
64
149
|
text = '定点王:\n';
|
|
65
|
-
const 等级符合定点王经验 = 等级符合定点王.map((
|
|
66
|
-
x = 等级差倍率[Math.abs(等级 -
|
|
67
|
-
return
|
|
150
|
+
const 等级符合定点王经验 = 等级符合定点王.map((boss) => {
|
|
151
|
+
x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
|
|
152
|
+
return boss.baseEXP * x;
|
|
68
153
|
});
|
|
69
154
|
const 经验最大定点王索引 = 等级符合定点王经验.map((exp, i) => [exp, i])
|
|
70
155
|
.sort(([a], [b]) => b - a)
|
|
@@ -79,9 +164,9 @@ async function apply(ctx, config) {
|
|
|
79
164
|
const 等级符合野王 = rows1.filter(row => row.type === '野王');
|
|
80
165
|
n = 等级符合野王.length - 1;
|
|
81
166
|
text += '\n\n野王:\n';
|
|
82
|
-
const 等级符合野王经验 = 等级符合野王.map((
|
|
83
|
-
x = 等级差倍率[Math.abs(等级 -
|
|
84
|
-
return
|
|
167
|
+
const 等级符合野王经验 = 等级符合野王.map((boss) => {
|
|
168
|
+
x = 等级差倍率[Math.abs(等级 - boss.level)] || 0;
|
|
169
|
+
return boss.baseEXP * x;
|
|
85
170
|
});
|
|
86
171
|
const 经验最大野王索引 = 等级符合野王经验.map((exp, i) => [exp, i])
|
|
87
172
|
.sort(([a], [b]) => b - a)
|
|
@@ -97,7 +182,7 @@ async function apply(ctx, config) {
|
|
|
97
182
|
}
|
|
98
183
|
}
|
|
99
184
|
else {
|
|
100
|
-
return '如果你要查询升级头目,请输入"升级
|
|
185
|
+
return '如果你要查询升级头目,请输入"升级 等级数"来进行查询哦';
|
|
101
186
|
}
|
|
102
187
|
}
|
|
103
188
|
});
|