koishi-plugin-toram 4.2.0-test.5 → 4.2.0-test.6
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 +19 -11
- package/lib/script/BotTodoMgr.d.ts +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -695,7 +695,7 @@ var _BotTodoMgr = class _BotTodoMgr {
|
|
|
695
695
|
// 新增一条 todo,返回 id
|
|
696
696
|
addTodo(ts, type, payload) {
|
|
697
697
|
const id = `${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
698
|
-
const todo = {
|
|
698
|
+
const todo = { id, ts, type, payload };
|
|
699
699
|
const list = this._todos.get(ts) || [];
|
|
700
700
|
list.push(todo);
|
|
701
701
|
this._todos.set(ts, list);
|
|
@@ -716,7 +716,7 @@ var _BotTodoMgr = class _BotTodoMgr {
|
|
|
716
716
|
removeTodo(ts, id) {
|
|
717
717
|
const list = this._todos.get(ts);
|
|
718
718
|
if (!list) return;
|
|
719
|
-
const next = list.filter((x) => x.
|
|
719
|
+
const next = list.filter((x) => x.id !== id);
|
|
720
720
|
if (next.length > 0) this._todos.set(ts, next);
|
|
721
721
|
else this._todos.delete(ts);
|
|
722
722
|
this.saveTodos();
|
|
@@ -859,20 +859,28 @@ var Config = import_koishi.Schema.intersect([
|
|
|
859
859
|
]);
|
|
860
860
|
async function apply(ctx, config) {
|
|
861
861
|
const logger = ctx.logger("toram");
|
|
862
|
-
ctx.model.extend(
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
862
|
+
ctx.model.extend(
|
|
863
|
+
"toram_user",
|
|
864
|
+
{
|
|
865
|
+
// 各字段的类型声明
|
|
866
|
+
qq: "string",
|
|
867
|
+
nickname: "string",
|
|
868
|
+
otherNames: "list",
|
|
869
|
+
monthlyCardRemindTimeIndex: "integer",
|
|
870
|
+
lastGetMonthlyCardDate: "string"
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
primary: "qq"
|
|
874
|
+
}
|
|
875
|
+
);
|
|
870
876
|
ctx.model.extend("toram_todo", {
|
|
871
877
|
// 各字段的类型声明
|
|
872
|
-
|
|
878
|
+
id: "string",
|
|
873
879
|
ts: "double",
|
|
874
880
|
type: "string",
|
|
875
881
|
payload: "json"
|
|
882
|
+
}, {
|
|
883
|
+
primary: "id"
|
|
876
884
|
});
|
|
877
885
|
JsonMgr.Inst().setLogger(logger);
|
|
878
886
|
await JsonMgr.Inst().loadJson();
|