koishi-plugin-schedule
Advanced tools
Comparing version 2.0.0-alpha.26 to 2.0.0-alpha.27
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const koishi_core_1 = require("koishi-core"); | ||
const koishi_utils_1 = require("koishi-utils"); | ||
koishi_core_1.injectMethods('mysql', 'schedule', { | ||
@@ -24,23 +23,2 @@ createSchedule(time, assignee, interval, command, meta) { | ||
}); | ||
koishi_core_1.injectMethods('level', 'schedule', { | ||
createSchedule(time, assignee, interval, command, meta) { | ||
return this.create('schedule', { time, assignee, interval, command, meta }); | ||
}, | ||
removeSchedule(id) { | ||
return this.remove('schedule', id); | ||
}, | ||
getSchedule(id) { | ||
return this.tables.schedule.get(id).catch(koishi_utils_1.noop); | ||
}, | ||
async getAllSchedules(assignees) { | ||
if (!assignees) | ||
assignees = await koishi_core_1.getSelfIds(); | ||
return new Promise((resolve) => { | ||
const data = []; | ||
this.tables.schedule.createValueStream() | ||
.on('data', item => assignees.includes(item.assignee) ? data.push(item) : null) | ||
.on('end', () => resolve(data)); | ||
}); | ||
}, | ||
}); | ||
//# sourceMappingURL=database.js.map |
import { Context, Meta } from 'koishi-core'; | ||
import './database'; | ||
export * from './utils'; | ||
export interface Schedule { | ||
@@ -5,0 +4,0 @@ id: number; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const koishi_core_1 = require("koishi-core"); | ||
const utils_1 = require("./utils"); | ||
const koishi_utils_1 = require("koishi-utils"); | ||
require("./database"); | ||
__export(require("./utils")); | ||
function inspectSchedule({ id, assignee, meta, interval, command, time }) { | ||
@@ -38,2 +34,7 @@ if (!koishi_core_1.appMap[assignee]) | ||
} | ||
function formatContext(meta) { | ||
return meta.messageType === 'private' ? `私聊 ${meta.userId}` | ||
: meta.messageType === 'group' ? `群聊 ${meta.groupId}` | ||
: `讨论组 ${meta.discussId}`; | ||
} | ||
koishi_core_1.onStart(async () => { | ||
@@ -65,5 +66,5 @@ const { database } = koishi_core_1.appList[0]; | ||
return meta.$send(schedules.map(({ id, time, interval, command, meta }) => { | ||
let output = `${id}. 触发时间:${utils_1.formatTimeAndInterval(time, interval)},指令:${command}`; | ||
let output = `${id}. 触发时间:${koishi_utils_1.formatTimeInterval(time, interval)},指令:${command}`; | ||
if (options.fullList) | ||
output += `,上下文:${utils_1.formatContext(meta)}`; | ||
output += `,上下文:${formatContext(meta)}`; | ||
return output; | ||
@@ -74,7 +75,7 @@ }).join('\n')); | ||
return meta.$send('请输入要执行的指令。'); | ||
const time = utils_1.parseDate(dateSegments.join('-')); | ||
const time = koishi_utils_1.parseDate(dateSegments.join('-')); | ||
if (Number.isNaN(+time)) { | ||
return meta.$send('请输入合法的日期。'); | ||
} | ||
const interval = utils_1.parseTime(options.interval); | ||
const interval = koishi_utils_1.parseTime(options.interval); | ||
if (!interval && options.interval) { | ||
@@ -81,0 +82,0 @@ return meta.$send('请输入合法的时间间隔。'); |
@@ -1,2 +0,1 @@ | ||
import { Meta } from 'koishi-core'; | ||
export declare function parseTime(source: string): number; | ||
@@ -6,2 +5,1 @@ export declare function parseDate(date: string): Date; | ||
export declare function formatTimeAndInterval(time: Date, interval: number): string; | ||
export declare function formatContext(meta: Meta): string; |
@@ -79,8 +79,2 @@ "use strict"; | ||
exports.formatTimeAndInterval = formatTimeAndInterval; | ||
function formatContext(meta) { | ||
return meta.messageType === 'private' ? `私聊 ${meta.userId}` | ||
: meta.messageType === 'group' ? `群聊 ${meta.groupId}` | ||
: `讨论组 ${meta.discussId}`; | ||
} | ||
exports.formatContext = formatContext; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "koishi-plugin-schedule", | ||
"description": "Schedule plugin for Koishi", | ||
"version": "2.0.0-alpha.26", | ||
"version": "2.0.0-alpha.27", | ||
"main": "dist/index.js", | ||
@@ -37,10 +37,10 @@ "typings": "dist/index.d.ts", | ||
"devDependencies": { | ||
"koishi-database-level": "^2.0.0-alpha.24", | ||
"koishi-database-mysql": "^2.0.0-alpha.24", | ||
"koishi-test-utils": "^4.0.0-alpha.24" | ||
"koishi-database-level": "^2.0.0-alpha.25", | ||
"koishi-database-mysql": "^2.0.0-alpha.25", | ||
"koishi-test-utils": "^4.0.0-alpha.25" | ||
}, | ||
"dependencies": { | ||
"koishi-core": "^2.0.0-alpha.24", | ||
"koishi-utils": "^2.0.1" | ||
"koishi-core": "^2.0.0-alpha.25", | ||
"koishi-utils": "^2.0.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
19310
219
Updatedkoishi-core@^2.0.0-alpha.25
Updatedkoishi-utils@^2.0.2