26 lines
741 B
TypeScript
26 lines
741 B
TypeScript
import { createUeuse } from "@/lib/client";
|
|
import initI18n from "@/lib/i18n";
|
|
import CronExpressionParser from "cron-parser";
|
|
import { format } from "date-fns";
|
|
import i18next from "i18next";
|
|
|
|
await initI18n();
|
|
|
|
const next = BigInt(CronExpressionParser.parse("0 0 1 1 *").next().getTime() * 1_000_000);
|
|
while (process.hrtime.bigint() > next) {}
|
|
|
|
console.log("新年迎春の投稿を行います");
|
|
|
|
try {
|
|
await createUeuse({
|
|
text: i18next.t("hnyNotice", { year: String(new Date().getFullYear()) }),
|
|
}, "新年迎春");
|
|
|
|
console.log("新年迎春投稿時刻:", format(new Date(), "yyyy/M/d H:mm:ss:SSS"));
|
|
process.exit(0);
|
|
} catch (err: any) {
|
|
console.error("message" in err
|
|
? err.message
|
|
: err);
|
|
process.exit(1);
|
|
} |