koishi-plugin-toram 4.2.1 → 4.2.3
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
CHANGED
|
@@ -241,6 +241,53 @@ function executeAllMemberReminder(item) {
|
|
|
241
241
|
}
|
|
242
242
|
__name(executeAllMemberReminder, "executeAllMemberReminder");
|
|
243
243
|
|
|
244
|
+
// src/script/botFunction/monthlyCardFinalReminder.ts
|
|
245
|
+
var MONTHLY_CARD_FINAL_REMINDER_TYPE = "monthly-card-final-reminder";
|
|
246
|
+
async function scheduleMonthlyCardFinalReminder(groupId) {
|
|
247
|
+
const now = /* @__PURE__ */ new Date();
|
|
248
|
+
const next = new Date(now);
|
|
249
|
+
next.setHours(23, 30, 0, 0);
|
|
250
|
+
if (next.getTime() <= now.getTime()) next.setDate(next.getDate() + 1);
|
|
251
|
+
const ts = next.getTime();
|
|
252
|
+
const exists = (BotTodoMgr.Inst().getTodosAt(ts) || []).some(
|
|
253
|
+
(x) => x.type === MONTHLY_CARD_FINAL_REMINDER_TYPE && x.payload?.groupId === groupId
|
|
254
|
+
);
|
|
255
|
+
if (!exists) {
|
|
256
|
+
await BotTodoMgr.Inst().addTodo(ts, MONTHLY_CARD_FINAL_REMINDER_TYPE, { groupId });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
__name(scheduleMonthlyCardFinalReminder, "scheduleMonthlyCardFinalReminder");
|
|
260
|
+
function executeMonthlyCardFinalReminder(item) {
|
|
261
|
+
const payload = item.payload || {};
|
|
262
|
+
const groupId = payload.groupId;
|
|
263
|
+
if (!groupId) return;
|
|
264
|
+
const atUsers = genMonthlyCardFinalReminderUsers();
|
|
265
|
+
if (atUsers) {
|
|
266
|
+
TalkMgr.Inst().send(groupId, "月卡最后提醒", { atUsers });
|
|
267
|
+
}
|
|
268
|
+
const next = new Date(item.ts + 24 * 60 * 60 * 1e3);
|
|
269
|
+
next.setHours(23, 30, 0, 0);
|
|
270
|
+
const nextTs = next.getTime();
|
|
271
|
+
const exists = (BotTodoMgr.Inst().getTodosAt(nextTs) || []).some(
|
|
272
|
+
(x) => x.type === MONTHLY_CARD_FINAL_REMINDER_TYPE && x.payload?.groupId === groupId
|
|
273
|
+
);
|
|
274
|
+
if (!exists) {
|
|
275
|
+
BotTodoMgr.Inst().addTodo(nextTs, MONTHLY_CARD_FINAL_REMINDER_TYPE, { groupId });
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
__name(executeMonthlyCardFinalReminder, "executeMonthlyCardFinalReminder");
|
|
279
|
+
function genMonthlyCardFinalReminderUsers() {
|
|
280
|
+
const users = UserMgr.Inst().getAllMonthlyCardRemindUsers();
|
|
281
|
+
if (users.length === 0) return;
|
|
282
|
+
const now = /* @__PURE__ */ new Date();
|
|
283
|
+
const todayStr = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`;
|
|
284
|
+
const notConfirmed = users.filter((user) => user.lastGetMonthlyCardDate !== todayStr);
|
|
285
|
+
if (notConfirmed.length === 0) return;
|
|
286
|
+
const atUsers = notConfirmed.map((user) => `<at id="${user.qq}"/>`).join(" ");
|
|
287
|
+
return atUsers;
|
|
288
|
+
}
|
|
289
|
+
__name(genMonthlyCardFinalReminderUsers, "genMonthlyCardFinalReminderUsers");
|
|
290
|
+
|
|
244
291
|
// src/script/command/allMemberRemindCommand.ts
|
|
245
292
|
function allMemberRemind(event, args) {
|
|
246
293
|
const qq = event.session.event.user.id;
|
|
@@ -899,6 +946,7 @@ async function apply(ctx, config) {
|
|
|
899
946
|
config.monthlyCardReminder_eveningTime,
|
|
900
947
|
config.monthlyCardReminder_latenightTime
|
|
901
948
|
]);
|
|
949
|
+
scheduleMonthlyCardFinalReminder(config.groupId);
|
|
902
950
|
ctx.on("notice", (session) => {
|
|
903
951
|
if (config.sendDialog) logger.info(session);
|
|
904
952
|
const event = newEvent(ctx, session, config, logger);
|
|
@@ -940,11 +988,19 @@ async function apply(ctx, config) {
|
|
|
940
988
|
const event = newEvent(ctx, session, config, logger);
|
|
941
989
|
allMemberRemind(event, args);
|
|
942
990
|
});
|
|
991
|
+
ctx.command("我领月卡啦").action(async ({ session }, ...args) => {
|
|
992
|
+
const event = newEvent(ctx, session, config, logger);
|
|
993
|
+
const result = confirmMonthlyCardGet(event);
|
|
994
|
+
if (result.code === 1001 /* 通过 */) {
|
|
995
|
+
TalkMgr.Inst().reply(event, "月卡确认领取");
|
|
996
|
+
}
|
|
997
|
+
});
|
|
943
998
|
}
|
|
944
999
|
__name(apply, "apply");
|
|
945
1000
|
function registerBotTodoHandlers() {
|
|
946
1001
|
BotTodoMgr.Inst().on(ALL_MEMBER_REMINDER_TYPE, executeAllMemberReminder);
|
|
947
1002
|
BotTodoMgr.Inst().on(MONTHLY_CARD_REMINDER_TYPE, executeMonthlyCardReminder);
|
|
1003
|
+
BotTodoMgr.Inst().on(MONTHLY_CARD_FINAL_REMINDER_TYPE, executeMonthlyCardFinalReminder);
|
|
948
1004
|
}
|
|
949
1005
|
__name(registerBotTodoHandlers, "registerBotTodoHandlers");
|
|
950
1006
|
function newEvent(ctx, session, config, logger) {
|
package/lib/json/talks.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"@_result_@"
|
|
7
7
|
],
|
|
8
8
|
"被@":[
|
|
9
|
-
"魔导书现在提供这些功能哦:\n1.升级 等级【查询升级头目】\n如:升级 220\n2.月卡提醒 时间段【设置月卡提醒时间】\n时间段可选:凌晨(@_MCRMidnight_@点10分) 早上(@_MCRMorning_@点10分) 中午(@_MCRNoon_@点10分) 下午(@_MCRAfternoon_@点10分) 晚上(@_MCREvening_@点10分) 深夜(@_MCRLatenight_@点10分)\n如:月卡提醒 晚上\n3
|
|
9
|
+
"魔导书现在提供这些功能哦:\n1.升级 等级【查询升级头目】\n如:升级 220\n2.月卡提醒 时间段【设置月卡提醒时间】\n时间段可选:凌晨(@_MCRMidnight_@点10分) 早上(@_MCRMorning_@点10分) 中午(@_MCRNoon_@点10分) 下午(@_MCRAfternoon_@点10分) 晚上(@_MCREvening_@点10分) 深夜(@_MCRLatenight_@点10分)\n如:月卡提醒 晚上\n3.取消月卡提醒\n4.我领月卡啦【告诉魔导书你今天领了月卡,也可以戳一戳魔导书代替。每天23点30分魔导书会对没有确认的人再次提醒】"
|
|
10
10
|
],
|
|
11
11
|
"无权限": [
|
|
12
12
|
"抱歉,只有青灯同意的人才能这么做哦?"
|
|
@@ -32,6 +32,11 @@
|
|
|
32
32
|
"@_atUsers_@ \n布谷布谷,领月卡的时间到啦~",
|
|
33
33
|
"@_atUsers_@ \n快去领今天的月卡吧!"
|
|
34
34
|
],
|
|
35
|
+
"月卡最后提醒": [
|
|
36
|
+
"@_atUsers_@ \n你今天还没有领月卡!快去!",
|
|
37
|
+
"@_atUsers_@ \n你——的——月——卡——要——断——了——!",
|
|
38
|
+
"@_atUsers_@ \n魔导书叫你领月卡为什么不领!【恼】"
|
|
39
|
+
],
|
|
35
40
|
"月卡确认领取": [
|
|
36
41
|
"领月卡是好文明!",
|
|
37
42
|
"看来今天也有好好领月卡呢~",
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BotTodoItem } from "../BotTodoMgr";
|
|
2
|
+
export declare const MONTHLY_CARD_FINAL_REMINDER_TYPE = "monthly-card-final-reminder";
|
|
3
|
+
export declare function scheduleMonthlyCardFinalReminder(groupId: string): Promise<void>;
|
|
4
|
+
export declare function executeMonthlyCardFinalReminder(item: BotTodoItem): void;
|