koishi-plugin-maple-schedule 0.0.1 → 0.0.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 +6 -15
- package/package.json +1 -1
- package/lib/index.d.ts +0 -28
package/lib/index.js
CHANGED
|
@@ -231,14 +231,7 @@ function apply(ctx, config) {
|
|
|
231
231
|
} else {
|
|
232
232
|
ctx.logger("maple-schedule").info(`执行任务 #${task.id},按时在 ${shouldHaveTime} 执行`);
|
|
233
233
|
}
|
|
234
|
-
const
|
|
235
|
-
const bot = ctx.bots.find(
|
|
236
|
-
(bot2) => bot2.sid === botId || bot2.platform === task.platform && bot2.selfId === task.botId
|
|
237
|
-
);
|
|
238
|
-
if (!bot) {
|
|
239
|
-
ctx.logger("maple-schedule").warn(`机器人 ${botId} 不存在,跳过任务 #${task.id}`);
|
|
240
|
-
continue;
|
|
241
|
-
}
|
|
234
|
+
const bot = ctx.bots[0];
|
|
242
235
|
let messageContent = task.content;
|
|
243
236
|
if (isOverdue) {
|
|
244
237
|
messageContent = `过期任务: 本应在 ${shouldHaveTime} 执行
|
|
@@ -328,8 +321,7 @@ ${task.content}`;
|
|
|
328
321
|
return `定时任务创建成功!
|
|
329
322
|
任务ID: #${newTask.id}
|
|
330
323
|
任务类型: ${taskType}
|
|
331
|
-
执行时间: ${timeDisplay}${intervalDisplay}
|
|
332
|
-
任务内容: ${trimmedContent}`;
|
|
324
|
+
执行时间: ${timeDisplay}${intervalDisplay}`;
|
|
333
325
|
} catch (error) {
|
|
334
326
|
ctx.logger("maple-schedule").error("创建定时任务时出错:", error);
|
|
335
327
|
return "创建定时任务时出错了,请稍后再试。";
|
|
@@ -341,8 +333,8 @@ ${task.content}`;
|
|
|
341
333
|
return "页码必须是正整数!";
|
|
342
334
|
}
|
|
343
335
|
const query = {
|
|
344
|
-
platform: session.platform
|
|
345
|
-
botId: session.bot.selfId
|
|
336
|
+
platform: session.platform
|
|
337
|
+
// botId: session.bot.selfId,
|
|
346
338
|
};
|
|
347
339
|
if (session.channelId) {
|
|
348
340
|
query.channelId = session.channelId;
|
|
@@ -374,7 +366,7 @@ ${task.content}`;
|
|
|
374
366
|
if (task.intervalMs) {
|
|
375
367
|
intervalInfo = `(每${formatInterval(task.intervalMs)}) `;
|
|
376
368
|
}
|
|
377
|
-
output += `${displayIndex}. #${task.id} ${timeDisplay}${intervalInfo}${contentPreview}
|
|
369
|
+
output += `${displayIndex}. #${task.id} ${timeDisplay} ${intervalInfo} ${contentPreview}
|
|
378
370
|
`;
|
|
379
371
|
});
|
|
380
372
|
output += "\n──────────\n";
|
|
@@ -409,8 +401,7 @@ ${task.content}`;
|
|
|
409
401
|
ctx.logger("maple-schedule").info(`用户 ${session.userId} 删除了定时任务 #${id}`);
|
|
410
402
|
await ctx.database.remove("maple-schedule-tasks", { id });
|
|
411
403
|
return `已成功删除定时任务 #${id}
|
|
412
|
-
执行时间: ${timeDisplay}
|
|
413
|
-
任务内容: ${contentPreview}`;
|
|
404
|
+
执行时间: ${timeDisplay}`;
|
|
414
405
|
} catch (error) {
|
|
415
406
|
ctx.logger("maple-schedule").error("删除定时任务时出错:", error);
|
|
416
407
|
return "删除定时任务时出错了,请稍后再试。";
|
package/package.json
CHANGED
package/lib/index.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Context, Schema } from 'koishi';
|
|
2
|
-
export declare const name = "maple-schedule";
|
|
3
|
-
export declare const using: readonly ["database"];
|
|
4
|
-
interface ScheduleTask {
|
|
5
|
-
id: number;
|
|
6
|
-
platform: string;
|
|
7
|
-
botId: string;
|
|
8
|
-
channelId: string | null;
|
|
9
|
-
userId: string;
|
|
10
|
-
content: string;
|
|
11
|
-
nextExecutionTime: Date;
|
|
12
|
-
intervalMs: number | null;
|
|
13
|
-
}
|
|
14
|
-
declare module 'koishi' {
|
|
15
|
-
interface Tables {
|
|
16
|
-
'maple-schedule-tasks': ScheduleTask;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export interface Config {
|
|
20
|
-
maxContentLength: number;
|
|
21
|
-
maxPreviewLength: number;
|
|
22
|
-
sendInterval: number;
|
|
23
|
-
scanInterval: number;
|
|
24
|
-
timeTolerance: number;
|
|
25
|
-
}
|
|
26
|
-
export declare const Config: Schema<Config>;
|
|
27
|
-
export declare function apply(ctx: Context, config: Config): void;
|
|
28
|
-
export {};
|