koishi-plugin-rina-currency 0.0.4 → 0.0.5
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.d.ts +1 -0
- package/lib/index.js +6 -12
- package/lib/scheduler.d.ts +0 -2
- package/package.json +4 -2
- package/readme.md +2 -0
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __export(src_exports, {
|
|
|
36
36
|
name: () => name
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(src_exports);
|
|
39
|
+
var import_koishi_plugin_cron = require("koishi-plugin-cron");
|
|
39
40
|
|
|
40
41
|
// src/config.ts
|
|
41
42
|
var import_koishi = require("koishi");
|
|
@@ -632,19 +633,12 @@ var Scheduler = class {
|
|
|
632
633
|
} else if (this.config.collectOnStart) {
|
|
633
634
|
await this.collectAndAlert();
|
|
634
635
|
}
|
|
635
|
-
this.
|
|
636
|
-
|
|
636
|
+
this.ctx.cron("* * * * *", () => {
|
|
637
|
+
void this.collectIfDue();
|
|
638
|
+
void this.runBroadcasts();
|
|
639
|
+
});
|
|
637
640
|
});
|
|
638
641
|
}
|
|
639
|
-
/** Runs on China-time minute boundaries, with 17:00 as the daily anchor. */
|
|
640
|
-
scheduleAlignedCollections() {
|
|
641
|
-
const now = /* @__PURE__ */ new Date();
|
|
642
|
-
const delay = 6e4 - now.getSeconds() * 1e3 - now.getMilliseconds();
|
|
643
|
-
this.ctx.setTimeout(() => {
|
|
644
|
-
void this.collectIfDue();
|
|
645
|
-
this.ctx.setInterval(() => void this.collectIfDue(), 6e4);
|
|
646
|
-
}, delay);
|
|
647
|
-
}
|
|
648
642
|
getDueCollection(now = /* @__PURE__ */ new Date()) {
|
|
649
643
|
const clock = chinaClock(now);
|
|
650
644
|
const minutesSinceMidnight = clock.hour * 60 + clock.minute;
|
|
@@ -835,7 +829,7 @@ var RateService = class {
|
|
|
835
829
|
|
|
836
830
|
// src/index.ts
|
|
837
831
|
var name = "rina-currency";
|
|
838
|
-
var inject = ["database"];
|
|
832
|
+
var inject = ["database", "cron"];
|
|
839
833
|
var Config2 = Config;
|
|
840
834
|
function apply(ctx, config) {
|
|
841
835
|
extendModel(ctx);
|
package/lib/scheduler.d.ts
CHANGED
|
@@ -10,8 +10,6 @@ export declare class Scheduler {
|
|
|
10
10
|
private lastCollectionSlot?;
|
|
11
11
|
constructor(ctx: Context, logger: Logger, service: RateService, config: Config);
|
|
12
12
|
start(): void;
|
|
13
|
-
/** Runs on China-time minute boundaries, with 17:00 as the daily anchor. */
|
|
14
|
-
private scheduleAlignedCollections;
|
|
15
13
|
private getDueCollection;
|
|
16
14
|
private collectIfDue;
|
|
17
15
|
private getBot;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-rina-currency",
|
|
3
3
|
"description": "面向购汇决策的日元汇率插件,基于中行和工行数据",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"koishi": "^4.18.7"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
+
"koishi-plugin-cron": "^3.1.0",
|
|
24
25
|
"sharp": "^0.34.2"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
@@ -34,7 +35,8 @@
|
|
|
34
35
|
},
|
|
35
36
|
"service": {
|
|
36
37
|
"required": [
|
|
37
|
-
"database"
|
|
38
|
+
"database",
|
|
39
|
+
"cron"
|
|
38
40
|
]
|
|
39
41
|
}
|
|
40
42
|
}
|
package/readme.md
CHANGED