koishi-plugin-toram 4.2.0 → 4.2.1-test.1

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
@@ -195,7 +195,7 @@ function scheduleMonthlyCardReminders(groupId, hours) {
195
195
  }
196
196
  }
197
197
  __name(scheduleMonthlyCardReminders, "scheduleMonthlyCardReminders");
198
- async function executeMonthlyCardReminder(item) {
198
+ function executeMonthlyCardReminder(item) {
199
199
  const payload = item.payload || {};
200
200
  const groupId = payload.groupId;
201
201
  const timeIndex = payload.timeIndex;
@@ -687,19 +687,18 @@ var _BotTodoMgr = class _BotTodoMgr {
687
687
  });
688
688
  }
689
689
  // 持久化内存中的 todo
690
- saveTodos() {
691
- const data = [];
692
- this._todos.forEach((list) => data.push(...list));
693
- this.ctx.database.upsert("toram_todo", data);
690
+ async saveTodos() {
691
+ const data = Array.from(this._todos.values()).flat();
692
+ await this.ctx.database.upsert("toram_todo", data);
694
693
  }
695
694
  // 新增一条 todo,返回 id
696
- addTodo(ts, type, payload) {
695
+ async addTodo(ts, type, payload) {
697
696
  const id = `${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
698
697
  const todo = { id, ts, type, payload };
699
698
  const list = this._todos.get(ts) || [];
700
699
  list.push(todo);
701
700
  this._todos.set(ts, list);
702
- this.saveTodos();
701
+ await this.saveTodos();
703
702
  if (this._started) {
704
703
  if (this._nextTs === void 0 || ts < this._nextTs) {
705
704
  this.scheduleNext();
@@ -889,7 +888,7 @@ async function apply(ctx, config) {
889
888
  TalkMgr.Inst().setTalks();
890
889
  await UserMgr.Inst().setUsers(ctx);
891
890
  MonsterMgr.Inst().setMonsters();
892
- BotTodoMgr.Inst().setTodos(ctx);
891
+ await BotTodoMgr.Inst().setTodos(ctx);
893
892
  registerBotTodoHandlers();
894
893
  BotTodoMgr.Inst().start();
895
894
  scheduleMonthlyCardReminders(config.groupId, [
@@ -21,7 +21,7 @@ export declare class BotTodoMgr {
21
21
  private _started;
22
22
  setTodos(ctx: Context): Promise<void>;
23
23
  private saveTodos;
24
- addTodo(ts: number, type: string, payload?: any): string;
24
+ addTodo(ts: number, type: string, payload?: any): Promise<string>;
25
25
  getTodosAt(ts: number): BotTodoItem[];
26
26
  removeTodo(ts: number, id: string): void;
27
27
  removeTodosAt(ts: number): void;
@@ -1,4 +1,4 @@
1
1
  import { BotTodoItem } from "../BotTodoMgr";
2
2
  export declare const MONTHLY_CARD_REMINDER_TYPE = "monthly-card-reminder";
3
3
  export declare function scheduleMonthlyCardReminders(groupId: string, hours: number[]): void;
4
- export declare function executeMonthlyCardReminder(item: BotTodoItem): Promise<void>;
4
+ export declare function executeMonthlyCardReminder(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.0",
4
+ "version": "4.2.1-test.1",
5
5
  "contributors": [
6
6
  "青灯 <1874053520@qq.com>"
7
7
  ],