|
1 |
| -const UtilsModule = require("../utils/utilsModule"); |
2 | 1 | const config = require("../config/config");
|
3 | 2 | const helper = require("../utils/helper");
|
| 3 | +const schedule = require("../utils/schedule"); |
4 | 4 | const Logger = require("../utils/logger");
|
5 | 5 |
|
6 | 6 | const logger = new Logger("modules/legacy");
|
@@ -41,7 +41,7 @@ const main = async controller => {
|
41 | 41 | setPTZRoamMode(controller, currentScene);
|
42 | 42 | }
|
43 | 43 |
|
44 |
| - runAtSpecificTimeOfDay(config.restrictedHours.start - 1, 55, () => { |
| 44 | + schedule(config.restrictedHours.start - 1, 55, () => { |
45 | 45 | try {
|
46 | 46 | let now = new Date();
|
47 | 47 | let minutes = now.getUTCMinutes();
|
@@ -2780,40 +2780,4 @@ async function setPTZRoamMode(controller, scene) {
|
2780 | 2780 | roamTimeout = setTimeout(setPTZRoamMode, length * 1000, controller, scene);
|
2781 | 2781 | }
|
2782 | 2782 |
|
2783 |
| -// function runAtSpecificTimeOfDay(hour, minutes, func) { |
2784 |
| -// const twentyFourHours = 86400000; |
2785 |
| -// const now = new Date(); |
2786 |
| -// let eta_ms = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), hour, minutes, 0, 0).getTime() - now; |
2787 |
| -// if (eta_ms < 0) { |
2788 |
| -// eta_ms += twentyFourHours; |
2789 |
| -// } |
2790 |
| -// let nowMin = now.getUTCMinutes(); |
2791 |
| -// let nowHour = now.getUTCHours(); |
2792 |
| -// logger.log("check time: ",now,nowHour,nowMin,config); |
2793 |
| -// logger.log("setup !livecam Timer for: ",eta_ms); |
2794 |
| -// setTimeout(function () { |
2795 |
| -// //run once |
2796 |
| -// func(); |
2797 |
| -// // run every 24 hours from now on |
2798 |
| -// setInterval(func, twentyFourHours); |
2799 |
| -// }, eta_ms); |
2800 |
| -// } |
2801 |
| - |
2802 |
| -function runAtSpecificTimeOfDay(hour, minutes, func) { |
2803 |
| - const twentyFourHours = 86400000; |
2804 |
| - const now = new Date(); |
2805 |
| - let next = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), hour, minutes, 0, 0).getTime(); |
2806 |
| - if (next < Date.now()) { |
2807 |
| - next += twentyFourHours; |
2808 |
| - } |
2809 |
| - |
2810 |
| - setInterval(function () { |
2811 |
| - if (next < Date.now()) { |
2812 |
| - func(); |
2813 |
| - next += twentyFourHours; |
2814 |
| - } |
2815 |
| - }, 60_000); |
2816 |
| - } |
2817 |
| - |
2818 | 2783 | module.exports = Object.assign(main, { onTwitchMessage });
|
2819 |
| - |
0 commit comments