Skip to content

Commit 5a88390

Browse files
committed
chore: refactor package.json scripts, update dependencies, and add tsdown configuration
- Changed build script from `tsc` to `tsdown`. - Updated start script for production to use `dist/server.mjs`. - Added TypeScript configuration for `tsdown` in a new `tsdown.config.ts` file. - Removed unused dependencies from `package.json` and `pnpm-lock.yaml`. - Refactored app initialization in `src/app.ts` to streamline plugin registration. - Enhanced module registration in `src/modules/loader.ts` for better maintainability. Signed-off-by: Innei <tukon479@gmail.com>
1 parent 9b7e897 commit 5a88390

2 files changed

Lines changed: 5 additions & 34 deletions

File tree

src/modules/mx-space/event-handlers/comment-create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { appConfig } from "app.config";
1+
import { appConfig } from "~/app.config";
22
import {
33
CollectionRefTypes,
44
type NoteModel,

src/modules/mx-space/index.ts

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
import { appConfig } from "~/app.config";
2-
import { CronJob } from "cron";
3-
import { sample } from "lodash";
41
import RemoveMarkdown from "remove-markdown";
5-
import { z } from "zod";
6-
import type { PluginFunction } from "~/lib/plugin";
72
import type { Telegraf } from "telegraf";
83
import type { Message, Update } from "telegraf/types";
4+
import { z } from "zod";
5+
import { appConfig } from "~/app.config";
6+
import type { PluginFunction } from "~/lib/plugin";
97

108
import { createHandler, type WebhookEventSource } from "@mx-space/webhook";
119

1210
import { escapeMarkdown } from "~/lib/helper";
13-
import { createNamespaceLogger } from "~/lib/logger";
1411
import { setTGBotCommands } from "~/lib/register-command";
1512
import { relativeTimeFromNow } from "~/lib/time";
1613

@@ -47,11 +44,7 @@ export const register: PluginFunction = async (ctx) => {
4744
});
4845

4946
// socket.connect()
50-
await Promise.all([
51-
bindEvents(tgBot),
52-
bindCommands(tgBot),
53-
bindCronJob(tgBot),
54-
]);
47+
await Promise.all([bindEvents(tgBot), bindCommands(tgBot)]);
5548
};
5649

5750
async function bindEvents(tgBot: Telegraf) {
@@ -236,25 +229,3 @@ async function bindCommands(tgBot: Telegraf) {
236229
},
237230
]);
238231
}
239-
240-
async function bindCronJob(tgBot: Telegraf) {
241-
const logger = createNamespaceLogger("Mix Space CronJob");
242-
const helloCron = new CronJob(
243-
"0 0 8 * * *",
244-
async () => {
245-
const aggregateData = await getMxSpaceAggregateData();
246-
const hitokoto =
247-
sample((await fetchHitokoto()).from_who.split("")) || "喵";
248-
logger.info("Daily greeting start sending");
249-
await tgBot.telegram.sendMessage(
250-
appConfig.mxSpace.watchChannelId,
251-
`早安!这里是 ${aggregateData.user.name} 的博客,今天也是元气满满的一天!\n\n${hitokoto}`,
252-
);
253-
},
254-
null,
255-
false,
256-
"Asia/Shanghai",
257-
);
258-
259-
helloCron.start();
260-
}

0 commit comments

Comments
 (0)