koishi-plugin-toram 0.2.2-alpha.8 → 0.2.2
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 -0
- package/lib/index.js +52 -48
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -8,6 +8,7 @@ exports.Config = koishi_1.Schema.object({
|
|
|
8
8
|
版本等级: koishi_1.Schema.number().default(240),
|
|
9
9
|
升级_定点王数量: koishi_1.Schema.number().default(6),
|
|
10
10
|
升级_野王数量: koishi_1.Schema.number().default(4),
|
|
11
|
+
组队_未来天数: koishi_1.Schema.number().default(7),
|
|
11
12
|
});
|
|
12
13
|
async function apply(ctx, config) {
|
|
13
14
|
ctx.model.extend('toram_boss', {
|
|
@@ -37,47 +38,49 @@ async function apply(ctx, config) {
|
|
|
37
38
|
let text;
|
|
38
39
|
let 等级差倍率 = [11, 11, 11, 11, 11, 10, 9, 7, 3];
|
|
39
40
|
ctx.command('组队 <截止时间> <求组内容>').action(async ({ session }, ...args) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
else {
|
|
51
|
-
const 截止时间拆分 = 截止时间.split('月');
|
|
52
|
-
const 截止时间_月 = Number(截止时间拆分[0]);
|
|
53
|
-
const 截止时间_日 = Number(截止时间拆分[1].replace('日', ''));
|
|
54
|
-
const 当前时间date = new Date();
|
|
55
|
-
const 当前时间_年 = 当前时间date.getFullYear();
|
|
56
|
-
const 当前时间_月 = 当前时间date.getMonth() + 1;
|
|
57
|
-
const 当前时间_日 = 当前时间date.getDate();
|
|
58
|
-
if (截止时间_月 < 当前时间_月 || (截止时间_月 == 当前时间_月 && 截止时间_日 < 当前时间_日)) {
|
|
59
|
-
截止时间_年 = 当前时间_年 + 1;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
截止时间_年 = 当前时间_年;
|
|
63
|
-
}
|
|
64
|
-
;
|
|
65
|
-
const 截止时间字符串 = `${截止时间_年}-${截止时间_月}-${截止时间_日 + 1}`;
|
|
66
|
-
const 截止时间date = new Date(截止时间字符串);
|
|
67
|
-
if (isNaN(截止时间date.getTime())) {
|
|
68
|
-
return '你确定是这个日期吗?';
|
|
69
|
-
}
|
|
70
|
-
;
|
|
71
|
-
const 最大时间date = new Date(当前时间date.getTime() + 8 * 24 * 60 * 60 * 1000);
|
|
72
|
-
if (截止时间date > 最大时间date) {
|
|
73
|
-
return '为防止资源占用,只支持输入未来一周的时间哦~';
|
|
74
|
-
}
|
|
75
|
-
;
|
|
76
|
-
const { nickname } = await session.onebot.getGroupMemberInfo(session.guildId, session.userId, false);
|
|
77
|
-
await ctx.database.upsert('toram_team', [{ id: session.guildId.toString() + session.userId.toString(), form: session.guildId, member_id: session.userId, member_name: nickname, until: 截止时间date.getTime(), until_string: 截止时间, content: 组队内容 }]);
|
|
78
|
-
return '成功发布求组信息到组队大厅!';
|
|
79
|
-
}
|
|
41
|
+
const 当前时间date = new Date();
|
|
42
|
+
await ctx.database.remove('toram_team', { until_Unix: { $lte: 当前时间date.getTime() } });
|
|
43
|
+
let 截止时间 = args[0], 组队内容 = args[1];
|
|
44
|
+
let 截止时间_年 = 0;
|
|
45
|
+
if (截止时间 == undefined || 组队内容 == undefined || /^\d+月\d+日(前)?$/.test(截止时间) == false) {
|
|
46
|
+
return '如果你要发布组队信息,请输入\n"组队 时间/截止时间 求组内容"\n\n示例:\n"组队 5月1日前 210升级"表示截止至5月1日结束前希望组队进行210升级;\n"组队 5月2日 190托环"表示5月2日当天希望组队进行190托环';
|
|
47
|
+
}
|
|
48
|
+
const 组队对象 = await ctx.database.get('toram_team', `${session.guildId}${session.userId}`);
|
|
49
|
+
if (组队对象.length != 0) {
|
|
50
|
+
return '每个人同一时间只能发布一个组队哦~';
|
|
80
51
|
}
|
|
52
|
+
const 截止时间拆分 = 截止时间.split('月');
|
|
53
|
+
const 截止时间_月 = Number(截止时间拆分[0]);
|
|
54
|
+
const 截止时间_日 = Number(截止时间拆分[1].replace('日', ''));
|
|
55
|
+
const 当前时间_年 = 当前时间date.getFullYear();
|
|
56
|
+
const 当前时间_月 = 当前时间date.getMonth() + 1;
|
|
57
|
+
const 当前时间_日 = 当前时间date.getDate();
|
|
58
|
+
if (截止时间_月 < 当前时间_月 || (截止时间_月 == 当前时间_月 && 截止时间_日 < 当前时间_日)) {
|
|
59
|
+
截止时间_年 = 当前时间_年 + 1;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
截止时间_年 = 当前时间_年;
|
|
63
|
+
}
|
|
64
|
+
;
|
|
65
|
+
const 截止时间字符串 = `${截止时间_年}-${截止时间_月}-${截止时间_日}`;
|
|
66
|
+
const 截止时间date = new Date(截止时间字符串);
|
|
67
|
+
const 检测时间_年 = 截止时间date.getFullYear();
|
|
68
|
+
const 检测时间_月 = 截止时间date.getMonth() + 1;
|
|
69
|
+
const 检测时间_日 = 截止时间date.getDate();
|
|
70
|
+
const 检测时间字符串 = `${检测时间_年}-${检测时间_月}-${检测时间_日}`;
|
|
71
|
+
if (isNaN(截止时间date.getTime()) || 检测时间字符串 != 截止时间字符串) {
|
|
72
|
+
return '你确定是这个日期吗?';
|
|
73
|
+
}
|
|
74
|
+
;
|
|
75
|
+
截止时间date.setDate(截止时间date.getDate() + 1);
|
|
76
|
+
const 最大时间date = new Date(当前时间date.getTime() + 8 * 24 * 60 * 60 * 1000);
|
|
77
|
+
if (截止时间date > 最大时间date) {
|
|
78
|
+
return '只支持输入未来' + config.组队_未来天数 + '天的时间哦~';
|
|
79
|
+
}
|
|
80
|
+
;
|
|
81
|
+
const { nickname } = await session.onebot.getGroupMemberInfo(session.guildId, session.userId, true);
|
|
82
|
+
await ctx.database.upsert('toram_team', [{ id: `${session.guildId}${session.userId}`, form: session.guildId, member_id: session.userId, member_name: nickname, until_Unix: 截止时间date.getTime(), until_string: 截止时间, content: 组队内容 }]);
|
|
83
|
+
return '成功发布求组信息到组队大厅!';
|
|
81
84
|
});
|
|
82
85
|
ctx.command('组队大厅 [页码]').action(async ({ session }, 输入页码) => {
|
|
83
86
|
{
|
|
@@ -85,7 +88,7 @@ async function apply(ctx, config) {
|
|
|
85
88
|
let 结束索引 = 0;
|
|
86
89
|
let 页码 = 0;
|
|
87
90
|
const 当前时间date = new Date();
|
|
88
|
-
await ctx.database.remove('toram_team', {
|
|
91
|
+
await ctx.database.remove('toram_team', { until_Unix: { $lte: 当前时间date.getTime() } });
|
|
89
92
|
const 本群组队 = await ctx.database.get('toram_team', { form: session.guildId });
|
|
90
93
|
const 本群组队数 = 本群组队.length;
|
|
91
94
|
const 总页数 = Math.max(Math.ceil(本群组队数 / 10), 1);
|
|
@@ -96,31 +99,32 @@ async function apply(ctx, config) {
|
|
|
96
99
|
页码 = 输入页码;
|
|
97
100
|
}
|
|
98
101
|
;
|
|
99
|
-
text = '
|
|
102
|
+
text = '组队大厅 第' + 页码 + '/' + 总页数 + '页\n\n';
|
|
100
103
|
if (本群组队数 == 0) {
|
|
101
104
|
text += '【还没有人发布组队信息呢】';
|
|
102
105
|
}
|
|
103
106
|
else {
|
|
104
107
|
起始索引 = (页码 - 1) * 10;
|
|
105
|
-
结束索引 = Math.min(页码 * 10
|
|
108
|
+
结束索引 = Math.min(页码 * 10, 本群组队数);
|
|
106
109
|
const 目标页数据 = 本群组队.slice(起始索引, 结束索引);
|
|
107
110
|
const 目标页信息结果 = 目标页数据.map((team) => {
|
|
108
111
|
return `${team?.member_name} ${team?.until_string} ${team?.content}`;
|
|
109
112
|
}).join('\n');
|
|
110
113
|
text += 目标页信息结果;
|
|
111
114
|
}
|
|
112
|
-
text += '\n第' + 页码 + '/' + 总页数 + '页';
|
|
113
115
|
if (页码 != 输入页码) {
|
|
114
|
-
text += '\n
|
|
116
|
+
text += '\n\n输入"组队大厅 页码数"查看指定的页码';
|
|
115
117
|
}
|
|
116
118
|
return text;
|
|
117
119
|
}
|
|
118
120
|
});
|
|
119
121
|
ctx.command('取消组队').action(async ({ session }) => {
|
|
120
122
|
{
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
const 当前时间date = new Date();
|
|
124
|
+
await ctx.database.remove('toram_team', { until_Unix: { $lte: 当前时间date.getTime() } });
|
|
125
|
+
const 删除对象 = await ctx.database.get('toram_team', `${session.guildId}${session.userId}`);
|
|
126
|
+
if (删除对象.length != 0) {
|
|
127
|
+
await ctx.database.remove('toram_team', `${session.guildId}${session.userId}`);
|
|
124
128
|
return '已取消组队';
|
|
125
129
|
}
|
|
126
130
|
return '你没有正在进行的组队';
|