koishi-plugin-toram 4.2.1 → 4.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.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) {
@@ -1,2 +1,3 @@
1
1
  export * from './monthlyCardReminder';
2
2
  export * from './allMemberReminder';
3
+ export * from './monthlyCardFinalReminder';
@@ -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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-toram",
3
3
  "description": "托拉姆物语小工具",
4
- "version": "4.2.1",
4
+ "version": "4.2.2",
5
5
  "contributors": [
6
6
  "青灯 <1874053520@qq.com>"
7
7
  ],